summaryrefslogtreecommitdiffstats
path: root/pokemod/SpeciesAbility.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/SpeciesAbility.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/SpeciesAbility.cpp')
-rw-r--r--pokemod/SpeciesAbility.cpp119
1 files changed, 58 insertions, 61 deletions
diff --git a/pokemod/SpeciesAbility.cpp b/pokemod/SpeciesAbility.cpp
index b4a0cfe5..fe698dea 100644
--- a/pokemod/SpeciesAbility.cpp
+++ b/pokemod/SpeciesAbility.cpp
@@ -1,113 +1,110 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokemod/SpeciesAbility.cpp
-// Purpose: Define an ability that a species can have
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Tue Mar 20 18:39:17 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/>.
+ */
+// Pokemod includes
#include "Pokemod.h"
+
+// Header include
#include "SpeciesAbility.h"
-SpeciesAbility::SpeciesAbility(const Pokemod* par, const int _id) :
- Object("SpeciesAbility", par, _id),
- ability(-1),
- weight(1)
+SpeciesAbility::SpeciesAbility(const Pokemod* pokemod, const int id) :
+ Object("SpeciesAbility", pokemod, id),
+ m_ability(INT_MAX),
+ m_weight(1)
{
}
-SpeciesAbility::SpeciesAbility(const Pokemod* par, const SpeciesAbility& a, const int _id) :
- Object("SpeciesAbility", par, _id)
+SpeciesAbility::SpeciesAbility(const Pokemod* pokemod, const SpeciesAbility& ability, const int id) :
+ Object("SpeciesAbility", pokemod, id)
{
- *this = a;
+ *this = ability;
}
-SpeciesAbility::SpeciesAbility(const Pokemod* par, const QString& fname, const int _id) :
- Object("SpeciesAbility", par, _id)
+SpeciesAbility::SpeciesAbility(const Pokemod* pokemod, const QString& fileName, const int id) :
+ Object("SpeciesAbility", pokemod, id)
{
- load(fname, _id);
+ load(fileName, id);
}
bool SpeciesAbility::validate() const
{
bool valid = true;
- pokemod->validationMsg(QString("------Ability with id %1---").arg(id), Pokemod::V_Msg);
- if (pokemod->getAbilityIndex(ability) == -1)
+ pokemod()->validationMsg(QString("------Ability with id %1---").arg(id()), Pokemod::V_Msg);
+ if (pokemod()->abilityIndex(m_ability) == INT_MAX)
{
- pokemod->validationMsg("Invalid ability");
+ pokemod()->validationMsg("Invalid ability");
valid = false;
}
- if (!weight)
+ if (!m_weight)
{
- pokemod->validationMsg("Invalid weight");
+ pokemod()->validationMsg("Invalid weight");
valid = false;
}
return valid;
}
-void SpeciesAbility::load(const QString& fname, const int _id) throw(Exception)
+void SpeciesAbility::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("ability", ability);
- ini.getValue("weight", weight, 1);
+ setId(id);
+ ini.getValue("ability", m_ability);
+ ini.getValue("weight", m_weight, 1);
}
void SpeciesAbility::save(const QString& species) const throw(Exception)
{
Ini ini;
- ini.addField("id", id);
- ini.addField("ability", ability);
- ini.addField("weight", weight);
- ini.save(QString("%1/species/%2/ability/%3.pini").arg(pokemod->getPath()).arg(species).arg(id));
+ ini.addField("id", id());
+ ini.addField("ability", m_ability);
+ ini.addField("weight", m_weight);
+ ini.save(QString("%1/species/%2/ability/%3.pini").arg(pokemod()->path()).arg(species).arg(id()));
}
-void SpeciesAbility::setAbility(const int a) throw(BoundsException)
+void SpeciesAbility::setAbility(const int ability) throw(BoundsException)
{
- if (pokemod->getAbilityIndex(a) == -1)
- throw(BoundsException(className, "ability"));
- ability = a;
+ if (pokemod()->abilityIndex(ability) == INT_MAX)
+ throw(BoundsException(className(), "ability"));
+ m_ability = ability;
}
-void SpeciesAbility::setWeight(const int w) throw(BoundsException)
+void SpeciesAbility::setWeight(const int weight) throw(BoundsException)
{
- if (!w)
- throw(BoundsException(className, "weight"));
- weight = w;
+ if (!weight)
+ throw(BoundsException(className(), "weight"));
+ m_weight = weight;
}
-int SpeciesAbility::getAbility() const
+int SpeciesAbility::ability() const
{
- return ability;
+ return m_ability;
}
-int SpeciesAbility::getWeight() const
+int SpeciesAbility::weight() const
{
- return weight;
+ return m_weight;
}
SpeciesAbility& SpeciesAbility::operator=(const SpeciesAbility& rhs)
{
if (this == &rhs)
return *this;
- ability = rhs.ability;
- weight = rhs.weight;
+ m_ability = rhs.m_ability;
+ m_weight = rhs.m_weight;
return *this;
}