summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWildList.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-01-21 00:44:23 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-01-21 00:44:23 +0000
commit2b653821cc31f18adb5d50bb0bc19048939670dc (patch)
treed333bbf0d1dde8fe0c1633bea60785b20ac07841 /pokemod/MapWildList.cpp
parente27ba66952a1e851bb417611e0ed7df1fbf5f945 (diff)
downloadsigen-2b653821cc31f18adb5d50bb0bc19048939670dc.tar.gz
sigen-2b653821cc31f18adb5d50bb0bc19048939670dc.tar.xz
sigen-2b653821cc31f18adb5d50bb0bc19048939670dc.zip
[ADD] More GUI classes (only MoveEffect left)
[FIX] Polished up GUI classes [FIX] renamed methods get*ByID -> get*Index instead for more logical get*ByID [FIX] Renaming in pokemod to remove mention of Pokémon [FIX] minor .pro fixes (aesthetic mainly) git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@35 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapWildList.cpp')
-rw-r--r--pokemod/MapWildList.cpp74
1 files changed, 42 insertions, 32 deletions
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 44f7f42b..79fd2fbc 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -73,7 +73,7 @@ bool PokeMod::MapWildList::validate() const
QMap<unsigned, unsigned> idChecker;
for (QListIterator<unsigned> i(times); i.hasNext(); i.next())
{
- if (pokemod.getTimeByID(i.peekNext()) == UINT_MAX)
+ if (pokemod.getTimeIndex(i.peekNext()) == UINT_MAX)
{
pokemod.validationMsg("Invalid time");
valid = false;
@@ -111,7 +111,7 @@ bool PokeMod::MapWildList::validate() const
unsigned PokeMod::MapWildList::getNewId() const
{
unsigned i = 0;
- for (; (i < getPokemonCount()) && (getPokemonByID(i) != UINT_MAX); ++i)
+ for (; (i < getEncounterCount()) && (getEncounterIndex(i) != UINT_MAX); ++i)
;
return i;
}
@@ -139,11 +139,11 @@ void PokeMod::MapWildList::load(const QString& fname, const unsigned _id) throw(
QStringList path = pokemod.getPath().split('/');
path.removeLast();
QDir fdir(path.join("/"));
- pokemon.clear();
- if (fdir.cd("pokemon"))
+ encounters.clear();
+ if (fdir.cd("encounter"))
{
for (QStringListIterator i(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); i.hasNext(); )
- newPokemon(i.next());
+ newEncounter(i.next());
}
}
@@ -158,7 +158,7 @@ void PokeMod::MapWildList::save(const QString& map) const throw(Exception)
ini.addField(QString("time-%1").arg(i), times[i]);
ini.addField("scope", scope);
ini.save(QString("%1/map/%2/wildlist/%3/data.pini").arg(pokemod.getPath()).arg(map).arg(id));
- for (QListIterator<MapWildListPokemon> i(pokemon); i.hasNext(); )
+ for (QListIterator<MapWildListEncounter> i(encounters); i.hasNext(); )
i.next().save(map, id);
}
@@ -221,58 +221,68 @@ int PokeMod::MapWildList::getScope() const
return scope;
}
-const PokeMod::MapWildListPokemon& PokeMod::MapWildList::getPokemon(const unsigned i) const throw(IndexException)
+const PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounter(const unsigned i) const throw(IndexException)
{
- if (getPokemonCount() <= i)
+ if (getEncounterCount() <= i)
throw(IndexException("MapWildList"));
- return pokemon.at(i);
+ return encounters.at(i);
}
-PokeMod::MapWildListPokemon& PokeMod::MapWildList::getPokemon(const unsigned i) throw(IndexException)
+PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounter(const unsigned i) throw(IndexException)
{
- if (getPokemonCount() <= i)
+ if (getEncounterCount() <= i)
throw(IndexException("MapWildList"));
- return pokemon[i];
+ return encounters[i];
}
-unsigned PokeMod::MapWildList::getPokemonByID(const unsigned _id) const
+const PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounterByID(const unsigned i) const throw(IndexException)
{
- for (unsigned i = 0; i < getPokemonCount(); ++i)
+ return getEncounter(getEncounterIndex(i));
+}
+
+PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounterByID(const unsigned i) throw(IndexException)
+{
+ return getEncounter(getEncounterIndex(i));
+}
+
+unsigned PokeMod::MapWildList::getEncounterIndex(const unsigned _id) const
+{
+ for (unsigned i = 0; i < getEncounterCount(); ++i)
{
- if (pokemon[i].getId() == _id)
+ if (encounters[i].getId() == _id)
return i;
}
return UINT_MAX;
}
-unsigned PokeMod::MapWildList::getPokemonCount() const
+unsigned PokeMod::MapWildList::getEncounterCount() const
{
- return pokemon.size();
+ return encounters.size();
}
-PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon()
+PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter()
{
- pokemon.append(MapWildListPokemon(pokemod, getNewId()));
- return pokemon[getPokemonCount() - 1];
+ encounters.append(MapWildListEncounter(pokemod, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
-PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon(const QString& fname)
+PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter(const QString& fname)
{
- pokemon.append(MapWildListPokemon(pokemod, fname, getNewId()));
- return pokemon[getPokemonCount() - 1];
+ encounters.append(MapWildListEncounter(pokemod, fname, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
-PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon(const MapWildListPokemon& p)
+PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter(const MapWildListEncounter& p)
{
- pokemon.append(MapWildListPokemon(pokemod, p, getNewId()));
- return pokemon[getPokemonCount() - 1];
+ encounters.append(MapWildListEncounter(pokemod, p, getNewId()));
+ return encounters[getEncounterCount() - 1];
}
-void PokeMod::MapWildList::deletePokemon(const unsigned i) throw(IndexException)
+void PokeMod::MapWildList::deleteEncounter(const unsigned i) throw(IndexException)
{
- if (getPokemonCount() <= i)
+ if (getEncounterCount() <= i)
throw(IndexException("MapWildList"));
- pokemon.removeAt(i);
+ encounters.removeAt(i);
}
PokeMod::MapWildList& PokeMod::MapWildList::operator=(const MapWildList& rhs)
@@ -283,8 +293,8 @@ PokeMod::MapWildList& PokeMod::MapWildList::operator=(const MapWildList& rhs)
value = rhs.value;
times = rhs.times;
scope = rhs.scope;
- pokemon.clear();
- for (unsigned i = 0; i < rhs.getPokemonCount(); ++i)
- newPokemon(rhs.getPokemon(i));
+ encounters.clear();
+ for (unsigned i = 0; i < rhs.getEncounterCount(); ++i)
+ newEncounter(rhs.getEncounter(i));
return *this;
}