Planeshift
stat.h
Go to the documentation of this file.
1 /*
2  * stat.h
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PS_STAT_HEADER
21 #define PS_STAT_HEADER
22 
23 #include <cstypes.h>
24 
29 class Stat
30 {
31 public:
35  Stat() : value(0.0), max(0.0), rate(0.0), lastUpdate(0) {}
36 
40  void Update(csTicks now);
41 
45  void SetValue(float value, csTicks now);
46 
50  void SetMax(float max);
51 
55  void SetRate(float rate, csTicks now);
56 
62  float GetValue() const
63  {
64  return value;
65  }
66 
70  float GetMax() const
71  {
72  return max;
73  }
74 
78  float GetRate() const
79  {
80  return rate;
81  }
82 private:
83  float value;
84  float max;
85  float rate;
86  csTicks lastUpdate;
87 };
88 
89 #endif
float GetMax() const
Get the max stat value.
Definition: stat.h:70
void SetMax(float max)
Set the maximum stat value.
float GetRate() const
Get the regeneration rate.
Definition: stat.h:78
Represents a stat for the NPC.
Definition: stat.h:29
void SetValue(float value, csTicks now)
Set the stat value.
void SetRate(float rate, csTicks now)
Set the regeneration value for this stat.
Stat()
Constructor.
Definition: stat.h:35
float GetValue() const
Return the current value of the stat.
Definition: stat.h:62
void Update(csTicks now)
Update the stat to now.