summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-11-22 20:18:43 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-11-22 20:18:43 +0000
commit4cc4d62d084bc3002e35f6bd15a73f22157114e4 (patch)
treee492df521e068e0cd726382d0c08a939858196f2 /pokemod/Pokemod.cpp
parent83f4b43f63960ba30e38cf5bb53cd98ae738ef74 (diff)
downloadsigen-4cc4d62d084bc3002e35f6bd15a73f22157114e4.tar.gz
sigen-4cc4d62d084bc3002e35f6bd15a73f22157114e4.tar.xz
sigen-4cc4d62d084bc3002e35f6bd15a73f22157114e4.zip
[FIX] classes more usable
[FIX] Matrix class [ADD] pokemod/Rules.{h, cpp} [FIX] coding style cleaned up git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@28 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
-rw-r--r--pokemod/Pokemod.cpp2758
1 files changed, 1124 insertions, 1634 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index f2cbb059..538acecb 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -22,37 +22,12 @@
#include "Pokemod.h"
-PokeGen::PokeMod::Pokemod::Pokemod(const QString& f) :
- Object(0, this),
+PokeGen::PokeMod::Pokemod::Pokemod(const QString& fname) :
+ Object(*this, 0),
+ valstream(NULL),
title(""),
version(""),
description(""),
- genderAllowed(false),
- breedingAllowed(false),
- eggSpecies(UINT_MAX),
- holdItems(0),
- criticalDomains(false),
- abilityAllowed(false),
- natureAllowed(false),
- numPokemonBoxes(0),
- numPokemonPerBox(1),
- maxParty(1),
- maxFight(1),
- maxMoves(1),
- maxLevel(1),
- maxMoney(0),
- hardCash(false),
- specialSplit(false),
- specialDVSplit(false),
- maxDVValue(16),
- happiness(false),
- happyFaintLoss(0),
- happyLevelGain(0),
- happySteps(0),
- effortValuesAllowed(false),
- maxTotalEV(0),
- maxEVPerStat(0),
- pokerusChance(1, 1),
startMap(UINT_MAX),
startMoney(0),
startCoordinate(0, 0),
@@ -61,581 +36,500 @@ PokeGen::PokeMod::Pokemod::Pokemod(const QString& f) :
superPCUname(""),
superPCPasswd(""),
struggleMove(UINT_MAX),
- confuseMove(UINT_MAX),
- typeChart(1, 1, Frac(1, 1, Frac::Improper))
+ rules(*this)
{
- ImportIni(f);
+ load(fname);
}
-bool PokeGen::PokeMod::Pokemod::Validate()
+bool PokeGen::PokeMod::Pokemod::validate() const
{
- ValidationMsg(QString("Pokemod \"%1\"").arg(title), V_Msg);
+ bool valid = true;
+ validationMsg(QString("Pokemod \"%1\"").arg(title), V_Msg);
if (title == "")
{
- ValidationMsg("Title is not defined");
- isValid = false;
+ validationMsg("Title is not defined");
+ valid = false;
}
if (version == "")
{
- ValidationMsg("Version is not defined");
- isValid = false;
+ validationMsg("Version is not defined");
+ valid = false;
}
if (description == "")
- ValidationMsg("Description is not defined", V_Warn);
- if (genderAllowed && breedingAllowed && !GetSpecies(eggSpecies))
+ validationMsg("Description is not defined", V_Warn);
+ if (getMapByID(startMap))
{
- ValidationMsg("Invalid egg species");
- isValid = false;
- }
- if (!numPokemonBoxes)
- ValidationMsg("Invalid number of Pokémon boxes", V_Warn);
- else if (!numPokemonPerBox)
- {
- ValidationMsg("Invalid number of Pokémon per box");
- isValid = false;
- }
- if (!maxParty)
- {
- ValidationMsg("Invalid number of Pokémon for max party");
- isValid = false;
- }
- if (!maxParty || (maxParty < maxFight))
- {
- ValidationMsg("More Pokémon can fight than are allowed in the party");
- isValid = false;
- }
- if (!maxMoves)
- {
- ValidationMsg("Pokémon cannot learn any moves");
- isValid = false;
- }
- if (!maxMoney)
- ValidationMsg("Player cannot carry any money", V_Warn);
- if ((maxDVValue != 16) && (maxDVValue != 32))
- {
- ValidationMsg("Invalid maximum DV value");
- isValid = false;
- }
- if (effortValuesAllowed)
- {
- if (maxTotalEV < maxEVPerStat)
- {
- ValidationMsg("More EV points are allowed on a stat than allowed overall");
- isValid = false;
- }
- }
- if (.05 < pokerusChance)
- ValidationMsg("Pokérus chance is unusually high", V_Warn);
- if (const Map* m = GetMap(startMap))
- {
- if (m->GetWidth() <= startCoordinate.GetX())
+ if (getMap(getMapByID(startMap)).getWidth() <= startCoordinate.getX())
{
- ValidationMsg("Invalid starting x coordinate");
- isValid = false;
+ validationMsg("Invalid starting x coordinate");
+ valid = false;
}
- if (m->GetHeight() <= startCoordinate.GetY())
+ if (getMap(getMapByID(startMap)).getHeight() <= startCoordinate.getY())
{
- ValidationMsg("Invalid starting y coordinate");
- isValid = false;
+ validationMsg("Invalid starting y coordinate");
+ valid = false;
}
}
else
{
- ValidationMsg("Invalid starting map");
- isValid = false;
+ validationMsg("Invalid starting map");
+ valid = false;
}
if (D_End <= startDirection)
{
- ValidationMsg("Invalid starting direction");
- isValid = false;
+ validationMsg("Invalid starting direction");
+ valid = false;
}
- if (GetDialogByID(startDialog) == UINT_MAX)
+ if (getDialogByID(startDialog) == UINT_MAX)
{
- ValidationMsg("Invalid starting dialog");
- isValid = false;
+ validationMsg("Invalid starting dialog");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/walk.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/walk.png").arg(getPath())))
{
- ValidationMsg("Cannot find walking skin");
- isValid = false;
+ validationMsg("Cannot find walking skin");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/bike.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/bike.png").arg(getPath())))
{
- ValidationMsg("Cannot find biking skin");
- isValid = false;
+ validationMsg("Cannot find biking skin");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/surf.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/surf.png").arg(getPath())))
{
- ValidationMsg("Cannot find surfing skin");
- isValid = false;
+ validationMsg("Cannot find surfing skin");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/fly.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/fly.png").arg(getPath())))
{
- ValidationMsg("Cannot find flying skin");
- isValid = false;
+ validationMsg("Cannot find flying skin");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/fish.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/fish.png").arg(getPath())))
{
- ValidationMsg("Cannot find fishing skin");
- isValid = false;
+ validationMsg("Cannot find fishing skin");
+ valid = false;
}
- if (!QFile(GetPath() + "images/skins/surfFish.png").exists())
+ if (!QFile::exists(QString("%1/image/skin/surfFish.png").arg(getPath())))
{
- ValidationMsg("Cannot find surf fishing skin");
- isValid = false;
+ validationMsg("Cannot find surf fishing skin");
+ valid = false;
}
if (superPCUname == "")
- ValidationMsg("Super PC username not defined", V_Warn);
+ validationMsg("Super PC username not defined", V_Warn);
if (superPCPasswd == "")
- ValidationMsg("Super PC password not defined", V_Warn);
- if (GetMoveByID(struggleMove) == UINT_MAX)
+ validationMsg("Super PC password not defined", V_Warn);
+ if (getMoveByID(struggleMove) == UINT_MAX)
{
- ValidationMsg("Invalid struggle move");
- isValid = false;
+ validationMsg("Invalid struggle move");
+ valid = false;
}
- if (GetMoveByID(confuseMove) == UINT_MAX)
- ValidationMsg("Invalid confusion move", V_Warn);
+ if (!rules.isValid())
+ valid = false;
QMap<unsigned, unsigned> idChecker;
QMap<QString, unsigned> nameChecker;
- if (abilityAllowed)
+ QMap<unsigned, unsigned> timeChecker;
+ if (rules.getAbilityAllowed())
{
- if (GetAbilityCount())
+ if (!getAbilityCount())
{
- for (QList<Ability>::Iterator i = abilities.begin(); i != abilities.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 abilities with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 abilities with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- idChecker.clear();
- nameChecker.clear();
- }
- else
- {
- ValidationMsg("There are no abilities");
- isValid = false;
+ validationMsg("There are no abilities");
+ valid = false;
}
- }
- if (GetAuthorCount())
- {
- for (QList<Author>::Iterator i = authors.begin(); i != authors.end(); ++i)
+ for (QListIterator<Ability> i(abilities); i.hasNext(); i.next())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 authors with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 abilities with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 authors with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 abilities with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
idChecker.clear();
nameChecker.clear();
}
- else
+ if (!getAuthorCount())
{
- ValidationMsg("There are no authors");
- isValid = false;
+ validationMsg("There are no authors");
+ valid = false;
}
- if (GetBadgeCount())
+ for (QListIterator<Author> i(authors); i.hasNext(); i.next())
{
- for (QList<Badge>::Iterator i = badges.begin(); i != badges.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 badges with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 badges with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 authors with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
- ValidationMsg("There are no badges", V_Warn);
- if (GetCoinListCount())
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
- for (QList<CoinList>::Iterator i = coinLists.begin(); i != coinLists.end(); ++i)
+ if (1 < i.value())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ validationMsg(QString("There are %1 authors with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getBadgeCount())
+ validationMsg("There are no badges", V_Warn);
+ for (QListIterator<Badge> i(badges); i.hasNext(); i.next())
+ {
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 coin lists with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 badges with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 coin lists with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 badges with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
- ValidationMsg("There are no coin lists", V_Warn);
- if (GetDialogCount())
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getCoinListCount())
+ validationMsg("There are no coin lists", V_Warn);
+ for (QListIterator<CoinList> i(coinLists); i.hasNext(); i.next())
+ {
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
- for (QList<Dialog>::Iterator i = dialogs.begin(); i != dialogs.end(); ++i)
+ if (1 < i.value())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
+ validationMsg(QString("There are %1 coin lists with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 dialogs with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 coin lists with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
}
- else
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getDialogCount())
{
- ValidationMsg("There are no dialogs");
- isValid = false;
+ validationMsg("There are no dialogs");
+ valid = false;
}
- if (breedingAllowed)
+ for (QListIterator<Dialog> i(dialogs); i.hasNext(); i.next())
{
- if (GetEggGroupCount())
- {
- for (QList<EggGroup>::Iterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 egg groups with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 egg groups with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- idChecker.clear();
- nameChecker.clear();
- }
- else
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- ValidationMsg("There are no egg grous");
- isValid = false;
+ validationMsg(QString("There are %1 dialogs with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- if (GetItemCount())
+ idChecker.clear();
+ if (rules.getBreedingAllowed())
{
- for (QList<Item>::Iterator i = items.begin(); i != items.end(); ++i)
+ if (!getEggGroupCount())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ validationMsg("There are no egg grous");
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QListIterator<EggGroup> i(eggGroups); i.hasNext(); i.next())
+ {
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 items with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 egg groups with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 items with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 egg groups with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
idChecker.clear();
nameChecker.clear();
}
- else
- ValidationMsg("There are no items", V_Warn);
- if (GetItemTypeCount())
+ if (!getItemCount())
+ validationMsg("There are no items", V_Warn);
+ for (QListIterator<Item> i(items); i.hasNext(); i.next())
{
- for (QList<ItemType>::Iterator i = itemTypes.begin(); i != itemTypes.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 item types with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 items with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 item types with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 items with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getItemTypeCount())
{
- ValidationMsg("There are no item types");
- isValid = false;
+ validationMsg("There are no item types", getItemCount() ? V_Error : V_Warn);
+ if (getItemCount())
+ valid = false;
}
- if (GetMapCount())
+ for (QListIterator<ItemType> i(itemTypes); i.hasNext(); i.next())
{
- for (QList<Map>::Iterator i = maps.begin(); i != maps.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 Mmps with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 item types with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 maps with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 item types with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getMapCount())
{
- ValidationMsg("There are no maps");
- isValid = false;
+ validationMsg("There are no maps");
+ valid = false;
}
- if (GetMoveCount())
+ for (QListIterator<Map> i(maps); i.hasNext(); i.next())
{
- for (QList<Move>::Iterator i = moves.begin(); i != moves.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 moves with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 Mmps with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 moves with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 maps with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getMoveCount())
{
- ValidationMsg("There are no moves");
- isValid = false;
+ validationMsg("There are no moves");
+ valid = false;
}
- if (natureAllowed)
+ for (QListIterator<Move> i(moves); i.hasNext(); i.next())
{
- if (GetNatureCount())
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- for (QList<Nature>::Iterator i = natures.begin(); i != natures.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 natures with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 natures with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- idChecker.clear();
- nameChecker.clear();
+ validationMsg(QString("There are %1 moves with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- else
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- ValidationMsg("There are no natures");
- isValid = false;
+ validationMsg(QString("There are %1 moves with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- if (GetSpeciesCount())
+ idChecker.clear();
+ nameChecker.clear();
+ if (rules.getNatureAllowed())
{
- for (QList<Species>::Iterator i = species.begin(); i != species.end(); ++i)
+ if (!getNatureCount())
+ {
+ validationMsg("There are no natures");
+ valid = false;
+ }
+ for (QListIterator<Nature> i(natures); i.hasNext(); i.next())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 Pokémon with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 natures with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 Pokémon with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 natures with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
idChecker.clear();
nameChecker.clear();
}
- else
+ if (!getSpeciesCount())
+ {
+ validationMsg("There are no Pokémon");
+ valid = false;
+ }
+ for (QListIterator<Species> i(species); i.hasNext(); i.next())
{
- ValidationMsg("There are no Pokémon");
- isValid = false;
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
}
- if (GetStoreCount())
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
- for (QList<Store>::Iterator i = stores.begin(); i != stores.end(); ++i)
+ if (1 < i.value())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ validationMsg(QString("There are %1 Pokémon with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 stores with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 Pokémon with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getStoreCount())
+ validationMsg("There are no stores", V_Warn);
+ for (QListIterator<Store> i(stores); i.hasNext(); i.next())
+ {
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 stores with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 stores with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
- ValidationMsg("There are no stores", V_Warn);
- if (GetTileCount())
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
+ {
+ validationMsg(QString("There are %1 stores with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
+ }
+ }
+ idChecker.clear();
+ nameChecker.clear();
+ if (getTileCount())
{
- for (QList<Tile>::Iterator i = tiles.begin(); i != tiles.end(); ++i)
+ for (QListIterator<Tile> i(tiles); i.hasNext(); i.next())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 tiles with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 tiles with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
if (1 < i.value())
{
- ValidationMsg(QString("There are %1 tiles with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
+ validationMsg(QString("There are %1 tiles with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
}
idChecker.clear();
@@ -643,1748 +537,1344 @@ bool PokeGen::PokeMod::Pokemod::Validate()
}
else
{
- ValidationMsg("There are no tiles");
- isValid = false;
+ validationMsg("There are no tiles");
+ valid = false;
}
- if (GetTimeCount())
+ if (!getTimeCount())
{
- QMap<unsigned, unsigned> timeChecker;
- for (QList<Time>::Iterator i = times.begin(); i != times.end(); ++i)
+ validationMsg("There are no times");
+ valid = false;
+ }
+ for (QListIterator<Time> i(times); i.hasNext(); i.next())
+ {
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ ++timeChecker[(60 * i.peekNext().getStartHour()) + i.peekNext().getStartMinute()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++timeChecker[60 * i->GetStartHour() + i->GetStartMinute()];
+ validationMsg(QString("There are %1 times with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ }
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 times with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 times with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
}
- for (QMap<unsigned, unsigned>::ConstIterator i = timeChecker.begin(); i != timeChecker.end(); ++i)
+ }
+ for (QMapIterator<unsigned, unsigned> i(timeChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 times that start at %2:%3").arg(i.value()).arg(i.key() / 60).arg(i.key() % 60));
- isValid = false;
- }
+ validationMsg(QString("There are %1 times that start at %2:%3").arg(i.value()).arg(i.key() / 60).arg(i.key() % 60));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
+ idChecker.clear();
+ nameChecker.clear();
+ if (!getTypeCount())
{
- ValidationMsg("There are no times");
- isValid = false;
+ validationMsg("There are no types");
+ valid = false;
}
- if (GetTypeCount())
+ for (QListIterator<Type> i(types); i.hasNext(); i.next())
{
- for (QList<Type>::Iterator i = types.begin(); i != types.end(); ++i)
- {
- if (!i->IsValid())
- isValid = false;
- ++idChecker[i->GetId()];
- ++nameChecker[i->GetName()];
- }
- for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i)
- {
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 types with id %2").arg(i.value()).arg(i.key()));
- isValid = false;
- }
- }
- for (QMap<QString, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i)
+ if (!i.peekNext().isValid())
+ valid = false;
+ ++idChecker[i.peekNext().getId()];
+ ++nameChecker[i.peekNext().getName()];
+ }
+ for (QMapIterator<unsigned, unsigned> i(idChecker); i.hasNext(); i.next())
+ {
+ if (1 < i.value())
{
- if (1 < i.value())
- {
- ValidationMsg(QString("There are %1 types with the name \"%2\"").arg(i.value()).arg(i.key()));
- isValid = false;
- }
+ validationMsg(QString("There are %1 types with id %2").arg(i.value()).arg(i.key()));
+ valid = false;
}
- idChecker.clear();
- nameChecker.clear();
}
- else
+ for (QMapIterator<QString, unsigned> i(nameChecker); i.hasNext(); i.next())
{
- ValidationMsg("There are no types");
- isValid = false;
+ if (1 < i.value())
+ {
+ validationMsg(QString("There are %1 types with the name \"%2\"").arg(i.value()).arg(i.key()));
+ valid = false;
+ }
}
- return isValid;
+ return valid;
}
-QString PokeGen::PokeMod::Pokemod::GetPath() const
+QString PokeGen::PokeMod::Pokemod::getPath() const
{
- QString f = file;
- return f.mid(0, f.lastIndexOf(PM_DEF_SEP) + 1);
+ return path;
}
-void PokeGen::PokeMod::Pokemod::ImportIni(const QString& f)
+void PokeGen::PokeMod::Pokemod::load(const QString& fname)
{
- QList<Ini> sections;
- Ini meta("unset");
- QFile fin(f);
- fin.open(QIODevice::ReadOnly);
- file = f;
- while (!fin.atEnd() && (fin.peek(1).at(0) != '\n'))
+ Ini ini(fname);
+ QStringList fpath = fname.split('\\', QString::SkipEmptyParts).join("/").split('\\', QString::SkipEmptyParts);
+ fpath.removeLast();
+ path = fpath.join("/");
+ unsigned i;
+ unsigned j;
+ ini.getValue("title", title);
+ ini.getValue("version", version);
+ ini.getValue("description", description);
+ ini.getValue("startMap", startMap);
+ ini.getValue("startMoney", startMoney, 0);
+ ini.getValue("startCoordinate-x", i, 0);
+ ini.getValue("startCoordinate-y", j, 0);
+ startCoordinate.set(i, j);
+ ini.getValue("startDirection", startDirection);
+ ini.getValue("startDialog", startDialog);
+ ini.getValue("superPCUname", superPCUname);
+ ini.getValue("superPCPasswd", superPCPasswd);
+ ini.getValue("struggleMove", struggleMove);
+ QDir fdir(path);
+ if (QFile::exists(QString("%1/rules.pini").arg(path)))
+ rules.load(QString("%1/rules.pini").arg(path));
+ abilities.clear();
+ if (fdir.cd("ability"))
{
- Ini curSection(fin);
- if (curSection.GetName() == "pokemod")
- {
- if (meta.GetName() == "unset")
- {
- id = UINT_MAX;
- return;
- }
- meta = curSection;
- unsigned i;
- unsigned j;
- curSection.GetValue("title", title);
- curSection.GetValue("version", version);
- curSection.GetValue("description", description);
- curSection.GetValue("genderAllowed", genderAllowed, false);
- curSection.GetValue("breedingAllowed", breedingAllowed, false);
- curSection.GetValue("eggSpecies", eggSpecies);
- curSection.GetValue("holdItems", holdItems, 0);
- curSection.GetValue("criticalDomains", criticalDomains, false);
- curSection.GetValue("abilityAllowed", abilityAllowed, false);
- curSection.GetValue("natureAllowed", natureAllowed, false);
- curSection.GetValue("numPokemonBoxes", numPokemonBoxes, 0);
- curSection.GetValue("numPokemonPerBox", numPokemonPerBox, 1);
- curSection.GetValue("maxParty", maxParty, 1);
- curSection.GetValue("maxFight", maxFight, 1);
- curSection.GetValue("maxMoves", maxMoves, 1);
- curSection.GetValue("maxLevel", maxLevel, 0);
- curSection.GetValue("maxMoney", maxMoney, 0);
- curSection.GetValue("hardCash", hardCash, false);
- curSection.GetValue("specialSplit", specialSplit, false);
- curSection.GetValue("specialDVSplit", specialDVSplit, false);
- curSection.GetValue("maxDVValue", maxDVValue, 16);
- curSection.GetValue("happiness", happiness, false);
- curSection.GetValue("happyFaintLoss", happyFaintLoss, 0);
- curSection.GetValue("happyLevelGain", happyLevelGain, 0);
- curSection.GetValue("happySteps", happySteps, 0);
- curSection.GetValue("effortValuesAllowed", effortValuesAllowed, false);
- curSection.GetValue("maxTotalEV", maxTotalEV, 0);
- curSection.GetValue("maxEVPerStat", maxEVPerStat, 0);
- curSection.GetValue("pokerusChance-n", i, 1);
- curSection.GetValue("pokerusChance-d", j, 1);
- pokerusChance.Set(i, j);
- curSection.GetValue("startMap", startMap);
- curSection.GetValue("startMoney", startMoney, 0);
- curSection.GetValue("startCoordinate-x", i, 0);
- curSection.GetValue("startCoordinate-y", j, 0);
- startCoordinate.Set(i, j);
- curSection.GetValue("startDirection", startDirection);
- curSection.GetValue("startDialog", startDialog);
- curSection.GetValue("superPCUname", superPCUname);
- curSection.GetValue("superPCPasswd", superPCPasswd);
- curSection.GetValue("struggleMove", struggleMove);
- curSection.GetValue("confuseMove", confuseMove);
- }
- else if (curSection.GetName() == "ability")
- NewAbility(&curSection);
- else if (curSection.GetName() == "author")
- NewAuthor(&curSection);
- else if (curSection.GetName() == "badge")
- NewBadge(&curSection);
- else if (curSection.GetName() == "coinList")
- NewCoinList(&curSection);
- else if (curSection.GetName() == "dialog")
- NewDialog(&curSection);
- else if (curSection.GetName() == "eggGroup")
- NewEggGroup(&curSection);
- else if (curSection.GetName() == "item")
- NewItem(&curSection);
- else if (curSection.GetName() == "itemType")
- NewItemType(&curSection);
- else if (curSection.GetName() == "map")
- NewMap(&curSection);
- else if (curSection.GetName() == "move")
- NewMove(&curSection);
- else if (curSection.GetName() == "nature")
- NewNature(&curSection);
- else if (curSection.GetName() == "species")
- NewSpecies(&curSection);
- else if (curSection.GetName() == "store")
- NewStore(&curSection);
- else if (curSection.GetName() == "tile")
- NewTile(&curSection);
- else if (curSection.GetName() == "time")
- NewTime(&curSection);
- else if (curSection.GetName() == "type")
- NewType(&curSection);
- else
- sections.append(curSection);
- }
- if (meta.GetName() == "unset")
- {
- id = UINT_MAX;
- return;
- }
- for (QList<Type>::Iterator i = types.begin(); i != types.end(); ++i)
- {
- for (QList<Type>::Iterator j = types.begin(); j != types.end(); ++j)
- {
- unsigned k;
- unsigned l;
- meta.GetValue(QString("typeChart-%1-%2-n").arg(i->GetId()).arg(j->GetId()), k, 1);
- meta.GetValue(QString("typeChart-%1-%2-d").arg(i->GetId()).arg(j->GetId()), l, 1);
- SetTypeChart(i->GetId(), j->GetId(), k, l);
- }
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newAbility(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
}
- for (QList<Ini>::Iterator i = sections.begin(); i != sections.end(); ++i)
+ authors.clear();
+ if (fdir.cd("author"))
{
- QStringList s = i->GetName().split(" ", QString::SkipEmptyParts);
- if (s[0] == "abilityEffect")
- {
- for (unsigned j = 0; j < GetAbilityCount(); ++j)
- {
- if (abilities[j].GetName() == s[1])
- abilities[j].NewEffect(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "coinListObject")
- {
- for (unsigned j = 0; j < GetCoinListCount(); ++j)
- {
- if (coinLists[j].GetName() == s[1])
- coinLists[j].NewItem(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "itemEffect")
- {
- for (unsigned j = 0; j < GetItemCount(); ++j)
- {
- if (items[j].GetName() == s[1])
- items[j].NewEffect(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "mapEffect")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[1])
- maps[j].NewEffect(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "mapTrainer")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[1])
- maps[j].NewTrainer(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "mapWarp")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[1])
- maps[j].NewWarp(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "mapWildList")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[1])
- maps[j].NewWildList(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "moveEffect")
- {
- for (unsigned j = 0; j < GetMoveCount(); ++j)
- {
- if (moves[j].GetName() == s[1])
- moves[j].NewEffect(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "speciesAbility")
- {
- for (unsigned j = 0; j < GetSpeciesCount(); ++j)
- {
- if (species[j].GetName() == s[1])
- species[j].NewAbility(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "speciesEvolution")
- {
- for (unsigned j = 0; j < GetSpeciesCount(); ++j)
- {
- if (species[j].GetName() == s[1])
- species[j].NewEvolution(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "speciesItem")
- {
- for (unsigned j = 0; j < GetSpeciesCount(); ++j)
- {
- if (species[j].GetName() == s[1])
- species[j].NewItem(&*i);
- }
- sections.erase(i);
- }
- else if (s[0] == "speciesMove")
- {
- for (unsigned j = 0; j < GetSpeciesCount(); ++j)
- {
- if (species[j].GetName() == s[1])
- species[j].NewMove(&*i);
- }
- sections.erase(i);
- }
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newAuthor(i.next());
+ fdir.cdUp();
}
- unsigned u;
- bool ok;
- for (QList<Ini>::Iterator i = sections.begin(); i != sections.end(); ++i)
+ badges.clear();
+ if (fdir.cd("badge"))
{
- QStringList s = i->GetName().split(" ", QString::SkipEmptyParts);
- u = s[1].toUInt(&ok);
- if (ok)
- {
- if (s[0] == "mapTrainerSpecies")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[2])
- {
- if (MapTrainer* t = (MapTrainer* )maps[j].GetTrainer(maps[j].GetTrainerByID(u)))
- t->NewPokemon(&*i);
- }
- }
- sections.erase(i);
- }
- else if (s[0] == "mapWildListPokemon")
- {
- for (unsigned j = 0; j < GetMapCount(); ++j)
- {
- if (maps[j].GetName() == s[2])
- {
- if (MapWildList* w = (MapWildList* )maps[j].GetWildList(maps[j].GetWildListByID(u)))
- w->NewPokemon(&*i);
- }
- }
- sections.erase(i);
- }
- }
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newBadge(i.next());
+ fdir.cdUp();
}
-}
-
-void PokeGen::PokeMod::Pokemod::ExportIni(const QString& f)
-{
- Ini exPokemod("pokemod");
- QFile fout(f);
- fout.open(QIODevice::WriteOnly);
- file = f;
- exPokemod.AddField("title", title);
- exPokemod.AddField("version", version);
- exPokemod.AddField("description", description);
- exPokemod.AddField("genderAllowed", genderAllowed);
- exPokemod.AddField("breedingAllowed", breedingAllowed);
- exPokemod.AddField("eggSpecies", eggSpecies);
- exPokemod.AddField("holdItems", holdItems);
- exPokemod.AddField("criticalDomains", criticalDomains);
- exPokemod.AddField("abilityAllowed", abilityAllowed);
- exPokemod.AddField("natureAllowed", natureAllowed);
- exPokemod.AddField("numPokemonBoxes", numPokemonBoxes);
- exPokemod.AddField("numPokemonPerBox", numPokemonPerBox);
- exPokemod.AddField("maxParty", maxParty);
- exPokemod.AddField("maxFight", maxFight);
- exPokemod.AddField("maxMoves", maxMoves);
- exPokemod.AddField("maxLevel", maxLevel);
- exPokemod.AddField("maxMoney", maxMoney);
- exPokemod.AddField("hardCash", hardCash);
- exPokemod.AddField("specialSplit", specialSplit);
- exPokemod.AddField("specialDVSplit", specialDVSplit);
- exPokemod.AddField("maxDVValue", maxDVValue);
- exPokemod.AddField("happiness", happiness);
- exPokemod.AddField("happyFaintLoss", happyFaintLoss);
- exPokemod.AddField("happyLevelGain", happyLevelGain);
- exPokemod.AddField("happySteps", happySteps);
- exPokemod.AddField("effortValuesAllowed", effortValuesAllowed);
- exPokemod.AddField("maxTotalEV", maxTotalEV);
- exPokemod.AddField("maxEVPerStat", maxEVPerStat);
- exPokemod.AddField("pokerusChance-n", pokerusChance.GetNum());
- exPokemod.AddField("pokerusChance-d", pokerusChance.GetDenom());
- exPokemod.AddField("startMap", startMap);
- exPokemod.AddField("startMoney", startMoney);
- exPokemod.AddField("startCoordinate-x", startCoordinate.GetX());
- exPokemod.AddField("startCoordinate-y", startCoordinate.GetY());
- exPokemod.AddField("startDirection", startDirection);
- exPokemod.AddField("startDialog", startDialog);
- exPokemod.AddField("superPCUname", superPCUname);
- exPokemod.AddField("superPCPasswd", superPCPasswd);
- exPokemod.AddField("struggleMove", struggleMove);
- exPokemod.AddField("confuseMove", confuseMove);
- for (unsigned i = 1; i < typeChart.GetWidth(); ++i)
- {
- for (unsigned j = 1; j < typeChart.GetHeight(); ++j)
- {
- exPokemod.AddField(QString("typeChart-%1-%2-n").arg(typeChart(i, 0).GetNum()).arg(typeChart(0, j).GetNum()), typeChart(i, j).GetNum());
- exPokemod.AddField(QString("typeChart-%1-%2-d").arg(typeChart(i, 0).GetNum()).arg(typeChart(0, j).GetNum()), typeChart(i, j).GetDenom());
- }
+ coinLists.clear();
+ if (fdir.cd("coinlist"))
+ {
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newCoinList(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
+ }
+ dialogs.clear();
+ if (fdir.cd("dialog"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newDialog(i.next());
+ fdir.cdUp();
+ }
+ eggGroups.clear();
+ if (fdir.cd("egggroup"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newEggGroup(i.next());
+ fdir.cdUp();
}
- exPokemod.Export(fout);
- for (QList<Ability>::ConstIterator i = abilities.begin(); i != abilities.end(); ++i)
- i->ExportIni(fout);
- for (QList<Author>::ConstIterator i = authors.begin(); i != authors.end(); ++i)
- i->ExportIni(fout);
- for (QList<Badge>::ConstIterator i = badges.begin(); i != badges.end(); ++i)
- i->ExportIni(fout);
- for (QList<CoinList>::ConstIterator i = coinLists.begin(); i != coinLists.end(); ++i)
- i->ExportIni(fout);
- for (QList<Dialog>::ConstIterator i = dialogs.begin(); i != dialogs.end(); ++i)
- i->ExportIni(fout);
- for (QList<EggGroup>::ConstIterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
- i->ExportIni(fout);
- for (QList<Item>::ConstIterator i = items.begin(); i != items.end(); ++i)
- i->ExportIni(fout);
- for (QList<ItemType>::ConstIterator i = itemTypes.begin(); i != itemTypes.end(); ++i)
- i->ExportIni(fout);
- for (QList<Map>::ConstIterator i = maps.begin(); i != maps.end(); ++i)
- i->ExportIni(fout);
- for (QList<Move>::ConstIterator i = moves.begin(); i != moves.end(); ++i)
- i->ExportIni(fout);
- for (QList<Nature>::ConstIterator i = natures.begin(); i != natures.end(); ++i)
- i->ExportIni(fout);
- for (QList<Species>::ConstIterator i = species.begin(); i != species.end(); ++i)
- i->ExportIni(fout);
- for (QList<Store>::ConstIterator i = stores.begin(); i != stores.end(); ++i)
- i->ExportIni(fout);
- for (QList<Tile>::ConstIterator i = tiles.begin(); i != tiles.end(); ++i)
- i->ExportIni(fout);
- for (QList<Time>::ConstIterator i = times.begin(); i != times.end(); ++i)
- i->ExportIni(fout);
- for (QList<Type>::ConstIterator i = types.begin(); i != types.end(); ++i)
- i->ExportIni(fout);
-}
-
-unsigned PokeGen::PokeMod::Pokemod::MaxCompatability(const Pokemod& p) const
+ items.clear();
+ if (fdir.cd("item"))
+ {
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newItem(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
+ }
+ itemTypes.clear();
+ if (fdir.cd("itemtype"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newItemType(i.next());
+ fdir.cdUp();
+ }
+ maps.clear();
+ if (fdir.cd("map"))
+ {
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newMap(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
+ }
+ moves.clear();
+ if (fdir.cd("move"))
+ {
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newMove(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
+ }
+ natures.clear();
+ if (fdir.cd("nature"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newNature(i.next());
+ fdir.cdUp();
+ }
+ species.clear();
+ if (fdir.cd("species"))
+ {
+ for (QStringListIterator i(fdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); i.hasNext(); )
+ newSpecies(QString("%1/data.pini").arg(i.next()));
+ fdir.cdUp();
+ }
+ stores.clear();
+ if (fdir.cd("store"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newStore(i.next());
+ fdir.cdUp();
+ }
+ tiles.clear();
+ if (fdir.cd("tile"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newTile(i.next());
+ fdir.cdUp();
+ }
+ times.clear();
+ if (fdir.cd("time"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newTime(i.next());
+ fdir.cdUp();
+ }
+ types.clear();
+ if (fdir.cd("type"))
+ {
+ for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
+ newType(i.next());
+ }
+}
+
+void PokeGen::PokeMod::Pokemod::save() const
+{
+ Ini ini;
+ ini.addField("title", title);
+ ini.addField("version", version);
+ ini.addField("description", description);
+ ini.addField("startMap", startMap);
+ ini.addField("startMoney", startMoney);
+ ini.addField("startCoordinate-x", startCoordinate.getX());
+ ini.addField("startCoordinate-y", startCoordinate.getY());
+ ini.addField("startDirection", startDirection);
+ ini.addField("startDialog", startDialog);
+ ini.addField("superPCUname", superPCUname);
+ ini.addField("superPCPasswd", superPCPasswd);
+ ini.addField("struggleMove", struggleMove);
+ ini.save(QString("%1/data.pini").arg(getPath()));
+ rules.save();
+ for (QListIterator<Ability> i(abilities); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Author> i(authors); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Badge> i(badges); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<CoinList> i(coinLists); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Dialog> i(dialogs); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<EggGroup> i(eggGroups); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Item> i(items); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<ItemType> i(itemTypes); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Map> i(maps); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Move> i(moves); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Nature> i(natures); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Species> i(species); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Store> i(stores); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Tile> i(tiles); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Time> i(times); i.hasNext(); )
+ i.next().save();
+ for (QListIterator<Type> i(types); i.hasNext(); )
+ i.next().save();
+}
+
+unsigned PokeGen::PokeMod::Pokemod::maxCompatability(const Pokemod& p) const
{
// TODO (Ben #1#): MaxCompatability between two versions
}
-void PokeGen::PokeMod::Pokemod::SetTitle(const QString& t)
+void PokeGen::PokeMod::Pokemod::setTitle(const QString& t)
{
title = t;
}
-void PokeGen::PokeMod::Pokemod::SetVersion(const QString& v)
+void PokeGen::PokeMod::Pokemod::setVersion(const QString& v)
{
version = v;
}
-void PokeGen::PokeMod::Pokemod::SetDescription(const QString& d)
+void PokeGen::PokeMod::Pokemod::setDescription(const QString& d)
{
description = d;
}
-void PokeGen::PokeMod::Pokemod::SetIsGenderAllowed(const bool g)
-{
- genderAllowed = g;
- if (!genderAllowed)
- breedingAllowed = false;
-}
-
-bool PokeGen::PokeMod::Pokemod::SetIsBreedingAllowed(const bool b)
+void PokeGen::PokeMod::Pokemod::setStartMap(const unsigned s)
{
- if (genderAllowed)
- breedingAllowed = b;
- return (breedingAllowed == b);
+ if (getMapByID(s) == UINT_MAX)
+ throw("Pokemod: map out-of-bounds");
+ startMap = s;
}
-bool PokeGen::PokeMod::Pokemod::SetEggSpecies(const unsigned e)
+void PokeGen::PokeMod::Pokemod::setStartMoney(const unsigned s)
{
- if (breedingAllowed && (GetSpeciesByID(e) != UINT_MAX))
- eggSpecies = e;
- return (eggSpecies == e);
+ startMoney = s;
}
-void PokeGen::PokeMod::Pokemod::SetHoldItems(const unsigned h)
+void PokeGen::PokeMod::Pokemod::setStartCoordinate(const unsigned x, const unsigned y)
{
- holdItems = h;
+ if (getMapByID(startMap) == UINT_MAX)
+ throw("Pokemod: startMap out-of-bounds");
+ if (getMap(getMapByID(startMap)).getWidth() <= x)
+ throw("Pokemod: x coordinate out-of-bounds");
+ if (getMap(getMapByID(startMap)).getHeight() <= y)
+ throw("Pokemod: y coordinate out-of-bounds");
+ startCoordinate.set(x, y);
}
-void PokeGen::PokeMod::Pokemod::SetHasCriticalDomains(const bool c)
+void PokeGen::PokeMod::Pokemod::setStartCoordinateX(const unsigned x)
{
- criticalDomains = c;
+ if (getMapByID(startMap) == UINT_MAX)
+ throw("Pokemod: startMap out-of-bounds");
+ if (getMap(getMapByID(startMap)).getWidth() <= x)
+ throw("Pokemod: x coordinate out-of-bounds");
+ startCoordinate.setX(x);
}
-void PokeGen::PokeMod::Pokemod::SetIsAbilityAllowed(const bool a)
+void PokeGen::PokeMod::Pokemod::setStartCoordinateY(const unsigned y)
{
- abilityAllowed = a;
+ if (getMapByID(startMap) == UINT_MAX)
+ throw("Pokemod: startMap out-of-bounds");
+ if (getMap(getMapByID(startMap)).getHeight() <= y)
+ throw("Pokemod: y coordinate out-of-bounds");
+ startCoordinate.setY(y);
}
-void PokeGen::PokeMod::Pokemod::SetIsNatureAllowed(const bool n)
+void PokeGen::PokeMod::Pokemod::setStartDirection(const unsigned s)
{
- natureAllowed = n;
+ if (D_End <= s)
+ throw("Pokemod: startDirection out-of-bounds");
+ startDirection = s;
}
-void PokeGen::PokeMod::Pokemod::SetNumPokemonBoxes(const unsigned n)
+void PokeGen::PokeMod::Pokemod::setStartDialog(const unsigned s)
{
- numPokemonBoxes = n;
+ if (getDialogByID(s) == UINT_MAX)
+ throw("Pokemod: startDialog");
+ startDialog = s;
}
-void PokeGen::PokeMod::Pokemod::SetNumPokemonPerBox(const unsigned n)
+void PokeGen::PokeMod::Pokemod::setWalkSkin(const QString& fname)
{
- numPokemonPerBox = n;
+ QFile file(QString("%1/image/skin/walk.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/walk.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-bool PokeGen::PokeMod::Pokemod::SetMaxParty(const unsigned m)
+void PokeGen::PokeMod::Pokemod::setBikeSkin(const QString& fname)
{
- if (m)
- maxParty = m;
- return (maxParty == m);
+ QFile file(QString("%1/image/skin/bike.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/bike.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-bool PokeGen::PokeMod::Pokemod::SetMaxFight(const unsigned m)
+void PokeGen::PokeMod::Pokemod::setSurfSkin(const QString& fname)
{
- if (m <= maxParty)
- maxFight = m;
- return (maxFight == m);
+ QFile file(QString("%1/image/skin/surf.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/surf.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-bool PokeGen::PokeMod::Pokemod::SetMaxMoves(const unsigned m)
+void PokeGen::PokeMod::Pokemod::setFlySkin(const QString& fname)
{
- if (m)
- maxMoves = m;
- return (maxMoves == m);
+ QFile file(QString("%1/image/skin/fly.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/fly.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-bool PokeGen::PokeMod::Pokemod::SetMaxLevel(const unsigned m)
+void PokeGen::PokeMod::Pokemod::setFishSkin(const QString& fname)
{
- if (m)
- maxLevel = m;
- return (maxLevel == m);
+ QFile file(QString("%1/image/skin/fish.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/fish.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-void PokeGen::PokeMod::Pokemod::SetMaxMoney(const unsigned m)
+void PokeGen::PokeMod::Pokemod::setSurfFishSkin(const QString& fname)
{
- maxMoney = m;
+ QFile file(QString("%1/image/skin/surfFish.png").arg(getPath()));
+ if (file.exists() && !file.remove())
+ throw("Pokemod: unable to remove file");
+ if (!QFile::copy(fname, QString("%1/image/skin/surfFish.png").arg(getPath())))
+ throw("Pokemod: unable to copy file");
}
-void PokeGen::PokeMod::Pokemod::SetIsHardCash(const bool h)
+void PokeGen::PokeMod::Pokemod::setSuperPCUname(const QString& u)
{
- hardCash = h;
+ superPCUname = u;
}
-void PokeGen::PokeMod::Pokemod::SetIsSpecialSplit(const bool s)
+void PokeGen::PokeMod::Pokemod::setSuperPCPasswd(const QString& p)
{
- specialSplit = s;
+ superPCPasswd = p;
}
-void PokeGen::PokeMod::Pokemod::SetIsSpecialDVSplit(const bool s)
+void PokeGen::PokeMod::Pokemod::setStruggleMove(const unsigned s)
{
- specialDVSplit = s;
+ if (getMoveByID(s) == UINT_MAX)
+ throw("Pokemod: struggleMove out-of-bounds");
+ struggleMove = s;
}
-bool PokeGen::PokeMod::Pokemod::SetMaxDVValue(const unsigned char m)
+QString PokeGen::PokeMod::Pokemod::getTitle() const
{
- if ((m == 16) || (m == 32))
- maxDVValue = m;
- return (maxDVValue == m);
+ return title;
}
-void PokeGen::PokeMod::Pokemod::SetIsHappiness(const bool h)
+QString PokeGen::PokeMod::Pokemod::getVersion() const
{
- happiness = h;
+ return version;
}
-void PokeGen::PokeMod::Pokemod::SetHappyFaintLoss(const unsigned h)
+QString PokeGen::PokeMod::Pokemod::getDescription() const
{
- happyFaintLoss = h;
+ return description;
}
-void PokeGen::PokeMod::Pokemod::SetHappyLevelGain(const unsigned h)
+unsigned PokeGen::PokeMod::Pokemod::getStartMap() const
{
- happyLevelGain = h;
+ return startMap;
}
-void PokeGen::PokeMod::Pokemod::SetHappySteps(const unsigned h)
+unsigned PokeGen::PokeMod::Pokemod::getStartMoney() const
{
- happySteps = h;
+ return startMoney;
}
-void PokeGen::PokeMod::Pokemod::SetIsEffortValuesAllowed(const bool e)
+PokeGen::Point PokeGen::PokeMod::Pokemod::getStartCoordinate() const
{
- effortValuesAllowed = e;
+ return startCoordinate;
}
-void PokeGen::PokeMod::Pokemod::SetMaxTotalEV(const unsigned m)
+unsigned PokeGen::PokeMod::Pokemod::getStartCoordinateX() const
{
- maxTotalEV = m;
+ return startCoordinate.getX();
}
-bool PokeGen::PokeMod::Pokemod::SetMaxEVPerStat(const unsigned m)
+unsigned PokeGen::PokeMod::Pokemod::getStartCoordinateY() const
{
- if (m <= maxTotalEV)
- maxEVPerStat = m;
- return (maxEVPerStat == m);
+ return startCoordinate.getY();
}
-bool PokeGen::PokeMod::Pokemod::SetPokerusChance(const unsigned n, const unsigned d)
+unsigned PokeGen::PokeMod::Pokemod::getStartDirection() const
{
- return pokerusChance.Set(n, d);
+ return startDirection;
}
-bool PokeGen::PokeMod::Pokemod::SetPokerusChanceNum(const unsigned n)
+unsigned PokeGen::PokeMod::Pokemod::getStartDialog() const
{
- return pokerusChance.SetNum(n);
+ return startDialog;
}
-bool PokeGen::PokeMod::Pokemod::SetPokerusChanceDenom(const unsigned d)
+QString PokeGen::PokeMod::Pokemod::getSuperPCUname() const
{
- return pokerusChance.SetDenom(d);
+ return superPCUname;
}
-bool PokeGen::PokeMod::Pokemod::SetStartMap(const unsigned s)
+QString PokeGen::PokeMod::Pokemod::getSuperPCPasswd() const
{
- if (GetMapByID(s) != UINT_MAX)
- startMap = s;
- return (startMap == s);
+ return superPCPasswd;
}
-void PokeGen::PokeMod::Pokemod::SetStartMoney(const unsigned s)
+unsigned PokeGen::PokeMod::Pokemod::getStruggleMove() const
{
- startMoney = s;
+ return struggleMove;
}
-bool PokeGen::PokeMod::Pokemod::SetStartCoordinate(const unsigned x, const unsigned y)
+const PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::getAbility(const unsigned i) const
{
- if (const Map* m = GetMap(GetMapByID(startMap)))
- {
- if ((x < m->GetWidth()) && (y < m->GetHeight()))
- {
- startCoordinate.Set(x, y);
- return true;
- }
- }
- return false;
+ if (getAbilityCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return abilities.at(i);
}
-bool PokeGen::PokeMod::Pokemod::SetStartCoordinateX(const unsigned x)
+PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::getAbility(const unsigned i)
{
- if (const Map* m = GetMap(GetMapByID(startMap)))
- {
- if (x < m->GetWidth())
- {
- startCoordinate.SetX(x);
- return true;
- }
- }
- return false;
+ if (getAbilityCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return abilities[i];
}
-bool PokeGen::PokeMod::Pokemod::SetStartCoordinateY(const unsigned y)
+unsigned PokeGen::PokeMod::Pokemod::getAbilityByID(const unsigned _id) const
{
- if (const Map* m = GetMap(GetMapByID(startMap)))
+ for (unsigned i = 0; i < getAbilityCount(); ++i)
{
- if (y < m->GetHeight())
- {
- startCoordinate.SetY(y);
- return true;
- }
+ if (abilities[i].getId() == _id)
+ return i;
}
- return false;
-}
-
-bool PokeGen::PokeMod::Pokemod::SetStartDirection(const unsigned s)
-{
- if (s < D_End)
- startDirection = s;
- return (startDirection == s);
-}
-
-bool PokeGen::PokeMod::Pokemod::SetStartDialog(const unsigned s)
-{
- if (GetDialogByID(s) != UINT_MAX)
- startDialog = s;
- return (startDialog == s);
+ return UINT_MAX;
}
-bool PokeGen::PokeMod::Pokemod::SetWalkSkin(const QString& w)
+unsigned PokeGen::PokeMod::Pokemod::getAbilityCount() const
{
- QFile file(pokemod->GetPath() + "images/skins/walk.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(w, pokemod->GetPath() + "images/skins/walk.png");
+ return abilities.size();
}
-bool PokeGen::PokeMod::Pokemod::SetBikeSkin(const QString& b)
+PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility()
{
- QFile file(pokemod->GetPath() + "images/skins/bike.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(b, pokemod->GetPath() + "images/skins/bike.png");
+ abilities.append(Ability(*this, getNewAbilityId()));
+ return abilities[getAbilityCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::SetSurfSkin(const QString& s)
+PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility(const QString& fname)
{
- QFile file(pokemod->GetPath() + "images/skins/surf.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(s, pokemod->GetPath() + "images/skins/surf.png");
+ abilities.append(Ability(*this, fname, getNewAbilityId()));
+ return abilities[getAbilityCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::SetFlySkin(const QString& f)
+PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility(const Ability& a)
{
- QFile file(pokemod->GetPath() + "images/skins/fly.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(f, pokemod->GetPath() + "images/skins/fly.png");
+ abilities.append(Ability(*this, a, getNewAbilityId()));
+ return abilities[getAbilityCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::SetFishSkin(const QString& f)
+void PokeGen::PokeMod::Pokemod::deleteAbility(const unsigned i)
{
- QFile file(pokemod->GetPath() + "images/skins/fish.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(f, pokemod->GetPath() + "images/skins/fish.png");
+ if (getAbilityCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ abilities.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::SetSurfFishSkin(const QString& s)
+const PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::getAuthor(const unsigned i) const
{
- QFile file(pokemod->GetPath() + "images/skins/surfFish.png");
- if (file.exists() && !file.remove())
- return false;
- return QFile::copy(s, pokemod->GetPath() + "images/skins/surfFish.png");
+ if (getAuthorCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return authors.at(i);
}
-void PokeGen::PokeMod::Pokemod::SetSuperPCUname(const QString& u)
+PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::getAuthor(const unsigned i)
{
- superPCUname = u;
+ if (getAuthorCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return authors[i];
}
-void PokeGen::PokeMod::Pokemod::SetSuperPCPasswd(const QString& p)
+unsigned PokeGen::PokeMod::Pokemod::getAuthorByID(const unsigned _id) const
{
- superPCPasswd = p;
-}
-
-bool PokeGen::PokeMod::Pokemod::SetStruggleMove(const unsigned s)
-{
- if (GetMoveByID(s) != UINT_MAX)
- struggleMove = s;
- return (struggleMove == s);
+ for (unsigned i = 0; i < getAuthorCount(); ++i)
+ {
+ if (authors[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-bool PokeGen::PokeMod::Pokemod::SetConfuseMove(const unsigned c)
+unsigned PokeGen::PokeMod::Pokemod::getAuthorCount() const
{
- if (GetMoveByID(c) != UINT_MAX)
- confuseMove = c;
- return (confuseMove == c);
+ return authors.size();
}
-QString PokeGen::PokeMod::Pokemod::GetTitle() const
+PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::newAuthor()
{
- return title;
+ authors.append(Author(*this, getNewAuthorId()));
+ return authors[getAuthorCount() + 1];
}
-QString PokeGen::PokeMod::Pokemod::GetVersion() const
+void PokeGen::PokeMod::Pokemod::deleteAuthor(const unsigned i)
{
- return version;
+ if (getAuthorCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ authors.removeAt(i);
}
-QString PokeGen::PokeMod::Pokemod::GetDescription() const
+const PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::getBadge(const unsigned i) const
{
- return description;
+ if (i < getBadgeCount())
+ throw("Pokemod: out-of-bounds");
+ return badges.at(i);
}
-bool PokeGen::PokeMod::Pokemod::IsGenderAllowed() const
+PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::getBadge(const unsigned i)
{
- return genderAllowed;
+ if (i < getBadgeCount())
+ throw("Pokemod: out-of-bounds");
+ return badges[i];
}
-bool PokeGen::PokeMod::Pokemod::IsBreedingAllowed() const
+unsigned PokeGen::PokeMod::Pokemod::getBadgeByID(const unsigned _id) const
{
- return breedingAllowed;
+ for (unsigned i = 0; i < getBadgeCount(); ++i)
+ {
+ if (badges[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetEggSpecies() const
+unsigned PokeGen::PokeMod::Pokemod::getBadgeCount() const
{
- return eggSpecies;
+ return badges.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetHoldItems() const
+PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge()
{
- return holdItems;
+ badges.append(Badge(*this, getNewBadgeId()));
+ return badges[getBadgeCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::HasCriticalDomains() const
+PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge(const QString& fname)
{
- return criticalDomains;
+ badges.append(Badge(*this, fname, getNewBadgeId()));
+ return badges[getBadgeCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::IsAbilityAllowed() const
+PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge(const Badge& b)
{
- return abilityAllowed;
+ badges.append(Badge(*this, b, getNewBadgeId()));
+ return badges[getBadgeCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::IsNatureAllowed() const
+void PokeGen::PokeMod::Pokemod::deleteBadge(const unsigned i)
{
- return natureAllowed;
+ if (getBadgeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ badges.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetNumPokemonBoxes() const
+const PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::getCoinList(const unsigned i) const
{
- return numPokemonBoxes;
+ if (getCoinListCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return coinLists.at(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetNumPokemonPerBox() const
+PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::getCoinList(const unsigned i)
{
- return numPokemonPerBox;
+ if (getCoinListCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return coinLists[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxParty() const
+unsigned PokeGen::PokeMod::Pokemod::getCoinListByID(const unsigned _id) const
{
- return maxParty;
+ for (unsigned i = 0; i < getCoinListCount(); ++i)
+ {
+ if (coinLists[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxFight() const
+unsigned PokeGen::PokeMod::Pokemod::getCoinListCount() const
{
- return maxFight;
+ return coinLists.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxMoves() const
+PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList()
{
- return maxMoves;
+ coinLists.append(CoinList(*this, getNewCoinListId()));
+ return coinLists[getCoinListCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxLevel() const
+PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList(const QString& fname)
{
- return maxLevel;
+ coinLists.append(CoinList(*this, fname, getNewCoinListId()));
+ return coinLists[getCoinListCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxMoney() const
+PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList(const CoinList& c)
{
- return maxMoney;
+ coinLists.append(CoinList(*this, c, getNewCoinListId()));
+ return coinLists[getCoinListCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::IsHardCash() const
+void PokeGen::PokeMod::Pokemod::deleteCoinList(const unsigned i)
{
- return hardCash;
+ if (getCoinListCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ coinLists.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::IsSpecialSplit() const
+const PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::getDialog(const unsigned i) const
{
- return specialSplit;
+ if (getDialogCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return dialogs.at(i);
}
-bool PokeGen::PokeMod::Pokemod::IsSpecialDVSplit() const
+PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::getDialog(const unsigned i)
{
- return specialDVSplit;
+ if (getDialogCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return dialogs[i];
}
-unsigned char PokeGen::PokeMod::Pokemod::GetMaxDVValue() const
+unsigned PokeGen::PokeMod::Pokemod::getDialogByID(const unsigned _id) const
{
- return maxDVValue;
+ for (unsigned i = 0; i < getDialogCount(); ++i)
+ {
+ if (dialogs[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-bool PokeGen::PokeMod::Pokemod::IsHappiness() const
+unsigned PokeGen::PokeMod::Pokemod::getDialogCount() const
{
- return happiness;
+ return dialogs.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetHappyFaintLoss() const
+PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog()
{
- return happyFaintLoss;
+ dialogs.append(Dialog(*this, getNewDialogId()));
+ return dialogs[getDialogCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetHappyLevelGain() const
+PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog(const QString& fname)
{
- return happyLevelGain;
+ dialogs.append(Dialog(*this, fname, getNewDialogId()));
+ return dialogs[getDialogCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetHappySteps() const
+PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog(const Dialog& d)
{
- return happySteps;
+ dialogs.append(Dialog(*this, d, getNewDialogId()));
+ return dialogs[getDialogCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::IsEffortValuesAllowed() const
+void PokeGen::PokeMod::Pokemod::deleteDialog(const unsigned i)
{
- return effortValuesAllowed;
+ if (getDialogCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ dialogs.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxTotalEV() const
+const PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::getEggGroup(const unsigned i) const
{
- return maxTotalEV;
+ if (getEggGroupCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return eggGroups.at(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetMaxEVPerStat() const
+PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::getEggGroup(const unsigned i)
{
- return maxEVPerStat;
+ if (getEggGroupCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return eggGroups[i];
}
-PokeGen::Frac PokeGen::PokeMod::Pokemod::GetPokerusChance() const
+unsigned PokeGen::PokeMod::Pokemod::getEggGroupByID(const unsigned _id) const
{
- return pokerusChance;
+ for (unsigned i = 0; i < getEggGroupCount(); ++i)
+ {
+ if (eggGroups[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetPokerusChanceNum() const
+unsigned PokeGen::PokeMod::Pokemod::getEggGroupCount() const
{
- return pokerusChance.GetNum();
+ return eggGroups.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetPokerusChanceDenom() const
+PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup()
{
- return pokerusChance.GetDenom();
+ eggGroups.append(EggGroup(*this, getNewEggGroupId()));
+ return eggGroups[getEggGroupCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartMap() const
+PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup(const QString& fname)
{
- return startMap;
+ eggGroups.append(EggGroup(*this, fname, getNewEggGroupId()));
+ return eggGroups[getEggGroupCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartMoney() const
+PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup(const EggGroup& e)
{
- return startMoney;
+ eggGroups.append(EggGroup(*this, e, getNewEggGroupId()));
+ return eggGroups[getEggGroupCount() - 1];
}
-PokeGen::Point PokeGen::PokeMod::Pokemod::GetStartCoordinate() const
+void PokeGen::PokeMod::Pokemod::deleteEggGroup(const unsigned i)
{
- return startCoordinate;
+ if (getEggGroupCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ eggGroups.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartCoordinateX() const
+const PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::getItem(const unsigned i) const
{
- return startCoordinate.GetX();
+ if (getItemCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return items.at(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartCoordinateY() const
+PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::getItem(const unsigned i)
{
- return startCoordinate.GetY();
+ if (getItemCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return items[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartDirection() const
+unsigned PokeGen::PokeMod::Pokemod::getItemByID(const unsigned _id) const
{
- return startDirection;
+ for (unsigned i = 0; i < getItemCount(); ++i)
+ {
+ if (items[i].getId() == _id)
+ return i;
+ }
+ return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetStartDialog() const
+unsigned PokeGen::PokeMod::Pokemod::getItemCount() const
{
- return startDialog;
+ return items.size();
}
-QString PokeGen::PokeMod::Pokemod::GetSuperPCUname() const
+PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem()
{
- return superPCUname;
+ items.append(Item(*this, getNewItemId()));
+ return items[getItemCount() - 1];
}
-QString PokeGen::PokeMod::Pokemod::GetSuperPCPasswd() const
+PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem(const QString& fname)
{
- return superPCPasswd;
+ items.append(Item(*this, fname, getNewItemId()));
+ return items[getItemCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStruggleMove() const
+PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem(const Item& i)
{
- return struggleMove;
+ items.append(Item(*this, i, getNewItemId()));
+ return items[getItemCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetConfuseMove() const
+void PokeGen::PokeMod::Pokemod::deleteItem(const unsigned i)
{
- return confuseMove;
+ if (getItemCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ items.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::SetTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d)
+const PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::getItemType(const unsigned i) const
{
- unsigned col = UINT_MAX;
- unsigned row = UINT_MAX;
- for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row == UINT_MAX)); ++i)
- {
- if (typeChart(i, 0).GetNum() == att)
- col = i;
- if (typeChart(0, i).GetNum() == def)
- row = i;
- }
- if ((col != UINT_MAX) && (row != UINT_MAX))
- return typeChart(col, row).Set(n, d);
- return false;
+ if (getItemTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return itemTypes.at(i);
}
-bool PokeGen::PokeMod::Pokemod::SetTypeChartNum(const unsigned att, const unsigned def, const unsigned n)
+PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::getItemType(const unsigned i)
{
- unsigned col = UINT_MAX;
- unsigned row = UINT_MAX;
- for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row == UINT_MAX)); ++i)
- {
- if (typeChart(i, 0).GetNum() == att)
- col = i;
- if (typeChart(0, i).GetNum() == def)
- row = i;
- }
- if ((col != UINT_MAX) && (row != UINT_MAX))
- return typeChart(col, row).SetNum(n);
- return false;
+ if (getItemTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return itemTypes[i];
}
-bool PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const unsigned att, const unsigned def, const unsigned d)
+unsigned PokeGen::PokeMod::Pokemod::getItemTypeByID(const unsigned _id) const
{
- unsigned col = UINT_MAX;
- unsigned row = UINT_MAX;
- for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row == UINT_MAX)); ++i)
+ for (unsigned i = 0; i < getItemTypeCount(); ++i)
{
- if (typeChart(i, 0).GetNum() == att)
- col = i;
- if (typeChart(0, i).GetNum() == def)
- row = i;
+ if (itemTypes[i].getId() == _id)
+ return i;
}
- if ((col != UINT_MAX) && (row != UINT_MAX))
- return typeChart(col, row).SetDenom(d);
- return false;
+ return UINT_MAX;
}
-PokeGen::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const unsigned att, const unsigned def) const
+unsigned PokeGen::PokeMod::Pokemod::getItemTypeCount() const
{
- unsigned col = UINT_MAX;
- unsigned row = UINT_MAX;
- for (unsigned i = 1; (i < typeChart.GetWidth()) && ((col == UINT_MAX) || (row != UINT_MAX)); ++i)
- {
- if (typeChart(i, 0).GetNum() == att)
- row = i;
- if (typeChart(0, i).GetNum() == def)
- col = i;
- }
- if ((col != UINT_MAX) && (row != UINT_MAX))
- return typeChart(col, row);
- return Frac(1, 1);
+ return itemTypes.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetTypeChartNum(const unsigned att, const unsigned def) const
+PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType()
{
- return GetTypeChart(att, def).GetNum();
+ itemTypes.append(ItemType(*this, getNewItemTypeId()));
+ return itemTypes[getItemTypeCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetTypeChartDenom(const unsigned att, const unsigned def) const
+PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType(const QString& fname)
{
- return GetTypeChart(att, def).GetDenom();
+ itemTypes.append(ItemType(*this, fname, getNewItemTypeId()));
+ return itemTypes[getItemTypeCount() - 1];
}
-const PokeGen::PokeMod::Ability* PokeGen::PokeMod::Pokemod::GetAbility(const unsigned i) const
+PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType(const ItemType& i)
{
- if (i < GetAbilityCount())
- return &abilities[i];
- return NULL;
+ itemTypes.append(ItemType(*this, i, getNewItemTypeId()));
+ return itemTypes[getItemTypeCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetAbilityByID(const unsigned _id) const
+void PokeGen::PokeMod::Pokemod::deleteItemType(const unsigned i)
{
- for (unsigned i = 0; i < GetAbilityCount(); ++i)
- {
- if (abilities[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ if (getItemTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ itemTypes.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetAbilityCount() const
+const PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::getMap(const unsigned i) const
{
- return abilities.size();
+ if (getMapCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return maps.at(i);
}
-const PokeGen::PokeMod::Ability* PokeGen::PokeMod::Pokemod::NewAbility(Ini* const ini)
+PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::getMap(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetAbilityCount()) && (GetAbilityByID(i) != UINT_MAX); ++i)
- ;
- Ability newAbility(this, i);
- if (ini)
- newAbility.ImportIni(*ini);
- abilities.append(newAbility);
- return &abilities[GetAbilityCount() - 1];
+ if (getMapCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return maps[i];
}
-bool PokeGen::PokeMod::Pokemod::DeleteAbility(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getMapByID(const unsigned _id) const
{
- if (i < GetAbilityCount())
+ for (unsigned i = 0; i < getMapCount(); ++i)
{
- abilities.erase(abilities.begin() + i);
- return true;
- }
- return false;
-}
-
-const PokeGen::PokeMod::Author* PokeGen::PokeMod::Pokemod::GetAuthor(const unsigned i) const
-{
- if (i < GetAuthorCount())
- return &authors[i];
- return NULL;
-}
-
-unsigned PokeGen::PokeMod::Pokemod::GetAuthorByID(const unsigned _id) const
-{
- for (unsigned i = 0; i < GetAuthorCount(); ++i)
- {
- if (authors[i].GetId() == _id)
+ if (maps[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetAuthorCount() const
-{
- return authors.size();
-}
-
-const PokeGen::PokeMod::Author* PokeGen::PokeMod::Pokemod::NewAuthor(Ini* const ini)
-{
- unsigned i = 0;
- for (; (i < GetAuthorCount()) && (GetAuthorByID(i) != UINT_MAX); ++i)
- ;
- Author newAuthor(this, i);
- if (ini)
- newAuthor.ImportIni(*ini);
- authors.append(newAuthor);
- return &authors[GetAuthorCount() + 1];
-}
-
-bool PokeGen::PokeMod::Pokemod::DeleteAuthor(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getMapCount() const
{
- if (i < GetAuthorCount())
- {
- authors.erase(authors.begin() + i);
- return true;
- }
- return false;
+ return maps.size();
}
-const PokeGen::PokeMod::Badge* PokeGen::PokeMod::Pokemod::GetBadge(const unsigned i) const
+PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap()
{
- if (i < GetBadgeCount())
- return &badges[i];
- return NULL;
+ maps.append(Map(*this, getNewMapId()));
+ return maps[getMapCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetBadgeByID(const unsigned _id) const
+PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap(const QString& fname)
{
- for (unsigned i = 0; i < GetBadgeCount(); ++i)
- {
- if (badges[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ maps.append(Map(*this, fname, getNewMapId()));
+ return maps[getMapCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetBadgeCount() const
+PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap(const Map& m)
{
- return badges.size();
+ maps.append(Map(*this, m, getNewMapId()));
+ return maps[getMapCount() - 1];
}
-const PokeGen::PokeMod::Badge* PokeGen::PokeMod::Pokemod::NewBadge(Ini* const ini)
+void PokeGen::PokeMod::Pokemod::deleteMap(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetBadgeCount()) && (GetBadgeByID(i) != UINT_MAX); ++i)
- ;
- Badge newBadge(this, i);
- if (ini)
- newBadge.ImportIni(*ini);
- badges.append(newBadge);
- return &badges[GetBadgeCount() - 1];
+ if (getMapCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ maps.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::DeleteBadge(const unsigned i)
+const PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::getMove(const unsigned i) const
{
- if (i < GetBadgeCount())
- {
- badges.erase(badges.begin() + i);
- return true;
- }
- return false;
+ if (getMoveCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return moves.at(i);
}
-const PokeGen::PokeMod::CoinList* PokeGen::PokeMod::Pokemod::GetCoinList(const unsigned i) const
+PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::getMove(const unsigned i)
{
- if (i < GetCoinListCount())
- {
- return &coinLists[i];
- }
- return NULL;
+ if (getMoveCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return moves[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetCoinListByID(const unsigned _id) const
+unsigned PokeGen::PokeMod::Pokemod::getMoveByID(const unsigned _id) const
{
- for (unsigned i = 0; i < GetCoinListCount(); ++i)
+ for (unsigned i = 0; i < getMoveCount(); ++i)
{
- if (coinLists[i].GetId() == _id)
+ if (moves[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetCoinListCount() const
+unsigned PokeGen::PokeMod::Pokemod::getMoveCount() const
{
- return coinLists.size();
+ return moves.size();
}
-const PokeGen::PokeMod::CoinList* PokeGen::PokeMod::Pokemod::NewCoinList(Ini* const ini)
+PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove()
{
- unsigned i = 0;
- for (; (i < GetCoinListCount()) && (GetCoinListByID(i) != UINT_MAX); ++i)
- ;
- CoinList newCoinList(this, i);
- if (ini)
- newCoinList.ImportIni(*ini);
- coinLists.append(newCoinList);
- return &coinLists[GetCoinListCount() - 1];
+ moves.append(Move(*this, getNewMoveId()));
+ return moves[getMoveCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::DeleteCoinList(const unsigned i)
+PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove(const QString& fname)
{
- if (i < GetCoinListCount())
- {
- coinLists.erase(coinLists.begin() + i);
- return true;
- }
- return false;
+ moves.append(Move(*this, fname, getNewMoveId()));
+ return moves[getMoveCount() - 1];
}
-const PokeGen::PokeMod::Dialog* PokeGen::PokeMod::Pokemod::GetDialog(const unsigned i) const
+PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove(const Move& m)
{
- if (i < GetDialogCount())
- return &dialogs[i];
- return NULL;
+ moves.append(Move(*this, m, getNewMoveId()));
+ return moves[getMoveCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetDialogByID(const unsigned _id) const
+void PokeGen::PokeMod::Pokemod::deleteMove(const unsigned i)
{
- for (unsigned i = 0; i < GetDialogCount(); ++i)
- {
- if (dialogs[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ if (getMoveCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ moves.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetDialogCount() const
+const PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::getNature(const unsigned i) const
{
- return dialogs.size();
+ if (getNatureCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return natures.at(i);
}
-const PokeGen::PokeMod::Dialog* PokeGen::PokeMod::Pokemod::NewDialog(Ini* const ini)
+PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::getNature(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetDialogCount()) && (GetDialogByID(i) != UINT_MAX); ++i)
- ;
- Dialog newDialog(this, i);
- if (ini)
- newDialog.ImportIni(*ini);
- dialogs.append(newDialog);
- return &dialogs[GetDialogCount() - 1];
+ if (getNatureCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return natures[i];
}
-bool PokeGen::PokeMod::Pokemod::DeleteDialog(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getNatureByID(const unsigned _id) const
{
- if (i < GetDialogCount())
+ for (unsigned i = 0; i < getNatureCount(); ++i)
{
- dialogs.erase(dialogs.begin() + i);
- return true;
- }
- return false;
-}
-
-const PokeGen::PokeMod::EggGroup* PokeGen::PokeMod::Pokemod::GetEggGroup(const unsigned i) const
-{
- if (i < GetEggGroupCount())
- return &eggGroups[i];
- return NULL;
-}
-
-unsigned PokeGen::PokeMod::Pokemod::GetEggGroupByID(const unsigned _id) const
-{
- for (unsigned i = 0; i < GetEggGroupCount(); ++i)
- {
- if (eggGroups[i].GetId() == _id)
+ if (natures[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetEggGroupCount() const
+unsigned PokeGen::PokeMod::Pokemod::getNatureCount() const
{
- return eggGroups.size();
+ return natures.size();
}
-const PokeGen::PokeMod::EggGroup* PokeGen::PokeMod::Pokemod::NewEggGroup(Ini* const ini)
+PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature()
{
- unsigned i = 0;
- for (; (i < GetEggGroupCount()) && (GetEggGroupByID(i) != UINT_MAX); ++i)
- ;
- EggGroup newEggGroup(this, i);
- if (ini)
- newEggGroup.ImportIni(*ini);
- eggGroups.append(newEggGroup);
- return &eggGroups[GetEggGroupCount() - 1];
+ natures.append(Nature(*this, getNewNatureId()));
+ return natures[getNatureCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::DeleteEggGroup(const unsigned i)
+PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature(const QString& fname)
{
- if (i < GetEggGroupCount())
- {
- eggGroups.erase(eggGroups.begin() + i);
- return true;
- }
- return false;
+ natures.append(Nature(*this, fname, getNewNatureId()));
+ return natures[getNatureCount() - 1];
}
-const PokeGen::PokeMod::Item* PokeGen::PokeMod::Pokemod::GetItem(const unsigned i) const
+PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature(const Nature& n)
{
- if (i < GetItemCount())
- return &items[i];
- return NULL;
+ natures.append(Nature(*this, n, getNewNatureId()));
+ return natures[getNatureCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetItemByID(const unsigned _id) const
+void PokeGen::PokeMod::Pokemod::deleteNature(const unsigned i)
{
- for (unsigned i = 0; i < GetItemCount(); ++i)
- {
- if (items[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ if (getNatureCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ natures.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetItemCount() const
+const PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::getSpecies(const unsigned i) const
{
- return items.size();
+ if (getSpeciesCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return species.at(i);
}
-const PokeGen::PokeMod::Item* PokeGen::PokeMod::Pokemod::NewItem(Ini* const ini)
+PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::getSpecies(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetItemCount()) && (GetItemByID(i) != UINT_MAX); ++i)
- ;
- Item newItem(this, i);
- if (ini)
- newItem.ImportIni(*ini);
- items.append(newItem);
- return &items[GetItemCount() - 1];
+ if (getSpeciesCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return species[i];
}
-bool PokeGen::PokeMod::Pokemod::DeleteItem(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getSpeciesByID(const unsigned _id) const
{
- if (i < GetItemCount())
+ for (unsigned i = 0; i < getSpeciesCount(); ++i)
{
- items.erase(items.begin() + i);
- return true;
- }
- return false;
-}
-
-const PokeGen::PokeMod::ItemType* PokeGen::PokeMod::Pokemod::GetItemType(const unsigned i) const
-{
- if (i < GetItemTypeCount())
- return &itemTypes[i];
- return NULL;
-}
-
-unsigned PokeGen::PokeMod::Pokemod::GetItemTypeByID(const unsigned _id) const
-{
- for (unsigned i = 0; i < GetItemTypeCount(); ++i)
- {
- if (itemTypes[i].GetId() == _id)
+ if (species[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetItemTypeCount() const
+unsigned PokeGen::PokeMod::Pokemod::getSpeciesCount() const
{
- return itemTypes.size();
-}
-
-const PokeGen::PokeMod::ItemType* PokeGen::PokeMod::Pokemod::NewItemType(Ini* const ini)
-{
- unsigned i = 0;
- for (; (i < GetItemTypeCount()) && (GetItemTypeByID(i) != UINT_MAX); ++i)
- ;
- ItemType newItemType(this, i);
- if (ini)
- newItemType.ImportIni(*ini);
- itemTypes.append(newItemType);
- return &itemTypes[GetItemTypeCount() - 1];
-}
-
-bool PokeGen::PokeMod::Pokemod::DeleteItemType(const unsigned i)
-{
- if (i < GetItemTypeCount())
- {
- itemTypes.erase(itemTypes.begin() + i);
- return true;
- }
- return false;
+ return species.size();
}
-const PokeGen::PokeMod::Map* PokeGen::PokeMod::Pokemod::GetMap(const unsigned i) const
+PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies()
{
- if (i < GetMapCount())
- return &maps[i];
- return NULL;
+ species.append(Species(*this, getNewSpeciesId()));
+ return species[getSpeciesCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMapByID(const unsigned _id) const
+PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies(const QString& fname)
{
- for (unsigned i = 0; i < GetMapCount(); ++i)
- {
- if (maps[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ species.append(Species(*this, fname, getNewSpeciesId()));
+ return species[getSpeciesCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMapCount() const
+PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies(const Species& s)
{
- return maps.size();
+ species.append(Species(*this, s, getNewSpeciesId()));
+ return species[getSpeciesCount() - 1];
}
-const PokeGen::PokeMod::Map* PokeGen::PokeMod::Pokemod::NewMap(Ini* const ini)
+void PokeGen::PokeMod::Pokemod::deleteSpecies(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetMapCount()) && (GetMapByID(i) != UINT_MAX); ++i)
- ;
- Map newMap(this, i);
- if (ini)
- newMap.ImportIni(*ini);
- maps.append(newMap);
- return &maps[GetMapCount() - 1];
+ if (getSpeciesCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ species.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::DeleteMap(const unsigned i)
+const PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::getStore(const unsigned i) const
{
- if (i < GetMapCount())
- {
- maps.erase(maps.begin() + i);
- return true;
- }
- return false;
+ if (getStoreCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return stores.at(i);
}
-const PokeGen::PokeMod::Move* PokeGen::PokeMod::Pokemod::GetMove(const unsigned i) const
+PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::getStore(const unsigned i)
{
- if (i < GetMoveCount())
- return &moves[i];
- return NULL;
+ if (getStoreCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return stores[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetMoveByID(const unsigned _id) const
+unsigned PokeGen::PokeMod::Pokemod::getStoreByID(const unsigned _id) const
{
- for (unsigned i = 0; i < GetMoveCount(); ++i)
+ for (unsigned i = 0; i < getStoreCount(); ++i)
{
- if (moves[i].GetId() == _id)
+ if (stores[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetMoveCount() const
+unsigned PokeGen::PokeMod::Pokemod::getStoreCount() const
{
- return moves.size();
-}
-
-const PokeGen::PokeMod::Move* PokeGen::PokeMod::Pokemod::NewMove(Ini* const ini)
-{
- unsigned i = 0;
- for (; (i < GetMoveCount()) && (GetMoveByID(i) != UINT_MAX); ++i)
- ;
- Move newMove(this, i);
- if (ini)
- newMove.ImportIni(*ini);
- moves.append(newMove);
- return &moves[GetMoveCount() - 1];
-}
-
-bool PokeGen::PokeMod::Pokemod::DeleteMove(const unsigned i)
-{
- if (i < GetMoveCount())
- {
- moves.erase(moves.begin() + i);
- return true;
- }
- return false;
+ return stores.size();
}
-const PokeGen::PokeMod::Nature* PokeGen::PokeMod::Pokemod::GetNature(const unsigned i) const
+PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore()
{
- if (i < GetNatureCount())
- return &natures[i];
- return NULL;
+ stores.append(Store(*this, getNewStoreId()));
+ return stores[getStoreCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetNatureByID(const unsigned _id) const
+PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore(const QString& fname)
{
- for (unsigned i = 0; i < GetNatureCount(); ++i)
- {
- if (natures[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ stores.append(Store(*this, fname, getNewStoreId()));
+ return stores[getStoreCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetNatureCount() const
+PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore(const Store& s)
{
- return natures.size();
+ stores.append(Store(*this, s, getNewStoreId()));
+ return stores[getStoreCount() - 1];
}
-const PokeGen::PokeMod::Nature* PokeGen::PokeMod::Pokemod::NewNature(Ini* const ini)
+void PokeGen::PokeMod::Pokemod::deleteStore(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetNatureCount()) && (GetNatureByID(i) != UINT_MAX); ++i)
- ;
- Nature newNature(this, i);
- if (ini)
- newNature.ImportIni(*ini);
- natures.append(newNature);
- return &natures[GetNatureCount() - 1];
+ if (getStoreCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ stores.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::DeleteNature(const unsigned i)
+const PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::getTile(const unsigned i) const
{
- if (i < GetNatureCount())
- {
- natures.erase(natures.begin() + i);
- return true;
- }
- return false;
+ if (getTileCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return tiles.at(i);
}
-const PokeGen::PokeMod::Species* PokeGen::PokeMod::Pokemod::GetSpecies(const unsigned i) const
+PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::getTile(const unsigned i)
{
- if (i < GetSpeciesCount())
- return &species[i];
- return NULL;
+ if (getTileCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return tiles[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetSpeciesByID(const unsigned _id) const
+unsigned PokeGen::PokeMod::Pokemod::getTileByID(const unsigned _id) const
{
- for (unsigned i = 0; i < GetSpeciesCount(); ++i)
+ for (unsigned i = 0; i < getTileCount(); ++i)
{
- if (species[i].GetId() == _id)
+ if (tiles[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetSpeciesCount() const
-{
- return species.size();
-}
-
-const PokeGen::PokeMod::Species* PokeGen::PokeMod::Pokemod::NewSpecies(Ini* const ini)
-{
- unsigned i = 0;
- for (; (i < GetSpeciesCount()) && (GetSpeciesByID(i) != UINT_MAX); ++i)
- ;
- Species newSpecies(this, i);
- if (ini)
- newSpecies.ImportIni(*ini);
- species.append(newSpecies);
- return &species[GetSpeciesCount() - 1];
-}
-
-bool PokeGen::PokeMod::Pokemod::DeleteSpecies(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getTileCount() const
{
- if (i < GetSpeciesCount())
- {
- species.erase(species.begin() + i);
- return true;
- }
- return false;
+ return tiles.size();
}
-const PokeGen::PokeMod::Store* PokeGen::PokeMod::Pokemod::GetStore(const unsigned i) const
+PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile()
{
- if (i < GetStoreCount())
- return &stores[i];
- return NULL;
+ tiles.append(Tile(*this, getNewTileId()));
+ return tiles[getTileCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStoreByID(const unsigned _id) const
+PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile(const QString& fname)
{
- for (unsigned i = 0; i < GetStoreCount(); ++i)
- {
- if (stores[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ tiles.append(Tile(*this, fname, getNewTileId()));
+ return tiles[getTileCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetStoreCount() const
+PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile(const Tile& t)
{
- return stores.size();
+ tiles.append(Tile(*this, t, getNewTileId()));
+ return tiles[getTileCount() - 1];
}
-const PokeGen::PokeMod::Store* PokeGen::PokeMod::Pokemod::NewStore(Ini* const ini)
+void PokeGen::PokeMod::Pokemod::deleteTile(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetStoreCount()) && (GetStoreByID(i) != UINT_MAX); ++i)
- ;
- Store newStore(this, i);
- if (ini)
- newStore.ImportIni(*ini);
- stores.append(newStore);
- return &stores[GetStoreCount() - 1];
+ if (getTileCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ tiles.removeAt(i);
}
-bool PokeGen::PokeMod::Pokemod::DeleteStore(const unsigned i)
+const PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::getTime(const unsigned i) const
{
- if (i < GetStoreCount())
- {
- stores.erase(stores.begin() + i);
- return true;
- }
- return false;
+ if (getTimeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return times.at(i);
}
-const PokeGen::PokeMod::Tile* PokeGen::PokeMod::Pokemod::GetTile(const unsigned i) const
+PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::getTime(const unsigned i)
{
- if (i < GetTileCount())
- return &tiles[i];
- return NULL;
+ if (getTimeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return times[i];
}
-unsigned PokeGen::PokeMod::Pokemod::GetTileByID(const unsigned _id) const
+unsigned PokeGen::PokeMod::Pokemod::getTimeByID(const unsigned _id) const
{
- for (unsigned i = 0; i < GetTileCount(); ++i)
+ for (unsigned i = 0; i < getTimeCount(); ++i)
{
- if (tiles[i].GetId() == _id)
+ if (times[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeGen::PokeMod::Pokemod::GetTileCount() const
+unsigned PokeGen::PokeMod::Pokemod::getTimeCount() const
{
- return tiles.size();
+ return times.size();
}
-const PokeGen::PokeMod::Tile* PokeGen::PokeMod::Pokemod::NewTile(Ini* const ini)
+PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime()
{
- unsigned i = 0;
- for (; (i < GetTileCount()) && (GetTileByID(i) != UINT_MAX); ++i)
- ;
- Tile newTile(this, i);
- if (ini)
- newTile.ImportIni(*ini);
- tiles.append(newTile);
- return &tiles[GetTileCount() - 1];
+ times.append(Time(*this, getNewTimeId()));
+ return times[getTimeCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::DeleteTile(const unsigned i)
+PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime(const QString& fname)
{
- if (i < GetTileCount())
- {
- tiles.erase(tiles.begin() + i);
- return true;
- }
- return false;
+ times.append(Time(*this, fname, getNewTimeId()));
+ return times[getTimeCount() - 1];
}
-const PokeGen::PokeMod::Time* PokeGen::PokeMod::Pokemod::GetTime(const unsigned i) const
+PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime(const Time& t)
{
- if (i < GetTimeCount())
- return &times[i];
- return NULL;
+ times.append(Time(*this, t, getNewTimeId()));
+ return times[getTimeCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetTimeByID(const unsigned _id) const
+void PokeGen::PokeMod::Pokemod::deleteTime(const unsigned i)
{
- for (unsigned i = 0; i < GetTimeCount(); ++i)
- {
- if (times[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ if (getTimeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ times.removeAt(i);
}
-unsigned PokeGen::PokeMod::Pokemod::GetTimeCount() const
+const PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::getType(const unsigned i) const
{
- return times.size();
+ if (getTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return types.at(i);
}
-const PokeGen::PokeMod::Time* PokeGen::PokeMod::Pokemod::NewTime(Ini* const ini)
+PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::getType(const unsigned i)
{
- unsigned i = 0;
- for (; (i < GetTimeCount()) && (GetTimeByID(i) != UINT_MAX); ++i)
- ;
- Time newTime(this, i);
- if (ini)
- newTime.ImportIni(*ini);
- times.append(newTime);
- return &times[GetTimeCount() - 1];
+ if (getTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ return types[i];
}
-bool PokeGen::PokeMod::Pokemod::DeleteTime(const unsigned i)
+unsigned PokeGen::PokeMod::Pokemod::getTypeByID(const unsigned _id) const
{
- if (i < GetTimeCount())
+ for (unsigned i = 0; i < getTypeCount(); ++i)
{
- times.erase(times.begin() + i);
- return true;
+ if (types[i].getId() == _id)
+ return i;
}
- return false;
+ return UINT_MAX;
}
-const PokeGen::PokeMod::Type* PokeGen::PokeMod::Pokemod::GetType(const unsigned i) const
+unsigned PokeGen::PokeMod::Pokemod::getTypeCount() const
{
- if (i < GetTypeCount())
- return &types[i];
- return NULL;
+ return types.size();
}
-unsigned PokeGen::PokeMod::Pokemod::GetTypeByID(const unsigned _id) const
+PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType()
{
- for (unsigned i = 0; i < GetTypeCount(); ++i)
- {
- if (types[i].GetId() == _id)
- return i;
- }
- return UINT_MAX;
+ FracMatrix& typeChart = rules.getTypeChart();
+ unsigned i;
+ types.append(Type(*this, i = getNewTypeId()));
+ typeChart.addCol(Frac(1, 1));
+ typeChart.addRow(Frac(1, 1));
+ return types[getTypeCount() - 1];
}
-unsigned PokeGen::PokeMod::Pokemod::GetTypeCount() const
+PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const QString& fname)
{
- return types.size();
+ FracMatrix& typeChart = rules.getTypeChart();
+ unsigned i;
+ types.append(Type(*this, fname, i = getNewTypeId()));
+ typeChart.addCol(Frac(1, 1));
+ typeChart.addRow(Frac(1, 1));
+ return types[getTypeCount() - 1];
}
-const PokeGen::PokeMod::Type* PokeGen::PokeMod::Pokemod::NewType(Ini* const ini)
+PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const Type& t)
{
- unsigned i = 0;
- for (; (i < GetTypeCount()) && (GetTypeByID(i) != UINT_MAX); ++i)
- ;
- Type newType(this, i);
- if (ini)
- newType.ImportIni(*ini);
- types.append(newType);
- typeChart.AddCol(Frac(1, 1));
- typeChart.AddRow(Frac(1, 1));
- typeChart(0, typeChart.GetHeight() - 1) = Frac(i, 1, Frac::Improper);
- typeChart(typeChart.GetHeight() - 1, 0) = Frac(i, 1, Frac::Improper);
- return &types[GetTypeCount() - 1];
+ FracMatrix& typeChart = rules.getTypeChart();
+ unsigned i;
+ types.append(Type(*this, t, i = getNewTypeId()));
+ typeChart.addCol(Frac(1, 1));
+ typeChart.addRow(Frac(1, 1));
+ return types[getTypeCount() - 1];
}
-bool PokeGen::PokeMod::Pokemod::DeleteType(const unsigned i)
+void PokeGen::PokeMod::Pokemod::deleteType(const unsigned i)
{
- if (i < GetTypeCount())
- {
- for (unsigned j = 0; j < typeChart.GetWidth(); ++j)
- {
- if (typeChart(j, 0).GetNum() == types[i].GetId())
- typeChart.DeleteCol(j);
- if (typeChart(0, j).GetNum() == types[i].GetId())
- typeChart.DeleteRow(j);
- }
- types.erase(types.begin() + i);
- return true;
- }
- return false;
+ if (getTypeCount() <= i)
+ throw("Pokemod: out-of-bounds");
+ rules.getTypeChart().deleteCol(i);
+ rules.getTypeChart().deleteRow(i);
}