1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
/////////////////////////////////////////////////////////////////////////////
// Name: pokemod/MoveEffect.cpp
// Purpose: Define an effect of a move
// Author: Ben Boeckel
// Modified by: Ben Boeckel
// Created: Tue Mar 20 18:29:40 2007
// Copyright: ©2007 Ben Boeckel and Nerdy Productions
// Licence:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>.
/////////////////////////////////////////////////////////////////////////////
#include "../general/Ref.h"
#include "Pokemod.h"
#include "MoveEffect.h"
const QStringList MoveEffect::EffectStr = QStringList() << "Damage" << "Status" << "Confuse" << "Stat" << "StealHP" << "Counter" << "Selfdestruct" << "Need Status" << "Mirror" << "GetMoney" << "Never Miss" << "Steal Types" << "Clear Effects" << "Wait And Return" << "Self Confuse" << "Force Switch" << "Hit Multiple" << "Hit Multiple Turns" << "Flinch" << "One Hit K.O." << "Recoil" << "Recover" << "Rest" << "Sheild" << "Substitute" << "Recharge" << "Rage" << "Mimic" << "Random Move" << "Seed" << "Disable" << "Cut HM" << "Fly HM" << "Surf HM" << "Strength HM" << "Flash HM" << "Rock Smash HM" << "Rock Climb HM" << "Whirlpool HM" << "Waterfall HM" << "Share HP HM " << "Escape HM";
MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) :
Object(par, _id),
chance(1, 1),
effect(UINT_MAX),
val1(UINT_MAX),
val2(UINT_MAX),
val3(INT_MIN),
val4(1, 1)
{
}
MoveEffect::MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id) :
Object(par, _id)
{
*this = e;
}
MoveEffect::MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id) :
Object(par, _id)
{
load(fname, _id);
}
bool MoveEffect::validate() const
{
bool valid = true;
pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg);
// TODO (Ben#1#): Move Effect validation
return valid;
}
void MoveEffect::load(const QString& fname, const unsigned _id) throw(Exception)
{
Ini ini(fname);
if (_id == UINT_MAX)
ini.getValue("id", id);
else
id = _id;
unsigned i;
unsigned j;
unsigned k;
ini.getValue("chance-n", i, 1);
ini.getValue("chance-d", j, 1);
chance.set(i, j);
ini.getValue("effect", effect);
ini.getValue("val1", val1);
ini.getValue("val2", val2);
ini.getValue("val3", val3);
ini.getValue("val4-n", i);
ini.getValue("val4-d", j);
ini.getValue("val4-t", k);
val4.set(i, j, k);
}
void MoveEffect::save(const QString& move) const throw(Exception)
{
Ini ini;
ini.addField("id", id);
ini.addField("chance-n", chance.getNum());
ini.addField("chance-d", chance.getDenom());
ini.addField("effect", effect);
ini.addField("val1", val1);
ini.addField("val2", val2);
ini.addField("val3", val3);
ini.addField("val4-n", val4.getNum());
ini.addField("val4-d", val4.getDenom());
ini.addField("val4-t", val4.getType());
ini.save(QString("%1/move/%2/effect/%3.pini").arg(pokemod.getPath()).arg(move).arg(id));
}
void MoveEffect::setChance(const unsigned n, const unsigned d) throw(Exception)
{
chance.set(n, d);
}
void MoveEffect::setChanceNum(const unsigned n) throw(Exception)
{
chance.setNum(n);
}
void MoveEffect::setChanceDenom(const unsigned d) throw(Exception)
{
chance.setDenom(d);
}
void MoveEffect::setEffect(const unsigned e) throw(BoundsException)
{
if (E_End <= e)
throw(BoundsException("MoveEffect", "effect"));
effect = e;
val1 = UINT_MAX;
val2 = UINT_MAX;
val3 = INT_MIN;
val4.set(1, 1, ((e == E_StealHP) || (e == E_Counter) || (e == E_Selfdestruct) || (e == E_Mirror) || (e == E_GetMoney) || (e == E_WaitAndReturn) || (e == E_Recoil)) ? Frac::Improper : Frac::Proper);
}
void MoveEffect::setVal1(const unsigned v1) throw(Exception)
{
switch (effect)
{
case E_Damage:
if (D_End <= v1)
throw(BoundsException("MoveEffect", "val1"));
break;
case E_Status:
case E_NeedStatus:
if (STS_End <= v1)
throw(BoundsException("MoveEffect", "val1"));
throw;
case E_Stat:
if (ST_End_Battle <= v1)
throw(BoundsException("MoveEffect", "val1"));
break;
case E_Counter:
case E_Shield:
if (MT_End <= v1)
throw(BoundsException("MoveEffect", "val1"));
break;
case E_Recoil:
if (R_End <= v1)
throw(BoundsException("MoveEffect", "val1"));
break;
default:
throw(BoundsException("MoveEffect", "val1"));
break;
}
val1 = v1;
}
void MoveEffect::setVal2(const unsigned v2) throw(Exception)
{
switch (effect)
{
case E_Damage:
if ((D_Level <= val1) || !v2)
throw(BoundsException("MoveEffect", "val2"));
break;
default:
throw(BoundsException("MoveEffect", "val2"));
break;
}
val2 = v2;
}
void MoveEffect::setVal3(const int v3)
{
switch (effect)
{
case E_Damage:
//if ()
break;
}
val3 = v3;
}
void MoveEffect::setVal4(const unsigned n, const unsigned d) throw(Exception)
{
val4.set(n, d);
}
void MoveEffect::setVal4Num(const unsigned n) throw(Exception)
{
val4.setNum(n);
}
void MoveEffect::setVal4Denom(const unsigned d) throw(Exception)
{
val4.setDenom(d);
}
Frac MoveEffect::getChance() const
{
return chance;
}
unsigned MoveEffect::getEffect() const
{
return effect;
}
unsigned MoveEffect::getVal1() const
{
return val1;
}
unsigned MoveEffect::getVal2() const
{
return val2;
}
int MoveEffect::getVal3() const
{
return val3;
}
Frac MoveEffect::getVal4() const
{
return val4;
}
MoveEffect& MoveEffect::operator=(const MoveEffect& rhs)
{
if (this == &rhs)
return *this;
chance = rhs.chance;
effect = rhs.effect;
val1 = rhs.val1;
val2 = rhs.val2;
val3 = rhs.val3;
val4 = rhs.val4;
return *this;
}
|