YAPOG  0.0.1
Yet Another Pokemon Online Game
BaseStat.cpp
Go to the documentation of this file.
4 
5 namespace yap
6 {
9 
11  : value_ (INITIAL_STAT_VALUE)
12  , effortValue_ (INITIAL_EFFORT_VALUE)
13  {
15  }
16 
18  const UInt16& ev,
19  const UInt16& iv)
20  : value_ (INITIAL_STAT_VALUE)
21  , individualValue_ (iv)
22  , effortValue_ (ev)
23  {
24  }
25 
26  const UInt16& BaseStat::GetValue () const
27  {
28  return value_;
29  }
30 
31 
33  {
34  return individualValue_;
35  }
36 
38  {
39  return effortValue_;
40  }
41 
42  void BaseStat::SetValue (const UInt16& value)
43  {
44  value_ = value;
45  }
46 
48  {
49  individualValue_ = iv;
50  }
51 
53  {
54  effortValue_ = ev;
55  }
56 
57  void BaseStat::ComputeValue (const int& base, const UInt16 level)
58  {
59  UInt16 result = MathHelper::Floor ((((individualValue_ + (2 * base) +
60  MathHelper::Floor (effortValue_ / 4) + 100) * level) / 100)) + 10;
61 
62  SetValue (result);
63  }
64 
65  void BaseStat::AddValue (int value)
66  {
67  value_ += value;
68  }
69 
71  const int& base,
72  const UInt16 level,
73  const float& natureFactor)
74  {
75  UInt16 result = MathHelper::Floor (((individualValue_ + (2 * base) +
76  MathHelper::Floor (effortValue_ / 4)) * level) / 100) + 5;
77 
78  result = MathHelper::Floor (result * natureFactor);
79 
80  SetValue (result);
81  }
82 
83 } // namespace yap