summaryrefslogtreecommitdiffstats
path: root/pokemod/Trainer.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/Trainer.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/Trainer.cpp')
-rw-r--r--pokemod/Trainer.cpp148
1 files changed, 71 insertions, 77 deletions
diff --git a/pokemod/Trainer.cpp b/pokemod/Trainer.cpp
index f82660a1..6981c67d 100644
--- a/pokemod/Trainer.cpp
+++ b/pokemod/Trainer.cpp
@@ -1,149 +1,143 @@
-/////////////////////////////////////////////////////////////////////////////
-// Name: pokemod/Trainer.cpp
-// Purpose: Define a type of trainer
-// Author: Ben Boeckel
-// Modified by: Ben Boeckel
-// Created: Sat Mar 8 16:30:03 2008
-// 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 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/>.
+ */
#include "Pokemod.h"
#include "Trainer.h"
-Trainer::Trainer(const Pokemod* par, const int _id) :
- Object("Trainer", par, _id),
- name(""),
- moneyFactor(0)
+Trainer::Trainer(const Pokemod* pokemod, const int id) :
+ Object("Trainer", pokemod, id),
+ m_name(""),
+ m_moneyFactor(0)
{
}
-Trainer::Trainer(const Pokemod* par, const Trainer& t, const int _id) :
- Object("Trainer", par, _id)
+Trainer::Trainer(const Pokemod* pokemod, const Trainer& trainer, const int id) :
+ Object("Trainer", pokemod, id)
{
- *this = t;
+ *this = trainer;
}
-Trainer::Trainer(const Pokemod* par, const QString& fname, const int _id) :
- Object("Trainer", par, _id)
+Trainer::Trainer(const Pokemod* pokemod, const QString& fileName, const int id) :
+ Object("Trainer", pokemod, id)
{
- load(fname);
+ load(fileName);
}
bool Trainer::validate() const
{
bool valid = true;
- pokemod->validationMsg(QString("---Trainer \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg);
- if (name == "")
+ pokemod()->validationMsg(QString("---Trainer \"%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 (moneyFactor < 0)
+ if (m_moneyFactor < 0)
{
- pokemod->validationMsg("Invalid money factor");
+ pokemod()->validationMsg("Invalid money factor");
valid = false;
}
- if (!QFile(getSkin()).exists())
+ if (!QFile(skin()).exists())
{
- pokemod->validationMsg("Cannot find the skin");
+ pokemod()->validationMsg("Cannot find the skin");
valid = false;
}
- if (!QFile(getAi()).exists())
+ if (!QFile(ai()).exists())
{
- pokemod->validationMsg("Cannot find the AI file");
+ pokemod()->validationMsg("Cannot find the AI file");
valid = false;
}
return valid;
}
-void Trainer::load(const QString& fname, const int _id) throw(Exception)
+void Trainer::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("moneyFactor", moneyFactor);
+ setId(id);
+ ini.getValue("name", m_name);
+ ini.getValue("moneyFactor", m_moneyFactor);
}
void Trainer::save() const throw(Exception)
{
Ini ini;
- ini.addField("id", id);
- ini.addField("name", name);
- ini.addField("moneyFactor", moneyFactor);
- ini.save(QString("%1/trainer/%2/data.pini").arg(pokemod->getPath()).arg(name));
+ ini.addField("id", id());
+ ini.addField("name", m_name);
+ ini.addField("moneyFactor", m_moneyFactor);
+ ini.save(QString("%1/trainer/%2/data.pini").arg(pokemod()->path()).arg(m_name));
}
-void Trainer::setName(const QString& n)
+void Trainer::setName(const QString& name)
{
- name = n;
+ m_name = name;
}
-void Trainer::setMoneyFactor(const int m) throw(BoundsException)
+void Trainer::setMoneyFactor(const int moneyFactor) throw(BoundsException)
{
- if (m < 0)
- throw(BoundsException(className, "moneyFactor"));
- moneyFactor = m;
+ if (moneyFactor < 0)
+ throw(BoundsException(className(), "moneyFactor"));
+ m_moneyFactor = moneyFactor;
}
-void Trainer::setSkin(const QString& s) throw(Exception)
+void Trainer::setSkin(const QString& fileName) throw(Exception)
{
- QFile file(getSkin());
+ QFile file(skin());
if (file.exists() && !file.remove())
- throw(ReplaceException(className, file.fileName()));
- if (!QFile::copy(s, getSkin()))
- throw(SaveException(className, file.fileName()));
+ throw(ReplaceException(className(), file.fileName()));
+ if (!QFile::copy(fileName, skin()))
+ throw(SaveException(className(), file.fileName()));
}
-void Trainer::setAi(const QString& a) throw(Exception)
+void Trainer::setAi(const QString& fileName) throw(Exception)
{
- QFile file(getAi());
+ QFile file(ai());
if (file.exists() && !file.remove())
- throw(ReplaceException(className, file.fileName()));
- if (!QFile::copy(a, getAi()))
- throw(SaveException(className, file.fileName()));
+ throw(ReplaceException(className(), file.fileName()));
+ if (!QFile::copy(fileName, ai()))
+ throw(SaveException(className(), file.fileName()));
}
-QString Trainer::getName() const
+QString Trainer::name() const
{
- return name;
+ return m_name;
}
-int Trainer::getMoneyFactor() const
+int Trainer::moneyFactor() const
{
- return moneyFactor;
+ return m_moneyFactor;
}
-QString Trainer::getSkin() const
+QString Trainer::skin() const
{
- return QString("%1/trainer/%2/skin.png").arg(pokemod->getPath()).arg(name);
+ return QString("%1/trainer/%2/skin.png").arg(pokemod()->path()).arg(m_name);
}
-QString Trainer::getAi() const
+QString Trainer::ai() const
{
- return QString("%1/badge/%2/ai.pai").arg(pokemod->getPath()).arg(name);
+ return QString("%1/trainer/%2/ai.pai").arg(pokemod()->path()).arg(m_name);
}
Trainer& Trainer::operator=(const Trainer& rhs)
{
if (this == &rhs)
return *this;
- name = rhs.name;
- moneyFactor = rhs.moneyFactor;
+ m_name = rhs.m_name;
+ m_moneyFactor = rhs.m_moneyFactor;
return *this;
}