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 __STATS_H
22 #define __STATS_H
23 
24 #include <stdio.h>
25 #include "dice.h"
26 #include "strproc.h"
27 #include "global.h"
28 
29 enum STATS {S_UNKNOWN = -1, S_STR, S_DEX, S_TOU, S_LEN, S_WIL, S_MAN, S_PER, S_CHR, S_EOF};
30 
31 extern char * stats_str[];
32 
33 class XStats
34 {
35 public:
36 	XStats(const char * str); // must be the same! "St:1d2 Dx:1d4 To:2d5"
37 	XStats(XStats * xs);
38 	XStats(); //all stats == 0 by default
Get(STATS s)39 	int Get(STATS s) { return stats[s] / 100; }
GetName(STATS s)40 	char * GetName(STATS s) { return stats_str[s]; }
41 	char * GetFullName(STATS s);
SetStat(STATS s,int val)42 	void SetStat(STATS s, int val) { stats[s] = val * 100; }
Modify(STATS s,int val)43 	void Modify(STATS s, int val) { stats[s] += val * 100; }
AddFract(STATS s,int val)44 	void AddFract(STATS s, int val) {stats[s] += val;}
45 	void Set(XStats * s);
46 	void Set(const char * str);
47 	void Add(XStats * s);
48 	void Sub(XStats * s);
49 	bool isEqual(XStats * s);
50 
51 	void Store(XFile * f);
52 	void Restore(XFile * f);
53 
Random()54 	static STATS Random() { return (STATS)(vRand(S_EOF)); }
55 
56 protected:
57 	int stats[S_EOF];
58 };
59 
60 #endif
61