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
|
/*
* Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com>
*
* 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/>.
*/
// Pokemod includes
#include "Pokemod.h"
// Header include
#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* pokemod, const int id) :
Object("MoveEffect", pokemod, id),
m_chance(1, 1),
m_effect(INT_MAX),
m_value1(INT_MAX),
m_value2(INT_MAX),
m_value3(0),
m_value4(1, 1)
{
}
MoveEffect::MoveEffect(const Pokemod* pokemod, const MoveEffect& effect, const int id) :
Object("MoveEffect", pokemod, id)
{
*this = effect;
}
MoveEffect::MoveEffect(const Pokemod* pokemod, const QString& fileName, const int id) :
Object("MoveEffect", pokemod, id)
{
load(fileName, 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& fileName, int id) throw(Exception)
{
Ini ini(fileName);
if (id == INT_MAX)
ini.getValue("id", id);
setId(id);
int i;
int j;
int k;
ini.getValue("chance-n", i, 1);
ini.getValue("chance-d", j, 1);
m_chance.set(i, j);
ini.getValue("effect", m_effect);
ini.getValue("value1", m_value1);
ini.getValue("value2", m_value2);
ini.getValue("value3", m_value3);
ini.getValue("value4-n", i);
ini.getValue("value4-d", j);
ini.getValue("value4-t", k);
m_value4.set(i, j, k);
}
void MoveEffect::save(const QString& move) const throw(Exception)
{
Ini ini;
ini.addField("id", id());
ini.addField("chance-n", m_chance.numerator());
ini.addField("chance-d", m_chance.denominator());
ini.addField("effect", m_effect);
ini.addField("value1", m_value1);
ini.addField("value2", m_value2);
ini.addField("value3", m_value3);
ini.addField("value4-n", m_value4.numerator());
ini.addField("value4-d", m_value4.denominator());
ini.addField("value4-t", m_value4.type());
ini.save(QString("%1/move/%2/effect/%3.pini").arg(pokemod()->path()).arg(move).arg(id()));
}
void MoveEffect::setChance(const int numerator, const int denominator) throw(Exception)
{
m_chance.set(numerator, denominator);
}
void MoveEffect::setEffect(const int effect) throw(BoundsException)
{
if (E_End <= effect)
throw(BoundsException(className(), "effect"));
m_effect = effect;
m_value1 = INT_MAX;
m_value2 = INT_MAX;
m_value3 = 0;
m_value4.set(1, 1, ((effect == E_StealHP) || (effect == E_Counter) || (effect == E_Selfdestruct) || (effect == E_Mirror) || (effect == E_GetMoney) || (effect == E_WaitAndReturn) || (effect == E_Recoil)) ? Frac::Improper : Frac::Proper);
}
void MoveEffect::setValue1(const int value1) throw(Exception)
{
switch (m_effect)
{
case E_Damage:
if (D_End <= value1)
throw(BoundsException(className(), "value1"));
break;
case E_Status:
case E_NeedStatus:
if (Pokemod::STS_End <= value1)
throw(BoundsException(className(), "value1"));
throw;
case E_Stat:
if (Pokemod::ST_End_Battle <= value1)
throw(BoundsException(className(), "value1"));
break;
case E_Counter:
case E_Shield:
if (MT_End <= value1)
throw(BoundsException(className(), "value1"));
break;
case E_Recoil:
if (R_End <= value1)
throw(BoundsException(className(), "value1"));
break;
default:
throw(BoundsException(className(), "value1"));
break;
}
m_value1 = value1;
}
void MoveEffect::setValue2(const int value2) throw(Exception)
{
switch (m_effect)
{
case E_Damage:
if ((D_Level <= m_value1) || !value2)
throw(BoundsException(className(), "value2"));
break;
default:
throw(BoundsException(className(), "value2"));
break;
}
m_value2 = value2;
}
void MoveEffect::setValue3(const int value3)
{
switch (m_effect)
{
case E_Damage:
//if ()
break;
}
m_value3 = value3;
}
void MoveEffect::setValue4(const int numerator, const int denominator) throw(Exception)
{
m_value4.set(numerator, denominator);
}
Frac MoveEffect::chance() const
{
return m_chance;
}
int MoveEffect::effect() const
{
return m_effect;
}
int MoveEffect::value1() const
{
return m_value1;
}
int MoveEffect::value2() const
{
return m_value2;
}
int MoveEffect::value3() const
{
return m_value3;
}
Frac MoveEffect::value4() const
{
return m_value4;
}
MoveEffect& MoveEffect::operator=(const MoveEffect& rhs)
{
if (this == &rhs)
return *this;
m_chance = rhs.m_chance;
m_effect = rhs.m_effect;
m_value1 = rhs.m_value1;
m_value2 = rhs.m_value2;
m_value3 = rhs.m_value3;
m_value4 = rhs.m_value4;
return *this;
}
|