summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-11-27 05:50:14 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-11-27 05:50:14 +0000
commitb2ec6250bb96e7a96898b35ee7271eb1a7b700ad (patch)
tree615ef5c23019361c48eb937b296101853f358c80 /pokemod/Pokemod.cpp
parent4cc4d62d084bc3002e35f6bd15a73f22157114e4 (diff)
downloadsigen-b2ec6250bb96e7a96898b35ee7271eb1a7b700ad.tar.gz
sigen-b2ec6250bb96e7a96898b35ee7271eb1a7b700ad.tar.xz
sigen-b2ec6250bb96e7a96898b35ee7271eb1a7b700ad.zip
[ADD] Known MoveEffects
[FIX] pokegen.pro error in rpm build target [FIX] EggSpecies not needed (generic species will be used instead) [FIX] StruggleMove not needed (generic will be used instead) [FIX] TypeChart moved back to Pokemod so that Rules are completely Pokemod-neutral git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@29 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
-rw-r--r--pokemod/Pokemod.cpp94
1 files changed, 78 insertions, 16 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index 538acecb..9882d330 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -35,7 +35,7 @@ PokeGen::PokeMod::Pokemod::Pokemod(const QString& fname) :
startDialog(UINT_MAX),
superPCUname(""),
superPCPasswd(""),
- struggleMove(UINT_MAX),
+ typeChart(1, 1, Frac(1, 1, Frac::Improper)),
rules(*this)
{
load(fname);
@@ -119,9 +119,9 @@ bool PokeGen::PokeMod::Pokemod::validate() const
validationMsg("Super PC username not defined", V_Warn);
if (superPCPasswd == "")
validationMsg("Super PC password not defined", V_Warn);
- if (getMoveByID(struggleMove) == UINT_MAX)
+ if ((typeChart.getWidth() != getTypeCount()) || (typeChart.getHeight() != getTypeCount()))
{
- validationMsg("Invalid struggle move");
+ validationMsg("TypeChart is invalid");
valid = false;
}
if (!rules.isValid())
@@ -635,7 +635,17 @@ void PokeGen::PokeMod::Pokemod::load(const QString& fname)
ini.getValue("startDialog", startDialog);
ini.getValue("superPCUname", superPCUname);
ini.getValue("superPCPasswd", superPCPasswd);
- ini.getValue("struggleMove", struggleMove);
+ for (unsigned i = 0; i < pokemod.getTypeCount(); ++i)
+ {
+ for (unsigned j = 0; j < pokemod.getTypeCount(); ++j)
+ {
+ unsigned k;
+ unsigned l;
+ ini.getValue(QString("typeChart-%1-%2-n").arg(i).arg(j), k, 1);
+ ini.getValue(QString("typeChart-%1-%2-d").arg(i).arg(j), l, 1);
+ setTypeChart(i, j, k, l);
+ }
+ }
QDir fdir(path);
if (QFile::exists(QString("%1/rules.pini").arg(path)))
rules.load(QString("%1/rules.pini").arg(path));
@@ -766,7 +776,14 @@ void PokeGen::PokeMod::Pokemod::save() const
ini.addField("startDialog", startDialog);
ini.addField("superPCUname", superPCUname);
ini.addField("superPCPasswd", superPCPasswd);
- ini.addField("struggleMove", struggleMove);
+ for (unsigned i = 1; i < typeChart.getWidth(); ++i)
+ {
+ for (unsigned j = 1; j < typeChart.getHeight(); ++j)
+ {
+ ini.addField(QString("typeChart-%1-%2-n").arg(typeChart(i, 0).getNum()).arg(typeChart(0, j).getNum()), typeChart(i, j).getNum());
+ ini.addField(QString("typeChart-%1-%2-d").arg(typeChart(i, 0).getNum()).arg(typeChart(0, j).getNum()), typeChart(i, j).getDenom());
+ }
+ }
ini.save(QString("%1/data.pini").arg(getPath()));
rules.save();
for (QListIterator<Ability> i(abilities); i.hasNext(); )
@@ -942,11 +959,29 @@ void PokeGen::PokeMod::Pokemod::setSuperPCPasswd(const QString& p)
superPCPasswd = p;
}
-void PokeGen::PokeMod::Pokemod::setStruggleMove(const unsigned s)
+void PokeGen::PokeMod::Pokemod::setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d)
+{
+ typeChart(att, def).set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemod::setTypeChartNum(const unsigned att, const unsigned def, const unsigned n)
+{
+ typeChart(att, def).setNum(n);
+}
+
+void PokeGen::PokeMod::Pokemod::setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d)
+{
+ typeChart(att, def).setDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemod::setRules(const Rules& r)
+{
+ rules = r;
+}
+
+void PokeGen::PokeMod::Pokemod::setRules(const QString& fname)
{
- if (getMoveByID(s) == UINT_MAX)
- throw("Pokemod: struggleMove out-of-bounds");
- struggleMove = s;
+ rules.load(fname);
}
QString PokeGen::PokeMod::Pokemod::getTitle() const
@@ -1009,9 +1044,39 @@ QString PokeGen::PokeMod::Pokemod::getSuperPCPasswd() const
return superPCPasswd;
}
-unsigned PokeGen::PokeMod::Pokemod::getStruggleMove() const
+const PokeGen::FracMatrix& PokeGen::PokeMod::Pokemod::getTypeChart() const
+{
+ return typeChart;
+}
+
+PokeGen::FracMatrix& PokeGen::PokeMod::Pokemod::getTypeChart()
+{
+ return typeChart;
+}
+
+PokeGen::Frac PokeGen::PokeMod::Pokemod::getTypeChart(const unsigned att, const unsigned def) const
+{
+ return typeChart(att, def);
+}
+
+unsigned PokeGen::PokeMod::Pokemod::getTypeChartNum(const unsigned att, const unsigned def) const
+{
+ return getTypeChart(att, def).getNum();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::getTypeChartDenom(const unsigned att, const unsigned def) const
+{
+ return getTypeChart(att, def).getDenom();
+}
+
+const PokeGen::PokeMod::Rules& PokeGen::PokeMod::Pokemod::getRules() const
+{
+ return rules;
+}
+
+PokeGen::PokeMod::Rules& PokeGen::PokeMod::Pokemod::getRules()
{
- return struggleMove;
+ return rules;
}
const PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::getAbility(const unsigned i) const
@@ -1843,7 +1908,6 @@ unsigned PokeGen::PokeMod::Pokemod::getTypeCount() const
PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType()
{
- FracMatrix& typeChart = rules.getTypeChart();
unsigned i;
types.append(Type(*this, i = getNewTypeId()));
typeChart.addCol(Frac(1, 1));
@@ -1853,7 +1917,6 @@ PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType()
PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const QString& fname)
{
- FracMatrix& typeChart = rules.getTypeChart();
unsigned i;
types.append(Type(*this, fname, i = getNewTypeId()));
typeChart.addCol(Frac(1, 1));
@@ -1863,7 +1926,6 @@ PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const QString& fname)
PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const Type& t)
{
- FracMatrix& typeChart = rules.getTypeChart();
unsigned i;
types.append(Type(*this, t, i = getNewTypeId()));
typeChart.addCol(Frac(1, 1));
@@ -1875,6 +1937,6 @@ void PokeGen::PokeMod::Pokemod::deleteType(const unsigned i)
{
if (getTypeCount() <= i)
throw("Pokemod: out-of-bounds");
- rules.getTypeChart().deleteCol(i);
- rules.getTypeChart().deleteRow(i);
+ typeChart.deleteCol(i);
+ typeChart.deleteRow(i);
}