1 /* 2 This file is part of "Avanor, the Land of Mystery" roguelike game 3 Home page: http://www.avanor.com/ 4 Copyright (C) 2000-2003 Vadim Gaidukevich 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21 #ifndef __DICE_H 22 #define __DICE_H 23 24 #include <assert.h> 25 #include <stdlib.h> 26 #include <string.h> 27 #include <stdio.h> 28 29 class XFile; 30 31 //this class is represent XdY : throw Y - side cube X turns 32 class XDice 33 { 34 public: XDice()35 XDice(){} 36 XDice(int _x, int _y, int _z = 0) { Setup(_x, _y, _z); } XDice(XDice * d)37 XDice(XDice * d) { Setup(d); } XDice(const char * str)38 XDice(const char * str) { Setup(str); } // represent "XdY +Z" for example "2d6 - 5" or "4d12 + 30" 39 void Setup(int _x, int _y, int _z = 0) { X = _x; Y = _y; Z = _z; Throw();} 40 void Setup(const char * str); Setup(XDice * d)41 void Setup(XDice * d) { Setup(d->X, d->Y, d->Z); } Add(XDice * d)42 void Add(XDice * d) {X += d->X; Y = (Y + d->Y) / 2; Z += d->Z;} 43 int Throw(); 44 int S; //generated result by throw 45 int X; 46 int Y; 47 int Z; 48 49 void Store(XFile * f); 50 void Restore(XFile * f); 51 52 }; 53 54 #endif 55