diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-10-26 21:21:38 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-10-26 21:21:38 +0000 |
| commit | 83f4b43f63960ba30e38cf5bb53cd98ae738ef74 (patch) | |
| tree | 80f37f9e4a35ea11b8b1f0369f90208f393df83f /pokemod/Pokemod.cpp | |
| parent | 4385af885daf460a18e236f08509358f764b2c8c (diff) | |
| download | sigen-83f4b43f63960ba30e38cf5bb53cd98ae738ef74.tar.gz sigen-83f4b43f63960ba30e38cf5bb53cd98ae738ef74.tar.xz sigen-83f4b43f63960ba30e38cf5bb53cd98ae738ef74.zip | |
Redoing rev25
[ADD] DISCLAIMER
[FIX] PokemonEvolution styles
[ADD] Relative enumeration
[DEL] pokemod/Status.{h, cpp}
[DEL] pokemod/StatusEffect.{h, cpp}
[FIX] Status effects will be added as needed instead of customized
[FIX] Completed ItemEffects
[FIX] Factored out Natures to be global
[DEL] pokemod/PokemonNature.{h, cpp}
[DEL] ai/Net.{h, cpp}
[DEL] ai/Layer/{h, cpp}
[ADD] battle/Arena.{h, cpp}
[ADD] battle/Team.{h, cpp}
[ADD] battle/Human.{h, cpp}
[ADD] battle/Bot.{h, cpp}
[ADD] battle/GhostBot.{h, cpp}
[ADD] battle/Pokemon.{h, cpp}
[ADD] battle/Ghost.{h, cpp}
[FIX] Fixed some scope errors in pokemod
[ADD] audio/audio.pro
[ADD] audio/Audio.{h, cpp}
[ADD] audio/AudioLibrary.{h, cpp}
[ADD] audio/AudioSystem.{h, cpp}
[ADD] audio/Music.{h, cpp}
[ADD] audio/SoundEffect.{h, cpp}
[DEL] old audio system (was in C)
[FIX] Optimized some routines in pokemod
[FIX] Moved global classes (Ini, Frac, Matrix, FracMatrix, Point, Flag) to general
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@27 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemod.cpp')
| -rw-r--r-- | pokemod/Pokemod.cpp | 301 |
1 files changed, 77 insertions, 224 deletions
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index e3eebda7..f2cbb059 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -82,7 +82,7 @@ bool PokeGen::PokeMod::Pokemod::Validate() } if (description == "") ValidationMsg("Description is not defined", V_Warn); - if (genderAllowed && breedingAllowed && !GetPokemon(eggSpecies)) + if (genderAllowed && breedingAllowed && !GetSpecies(eggSpecies)) { ValidationMsg("Invalid egg species"); isValid = false; @@ -144,7 +144,7 @@ bool PokeGen::PokeMod::Pokemod::Validate() ValidationMsg("Invalid starting map"); isValid = false; } - if (DIR_End <= startDirection) + if (D_End <= startDirection) { ValidationMsg("Invalid starting direction"); isValid = false; @@ -550,9 +550,9 @@ bool PokeGen::PokeMod::Pokemod::Validate() isValid = false; } } - if (GetPokemonCount()) + if (GetSpeciesCount()) { - for (QList<Pokemon>::Iterator i = pokemon.begin(); i != pokemon.end(); ++i) + for (QList<Species>::Iterator i = species.begin(); i != species.end(); ++i) { if (!i->IsValid()) isValid = false; @@ -583,36 +583,6 @@ bool PokeGen::PokeMod::Pokemod::Validate() ValidationMsg("There are no Pokémon"); isValid = false; } - if (GetStatusCount()) - { - for (QList<Status>::Iterator i = statuses.begin(); i != statuses.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 Statuses 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 Statuses with the name \"%2\"").arg(i.value()).arg(i.key())); - isValid = false; - } - } - idChecker.clear(); - nameChecker.clear(); - } - else - ValidationMsg("There are no statuses", V_Warn); if (GetStoreCount()) { for (QList<Store>::Iterator i = stores.begin(); i != stores.end(); ++i) @@ -837,10 +807,8 @@ void PokeGen::PokeMod::Pokemod::ImportIni(const QString& f) NewMove(&curSection); else if (curSection.GetName() == "nature") NewNature(&curSection); - else if (curSection.GetName() == "pokemon") - NewPokemon(&curSection); - else if (curSection.GetName() == "status") - NewStatus(&curSection); + else if (curSection.GetName() == "species") + NewSpecies(&curSection); else if (curSection.GetName() == "store") NewStore(&curSection); else if (curSection.GetName() == "tile") @@ -943,57 +911,39 @@ void PokeGen::PokeMod::Pokemod::ImportIni(const QString& f) } sections.erase(i); } - else if (s[0] == "pokemonAbility") - { - for (unsigned j = 0; j < GetPokemonCount(); ++j) - { - if (pokemon[j].GetName() == s[1]) - pokemon[j].NewAbility(&*i); - } - sections.erase(i); - } - else if (s[0] == "pokemonEvolution") + else if (s[0] == "speciesAbility") { - for (unsigned j = 0; j < GetPokemonCount(); ++j) + for (unsigned j = 0; j < GetSpeciesCount(); ++j) { - if (pokemon[j].GetName() == s[1]) - pokemon[j].NewEvolution(&*i); + if (species[j].GetName() == s[1]) + species[j].NewAbility(&*i); } sections.erase(i); } - else if (s[0] == "pokemonItem") + else if (s[0] == "speciesEvolution") { - for (unsigned j = 0; j < GetPokemonCount(); ++j) + for (unsigned j = 0; j < GetSpeciesCount(); ++j) { - if (pokemon[j].GetName() == s[1]) - pokemon[j].NewItem(&*i); + if (species[j].GetName() == s[1]) + species[j].NewEvolution(&*i); } sections.erase(i); } - else if (s[0] == "pokemonMove") + else if (s[0] == "speciesItem") { - for (unsigned j = 0; j < GetPokemonCount(); ++j) + for (unsigned j = 0; j < GetSpeciesCount(); ++j) { - if (pokemon[j].GetName() == s[1]) - pokemon[j].NewMove(&*i); + if (species[j].GetName() == s[1]) + species[j].NewItem(&*i); } sections.erase(i); } - else if (s[0] == "pokemonNature") + else if (s[0] == "speciesMove") { - for (unsigned j = 0; j < GetPokemonCount(); ++j) + for (unsigned j = 0; j < GetSpeciesCount(); ++j) { - if (pokemon[j].GetName() == s[1]) - pokemon[j].NewNature(&*i); - } - sections.erase(i); - } - else if (s[0] == "statusEffect") - { - for (unsigned j = 0; j < GetStatusCount(); ++j) - { - if (statuses[j].GetName() == s[1]) - statuses[j].NewEffect(&*i); + if (species[j].GetName() == s[1]) + species[j].NewMove(&*i); } sections.erase(i); } @@ -1006,7 +956,7 @@ void PokeGen::PokeMod::Pokemod::ImportIni(const QString& f) u = s[1].toUInt(&ok); if (ok) { - if (s[0] == "mapTrainerPokemon") + if (s[0] == "mapTrainerSpecies") { for (unsigned j = 0; j < GetMapCount(); ++j) { @@ -1111,9 +1061,7 @@ void PokeGen::PokeMod::Pokemod::ExportIni(const QString& f) i->ExportIni(fout); for (QList<Nature>::ConstIterator i = natures.begin(); i != natures.end(); ++i) i->ExportIni(fout); - for (QList<Pokemon>::ConstIterator i = pokemon.begin(); i != pokemon.end(); ++i) - i->ExportIni(fout); - for (QList<Status>::ConstIterator i = statuses.begin(); i != statuses.end(); ++i) + 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); @@ -1161,7 +1109,7 @@ bool PokeGen::PokeMod::Pokemod::SetIsBreedingAllowed(const bool b) bool PokeGen::PokeMod::Pokemod::SetEggSpecies(const unsigned e) { - if (breedingAllowed && (GetPokemonByID(e) != UINT_MAX)) + if (breedingAllowed && (GetSpeciesByID(e) != UINT_MAX)) eggSpecies = e; return (eggSpecies == e); } @@ -1356,7 +1304,7 @@ bool PokeGen::PokeMod::Pokemod::SetStartCoordinateY(const unsigned y) bool PokeGen::PokeMod::Pokemod::SetStartDirection(const unsigned s) { - if (s < DIR_End) + if (s < D_End) startDirection = s; return (startDirection == s); } @@ -1580,7 +1528,7 @@ unsigned PokeGen::PokeMod::Pokemod::GetMaxEVPerStat() const return maxEVPerStat; } -PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetPokerusChance() const +PokeGen::Frac PokeGen::PokeMod::Pokemod::GetPokerusChance() const { return pokerusChance; } @@ -1605,7 +1553,7 @@ unsigned PokeGen::PokeMod::Pokemod::GetStartMoney() const return startMoney; } -PokeGen::PokeMod::Point PokeGen::PokeMod::Pokemod::GetStartCoordinate() const +PokeGen::Point PokeGen::PokeMod::Pokemod::GetStartCoordinate() const { return startCoordinate; } @@ -1698,7 +1646,7 @@ bool PokeGen::PokeMod::Pokemod::SetTypeChartDenom(const unsigned att, const unsi return false; } -PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const unsigned att, const unsigned def) const +PokeGen::Frac PokeGen::PokeMod::Pokemod::GetTypeChart(const unsigned att, const unsigned def) const { unsigned col = UINT_MAX; unsigned row = UINT_MAX; @@ -1749,11 +1697,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetAbilityCount() const const PokeGen::PokeMod::Ability* PokeGen::PokeMod::Pokemod::NewAbility(Ini* const ini) { unsigned i = 0; - for (; i < GetAbilityCount(); ++i) - { - if (GetAbilityByID(i) == UINT_MAX) - break; - } + for (; (i < GetAbilityCount()) && (GetAbilityByID(i) != UINT_MAX); ++i) + ; Ability newAbility(this, i); if (ini) newAbility.ImportIni(*ini); @@ -1796,11 +1741,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetAuthorCount() const const PokeGen::PokeMod::Author* PokeGen::PokeMod::Pokemod::NewAuthor(Ini* const ini) { unsigned i = 0; - for (; i < GetAuthorCount(); ++i) - { - if (GetAuthorByID(i) == UINT_MAX) - break; - } + for (; (i < GetAuthorCount()) && (GetAuthorByID(i) != UINT_MAX); ++i) + ; Author newAuthor(this, i); if (ini) newAuthor.ImportIni(*ini); @@ -1843,11 +1785,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetBadgeCount() const const PokeGen::PokeMod::Badge* PokeGen::PokeMod::Pokemod::NewBadge(Ini* const ini) { unsigned i = 0; - for (; i < GetBadgeCount(); ++i) - { - if (GetBadgeByID(i) == UINT_MAX) - break; - } + for (; (i < GetBadgeCount()) && (GetBadgeByID(i) != UINT_MAX); ++i) + ; Badge newBadge(this, i); if (ini) newBadge.ImportIni(*ini); @@ -1892,11 +1831,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetCoinListCount() const const PokeGen::PokeMod::CoinList* PokeGen::PokeMod::Pokemod::NewCoinList(Ini* const ini) { unsigned i = 0; - for (; i < GetCoinListCount(); ++i) - { - if (GetCoinListByID(i) == UINT_MAX) - break; - } + for (; (i < GetCoinListCount()) && (GetCoinListByID(i) != UINT_MAX); ++i) + ; CoinList newCoinList(this, i); if (ini) newCoinList.ImportIni(*ini); @@ -1939,11 +1875,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetDialogCount() const const PokeGen::PokeMod::Dialog* PokeGen::PokeMod::Pokemod::NewDialog(Ini* const ini) { unsigned i = 0; - for (; i < GetDialogCount(); ++i) - { - if (GetDialogByID(i) == UINT_MAX) - break; - } + for (; (i < GetDialogCount()) && (GetDialogByID(i) != UINT_MAX); ++i) + ; Dialog newDialog(this, i); if (ini) newDialog.ImportIni(*ini); @@ -1986,11 +1919,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetEggGroupCount() const const PokeGen::PokeMod::EggGroup* PokeGen::PokeMod::Pokemod::NewEggGroup(Ini* const ini) { unsigned i = 0; - for (; i < GetEggGroupCount(); ++i) - { - if (GetEggGroupByID(i) == UINT_MAX) - break; - } + for (; (i < GetEggGroupCount()) && (GetEggGroupByID(i) != UINT_MAX); ++i) + ; EggGroup newEggGroup(this, i); if (ini) newEggGroup.ImportIni(*ini); @@ -2033,11 +1963,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetItemCount() const const PokeGen::PokeMod::Item* PokeGen::PokeMod::Pokemod::NewItem(Ini* const ini) { unsigned i = 0; - for (; i < GetItemCount(); ++i) - { - if (GetItemByID(i) == UINT_MAX) - break; - } + for (; (i < GetItemCount()) && (GetItemByID(i) != UINT_MAX); ++i) + ; Item newItem(this, i); if (ini) newItem.ImportIni(*ini); @@ -2080,11 +2007,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetItemTypeCount() const const PokeGen::PokeMod::ItemType* PokeGen::PokeMod::Pokemod::NewItemType(Ini* const ini) { unsigned i = 0; - for (; i < GetItemTypeCount(); ++i) - { - if (GetItemTypeByID(i) == UINT_MAX) - break; - } + for (; (i < GetItemTypeCount()) && (GetItemTypeByID(i) != UINT_MAX); ++i) + ; ItemType newItemType(this, i); if (ini) newItemType.ImportIni(*ini); @@ -2127,11 +2051,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetMapCount() const const PokeGen::PokeMod::Map* PokeGen::PokeMod::Pokemod::NewMap(Ini* const ini) { unsigned i = 0; - for (; i < GetMapCount(); ++i) - { - if (GetMapByID(i) == UINT_MAX) - break; - } + for (; (i < GetMapCount()) && (GetMapByID(i) != UINT_MAX); ++i) + ; Map newMap(this, i); if (ini) newMap.ImportIni(*ini); @@ -2174,11 +2095,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetMoveCount() const const PokeGen::PokeMod::Move* PokeGen::PokeMod::Pokemod::NewMove(Ini* const ini) { unsigned i = 0; - for (; i < GetMoveCount(); ++i) - { - if (GetMoveByID(i) == UINT_MAX) - break; - } + for (; (i < GetMoveCount()) && (GetMoveByID(i) != UINT_MAX); ++i) + ; Move newMove(this, i); if (ini) newMove.ImportIni(*ini); @@ -2221,11 +2139,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetNatureCount() const const PokeGen::PokeMod::Nature* PokeGen::PokeMod::Pokemod::NewNature(Ini* const ini) { unsigned i = 0; - for (; i < GetNatureCount(); ++i) - { - if (GetNatureByID(i) == UINT_MAX) - break; - } + for (; (i < GetNatureCount()) && (GetNatureByID(i) != UINT_MAX); ++i) + ; Nature newNature(this, i); if (ini) newNature.ImportIni(*ini); @@ -2243,95 +2158,45 @@ bool PokeGen::PokeMod::Pokemod::DeleteNature(const unsigned i) return false; } -const PokeGen::PokeMod::Pokemon* PokeGen::PokeMod::Pokemod::GetPokemon(const unsigned i) const -{ - if (i < GetPokemonCount()) - return &pokemon[i]; - return NULL; -} - -unsigned PokeGen::PokeMod::Pokemod::GetPokemonByID(const unsigned _id) const -{ - for (unsigned i = 0; i < GetPokemonCount(); ++i) - { - if (pokemon[i].GetId() == _id) - return i; - } - return UINT_MAX; -} - -unsigned PokeGen::PokeMod::Pokemod::GetPokemonCount() const -{ - return pokemon.size(); -} - -const PokeGen::PokeMod::Pokemon* PokeGen::PokeMod::Pokemod::NewPokemon(Ini* const ini) -{ - unsigned i = 0; - for (; i < GetPokemonCount(); ++i) - { - if (!GetPokemon(i) == UINT_MAX) - break; - } - Pokemon newPokemon(this, i); - if (ini) - newPokemon.ImportIni(*ini); - pokemon.append(newPokemon); - return &pokemon[GetPokemonCount() - 1]; -} - -bool PokeGen::PokeMod::Pokemod::DeletePokemon(const unsigned i) -{ - if (i < GetPokemonCount()) - { - pokemon.erase(pokemon.begin() + i); - return true; - } - return false; -} - -const PokeGen::PokeMod::Status* PokeGen::PokeMod::Pokemod::GetStatus(const unsigned i) const +const PokeGen::PokeMod::Species* PokeGen::PokeMod::Pokemod::GetSpecies(const unsigned i) const { - if (i < GetStatusCount()) - return &statuses[i]; + if (i < GetSpeciesCount()) + return &species[i]; return NULL; } -unsigned PokeGen::PokeMod::Pokemod::GetStatusByID(const unsigned _id) const +unsigned PokeGen::PokeMod::Pokemod::GetSpeciesByID(const unsigned _id) const { - for (unsigned i = 0; i < GetStatusCount(); ++i) + for (unsigned i = 0; i < GetSpeciesCount(); ++i) { - if (statuses[i].GetId() == _id) + if (species[i].GetId() == _id) return i; } return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::GetStatusCount() const +unsigned PokeGen::PokeMod::Pokemod::GetSpeciesCount() const { - return statuses.size(); + return species.size(); } -const PokeGen::PokeMod::Status* PokeGen::PokeMod::Pokemod::NewStatus(Ini* const ini) +const PokeGen::PokeMod::Species* PokeGen::PokeMod::Pokemod::NewSpecies(Ini* const ini) { unsigned i = 0; - for (; i < GetStatusCount(); ++i) - { - if (GetStatusByID(i) == UINT_MAX) - break; - } - Status newStatus(this, i); + for (; (i < GetSpeciesCount()) && (GetSpeciesByID(i) != UINT_MAX); ++i) + ; + Species newSpecies(this, i); if (ini) - newStatus.ImportIni(*ini); - statuses.append(newStatus); - return &statuses[GetStatusCount() - 1]; + newSpecies.ImportIni(*ini); + species.append(newSpecies); + return &species[GetSpeciesCount() - 1]; } -bool PokeGen::PokeMod::Pokemod::DeleteStatus(const unsigned i) +bool PokeGen::PokeMod::Pokemod::DeleteSpecies(const unsigned i) { - if (i < GetStatusCount()) + if (i < GetSpeciesCount()) { - statuses.erase(statuses.begin() + i); + species.erase(species.begin() + i); return true; } return false; @@ -2362,11 +2227,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetStoreCount() const const PokeGen::PokeMod::Store* PokeGen::PokeMod::Pokemod::NewStore(Ini* const ini) { unsigned i = 0; - for (; i < GetStoreCount(); ++i) - { - if (GetStoreByID(i) == UINT_MAX) - break; - } + for (; (i < GetStoreCount()) && (GetStoreByID(i) != UINT_MAX); ++i) + ; Store newStore(this, i); if (ini) newStore.ImportIni(*ini); @@ -2409,11 +2271,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetTileCount() const const PokeGen::PokeMod::Tile* PokeGen::PokeMod::Pokemod::NewTile(Ini* const ini) { unsigned i = 0; - for (; i < GetTileCount(); ++i) - { - if (GetTileByID(i) == UINT_MAX) - break; - } + for (; (i < GetTileCount()) && (GetTileByID(i) != UINT_MAX); ++i) + ; Tile newTile(this, i); if (ini) newTile.ImportIni(*ini); @@ -2456,11 +2315,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetTimeCount() const const PokeGen::PokeMod::Time* PokeGen::PokeMod::Pokemod::NewTime(Ini* const ini) { unsigned i = 0; - for (; i < GetTimeCount(); ++i) - { - if (GetTimeByID(i) == UINT_MAX) - break; - } + for (; (i < GetTimeCount()) && (GetTimeByID(i) != UINT_MAX); ++i) + ; Time newTime(this, i); if (ini) newTime.ImportIni(*ini); @@ -2503,11 +2359,8 @@ unsigned PokeGen::PokeMod::Pokemod::GetTypeCount() const const PokeGen::PokeMod::Type* PokeGen::PokeMod::Pokemod::NewType(Ini* const ini) { unsigned i = 0; - for (; i < GetTypeCount(); ++i) - { - if (GetTypeByID(i) == UINT_MAX) - break; - } + for (; (i < GetTypeCount()) && (GetTypeByID(i) != UINT_MAX); ++i) + ; Type newType(this, i); if (ini) newType.ImportIni(*ini); |
