JNR
rpg_sheet_modifiers.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
30 
31 
32 // Acrobatics sheet modifiers
33 //
34 class rpgSheet_Acrobate_Mods: public rpgSheet_Mods
35 {
36 public:
37 
38  rpgSheet_Acrobate_Mods() { reset(); };
39 
40  // Modifiers
41  //
42  double dMod_Speed;
43  double dMod_JPower;
44  double dMod_SPower;
45 
46  // Reset modifiers
47  //
48  virtual void reset(void)
49  {
50  dMod_Speed = dMod_JPower = dMod_SPower = 1;
51  }
52 
53  // Apply to another modifier
54  virtual void apply(rpgSheet_Mods *pTarget)
55  {
56  rpgSheet_Acrobate_Mods *pt = (rpgSheet_Acrobate_Mods*) pTarget;
57 
58  pt->dMod_Speed *= dMod_Speed;
59  pt->dMod_JPower *= dMod_JPower;
60  pt->dMod_SPower *= dMod_SPower;
61  }
62 
63  // Load modifers from TS
64  virtual void load(laPropertyList* pElement)
65  {
66  dMod_Speed = pElement->getDouble("mod-Speed");
67  dMod_JPower = pElement->getDouble("mod-JPower");
68  dMod_SPower = pElement->getDouble("mod-SPower");
69  }
70 };
71 
72 // Fighter sheet modifiers
73 //
74 class rpgSheet_Fighter_Mods: public rpgSheet_Acrobate_Mods{
75 public:
76 
77  rpgSheet_Fighter_Mods() { reset(); };
78 
79  // Modifiers
80  //
81  double dMod_AP;
82  double dMod_DP;
83 
84  // Reset modifiers
85  //
86  virtual void reset(void)
87  {
88  rpgSheet_Acrobate_Mods::reset();
89  dMod_AP = dMod_DP = 1;
90  }
91 
92  // Apply to another modifier
93  virtual void apply(rpgSheet_Mods *pTarget)
94  {
95  rpgSheet_Acrobate_Mods::apply(pTarget);
96  rpgSheet_Fighter_Mods *pt = (rpgSheet_Fighter_Mods*) pTarget;
97 
98  pt->dMod_AP *= dMod_AP;
99  pt->dMod_DP *= dMod_DP;
100  }
101 
102  // Load modifers from TS
103  virtual void load(laPropertyList* pElement)
104  {
105  dMod_AP = pElement->getDouble("mod-AP");
106  dMod_DP= pElement->getDouble("mod-DP");
107  }
108 };
109 
110 // Player sheet modifiers
111 //
112 class rpgSheet_PlayableChar_Mods: public rpgSheet_Fighter_Mods{
113 public:
114 
115  rpgSheet_PlayableChar_Mods() { reset(); };
116 
117  // Modifiers
118  //
119  double dMod_XP;
120 
121  // Special effects
122  //
123  // TODO: Revise special effects
124  //
125  M_BOOL bShrink;
126  M_BOOL bLevitate;
127  M_BOOL bGrasshopper;
128  M_BOOL bDrunk;
129 
130  // Reset modifiers
131  //
132  virtual void reset(void)
133  {
134  rpgSheet_Fighter_Mods::reset();
135 
136  dMod_XP = 1;
137 
138  bShrink = bLevitate = bGrasshopper = bDrunk = M_FALSE;
139  }
140 
141  // Apply to another modifier
142  virtual void apply(rpgSheet_Mods *pTarget)
143  {
144  rpgSheet_Fighter_Mods::apply(pTarget);
145  rpgSheet_PlayableChar_Mods *pt = (rpgSheet_PlayableChar_Mods*) pTarget;
146 
147  pt->dMod_XP *= dMod_XP;
148 
149  if(bShrink) pt->bShrink = M_TRUE;
150  if(bLevitate) pt->bLevitate = M_TRUE;
151  if(bGrasshopper) pt->bGrasshopper = M_TRUE;
152  }
153 
154  // Load modifers from TS
155  virtual void load(laPropertyList* pElement)
156  {
157  dMod_XP = pElement->getDouble("mod-XP");
158  bShrink = pElement->getBool("mod-shrink");
159  bLevitate = pElement->getBool("mod-levitate");
160  bGrasshopper = pElement->getBool("mod-grashopper");
161  bDrunk = pElement->getBool("mod-drunk");
162  }
163 };