summaryrefslogtreecommitdiffstats
path: root/pokemod/Badge.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-03-31 01:17:59 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-03-31 01:17:59 +0000
commit9a65bc6bb7c8da1dfa5b101579e52845c75848ef (patch)
tree258900f882a6998ac6fa525bd247e302028a8911 /pokemod/Badge.cpp
parent8e1ec2aec50999bae30625303f2c96e5b3b7f318 (diff)
downloadsigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.gz
sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.tar.xz
sigen-9a65bc6bb7c8da1dfa5b101579e52845c75848ef.zip
[FIX] Member variables now use m_ prefix
[FIX] Lots of minor fixes git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@95 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Badge.cpp')
-rw-r--r--pokemod/Badge.cpp216
1 files changed, 98 insertions, 118 deletions
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp
index 2868f93d..8e679aa2 100644
--- a/pokemod/Badge.cpp
+++ b/pokemod/Badge.cpp
@@ -1,216 +1,196 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokemod/Badge.cpp
-// Purpose: Define a badge which can boost some stats and can allow the
-// use of special techniques in the overworld
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Wed Feb 28 21:27:53 2007
-// Copyright: ©2007-2008 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/>.
-/////////////////////////////////////////////////////////////////////////////
-
+/*
+ * 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/>.
+ */
+
+// Header include
#include "Badge.h"
-Badge::Badge(const Pokemod* par, const int _id) :
- Object("Badge", par, _id),
- name(""),
- obey(0)
+Badge::Badge(const Pokemod* pokemod, const int id) :
+ Object("Badge", pokemod, id),
+ m_name(""),
+ m_obey(0)
{
for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
- stats[i].set(1, 1);
+ m_stats[i].set(1, 1);
for (int i = 0; i < Pokemod::HM_End_All; ++i)
- hm[i] = false;
+ m_hm[i] = false;
}
-Badge::Badge(const Pokemod* par, const Badge& b, const int _id) :
- Object("Badge", par, _id)
+Badge::Badge(const Pokemod* pokemod, const Badge& badge, const int id) :
+ Object("Badge", pokemod, id)
{
- *this = b;
+ *this = badge;
}
-Badge::Badge(const Pokemod* par, const QString& fname, const int _id) :
- Object("Badge", par, _id)
+Badge::Badge(const Pokemod* pokemod, const QString& fileName, const int id) :
+ Object("Badge", pokemod, id)
{
- load(fname, _id);
+ load(fileName, id);
}
bool Badge::validate() const
{
bool valid = true;
- pokemod->validationMsg(QString("---Badge \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg);
- if (name == "")
+ pokemod()->validationMsg(QString("---Badge \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+ if (m_name == "")
{
- pokemod->validationMsg("Name not defined");
+ pokemod()->validationMsg("Name not defined");
valid = false;
}
- if (pokemod->getRules()->getMaxLevel() < obey)
+ if (pokemod()->rules()->maxLevel() < m_obey)
{
- pokemod->validationMsg("Obey level out of range");
+ pokemod()->validationMsg("Obey level out of range");
valid = false;
}
- if (!QFile(getFace()).exists())
+ if (!QFile(face()).exists())
{
- pokemod->validationMsg("Cannot find the face sprite");
+ pokemod()->validationMsg("Cannot find the face sprite");
valid = false;
}
- if (!QFile(getBadge()).exists())
+ if (!QFile(badge()).exists())
{
- pokemod->validationMsg("Cannot find the badge sprite");
+ pokemod()->validationMsg("Cannot find the badge sprite");
valid = false;
}
return valid;
}
-void Badge::load(const QString& fname, const int _id) throw(Exception)
+void Badge::load(const QString& fileName, int id) throw(Exception)
{
- Ini ini(fname);
- if (_id == -1)
+ Ini ini(fileName);
+ if (id == INT_MAX)
ini.getValue("id", id);
- else
- id = _id;
- ini.getValue("name", name);
- ini.getValue("obey", obey, 0);
+ setId(id);
+ ini.getValue("name", m_name);
+ ini.getValue("obey", m_obey, 0);
for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
{
int j;
int k;
ini.getValue(QString("stats-%1-n").arg(i), j, 1);
ini.getValue(QString("stats-%1-d").arg(i), k, 1);
- stats[i].set(j, k);
+ m_stats[i].set(j, k);
}
for (int i = 0; i < Pokemod::HM_End_All; ++i)
- ini.getValue(QString("hm-%1").arg(i), hm[i], false);
+ ini.getValue(QString("hm-%1").arg(i), m_hm[i], false);
}
void Badge::save() const throw(Exception)
{
Ini ini;
- ini.addField("id", id);
- ini.addField("name", name);
- ini.addField("obey", obey);
+ ini.addField("id", id());
+ ini.addField("name", m_name);
+ ini.addField("obey", m_obey);
for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
{
- ini.addField(QString("stats-%1-n").arg(i), stats[i].getNum());
- ini.addField(QString("stats-%1-d").arg(i), stats[i].getDenom());
+ ini.addField(QString("stats-%1-n").arg(i), m_stats[i].numerator());
+ ini.addField(QString("stats-%1-d").arg(i), m_stats[i].denominator());
}
for (int i = 0; i < Pokemod::HM_End_All; ++i)
- ini.addField(QString("hm-%1").arg(i), hm[i]);
- ini.save(QString("%1/badge/%2.pini").arg(pokemod->getPath()).arg(name));
+ ini.addField(QString("hm-%1").arg(i), m_hm[i]);
+ ini.save(QString("%1/badge/%2.pini").arg(pokemod()->path()).arg(m_name));
}
-void Badge::setName(const QString& n)
+void Badge::setName(const QString& name)
{
- name = n;
+ m_name = name;
}
-void Badge::setFace(const QString& f) throw(Exception)
+void Badge::setFace(const QString& fileName) throw(Exception)
{
- QFile file(getFace());
+ QFile file(face());
if (file.exists() && !file.remove())
- throw(ReplaceException(className, file.fileName()));
- if (!QFile::copy(f, getFace()))
- throw(SaveException(className, file.fileName()));
+ throw(ReplaceException(className(), file.fileName()));
+ if (!QFile::copy(fileName, face()))
+ throw(SaveException(className(), file.fileName()));
}
-void Badge::setBadge(const QString& b) throw(Exception)
+void Badge::setBadge(const QString& fileName) throw(Exception)
{
- QFile file(getBadge());
+ QFile file(badge());
if (file.exists() && !file.remove())
- throw(ReplaceException(className, file.fileName()));
- if (!QFile::copy(b, getBadge()))
- throw(SaveException(className, file.fileName()));
-}
-
-void Badge::setObey(const int o) throw(BoundsException)
-{
- if (pokemod->getRules()->getMaxLevel() < o)
- throw(BoundsException(className, "obey"));
- obey = o;
-}
-
-void Badge::setStat(const int s, const int n, const int d) throw(Exception)
-{
- if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s)
- throw(BoundsException(className, "stat"));
- stats[s].set(n, d);
+ throw(ReplaceException(className(), file.fileName()));
+ if (!QFile::copy(fileName, badge()))
+ throw(SaveException(className(), file.fileName()));
}
-void Badge::setStatNum(const int s, const int n) throw(Exception)
+void Badge::setObey(const int obey) throw(BoundsException)
{
- if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s)
- throw(BoundsException(className, "stat"));
- stats[s].setNum(n);
+ if (pokemod()->rules()->maxLevel() < obey)
+ throw(BoundsException(className(), "obey"));
+ m_obey = obey;
}
-void Badge::setStatDenom(const int s, const int d) throw(Exception)
+void Badge::setStat(const int stat, const int numerator, const int denominator) throw(Exception)
{
- if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s)
- throw(BoundsException(className, "stat"));
- stats[s].setDenom(d);
+ if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ throw(BoundsException(className(), "stat"));
+ m_stats[stat].set(numerator, denominator);
}
-void Badge::setHm(const int h, const bool hb) throw(BoundsException)
+void Badge::setHm(const int hm, const bool hmAllowed) throw(BoundsException)
{
- if (Pokemod::HM_End_All <= h)
- throw(BoundsException(className, "hm"));
- hm[h] = hb;
+ if (Pokemod::HM_End_All <= hm)
+ throw(BoundsException(className(), "hm"));
+ m_hm[hm] = hmAllowed;
}
-QString Badge::getName() const
+QString Badge::name() const
{
- return name;
+ return m_name;
}
-QString Badge::getFace() const
+QString Badge::face() const
{
- return QString("%1/badge/%2/face.png").arg(pokemod->getPath()).arg(name);
+ return QString("%1/badge/%2/face.png").arg(pokemod()->path()).arg(m_name);
}
-QString Badge::getBadge() const
+QString Badge::badge() const
{
- return QString("%1/badge/%2/badge.png").arg(pokemod->getPath()).arg(name);
+ return QString("%1/badge/%2/badge.png").arg(pokemod()->path()).arg(m_name);
}
-int Badge::getObey() const
+int Badge::obey() const
{
- return obey;
+ return m_obey;
}
-Frac Badge::getStat(const int s) const throw(BoundsException)
+Frac Badge::stat(const int stat) const throw(BoundsException)
{
- if ((pokemod->getRules()->getSpecialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= s)
- throw(BoundsException(className, "stat"));
- return stats[s];
+ if ((pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
+ throw(BoundsException(className(), "stat"));
+ return m_stats[stat];
}
-bool Badge::getHm(const int h) const throw(BoundsException)
+bool Badge::hm(const int hm) const throw(BoundsException)
{
- if (Pokemod::HM_End_All <= h)
- throw(BoundsException(className, "hm"));
- return hm[h];
+ if (Pokemod::HM_End_All <= hm)
+ throw(BoundsException(className(), "hm"));
+ return m_hm[hm];
}
Badge& Badge::operator=(const Badge& rhs)
{
if (this == &rhs)
return *this;
- name = rhs.name;
- obey = rhs.obey;
+ m_name = rhs.m_name;
+ m_obey = rhs.m_obey;
for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
- stats[i] = rhs.stats[i];
+ m_stats[i] = rhs.m_stats[i];
for (int i = 0; i < Pokemod::HM_End_All; ++i)
- hm[i] = rhs.hm[i];
+ m_hm[i] = rhs.m_hm[i];
return *this;
}