diff options
Diffstat (limited to 'pokemod/Species.cpp')
-rw-r--r-- | pokemod/Species.cpp | 951 |
1 files changed, 951 insertions, 0 deletions
diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp new file mode 100644 index 00000000..4d1cc8df --- /dev/null +++ b/pokemod/Species.cpp @@ -0,0 +1,951 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/Species.cpp +// Purpose: Define a species +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Fri June 1 2007 12:10:40 +// Copyright: ©2007 Nerdy Productions +// Licence: +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTSpecies or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program. If not, see <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////////// + +#include "Species.h" + +const char* PokeGen::PokeMod::Species::StyleStr[PokeGen::PokeMod::Species::End] = {"Fluctuating", "Fading", "Slow", "Normal", "Fast", "Erratic"}; + +PokeGen::PokeMod::Species::Species(const Pokemod* par, const unsigned _id) : + Object(_id, par), + name(""), + growth(UINT_MAX), + catchValue(0), + runChance(1, 1), + itemChance(1, 1), + pokedexNumber(UINT_MAX), + weight(0), + heightFeet(0), + heightInches(0), + pokedexEntry(""), + genderFactor(1, 1, true), + eggSpecies(UINT_MAX), + eggSteps(0), + isDitto(false), + nidoranGroup(UINT_MAX) +{ + for (unsigned i = 0; i < ST_End_GSC; ++i) + { + baseStats[i] = 0; + effortValues[i] = 0; + } +} + +PokeGen::PokeMod::Species::Species(const Pokemod* par, Ini& ini, const unsigned _id) : + Object(_id, par) +{ + ImportIni(ini, _id); +} + +bool PokeGen::PokeMod::Species::Validate() +{ + pokemod->ValidationMsg(QString("---Species \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); + if (name == "") + { + pokemod->ValidationMsg("Name is not defined"); + isValid = false; + } + for (unsigned i = 0; i < (pokemod->IsSpecialSplit() ? ST_End_GSC : ST_End_RBY); ++i) + { + if (!baseStats[i]) + { + pokemod->ValidationMsg(QString("Invalid baseStats[%1]").arg(i)); + isValid = false; + } + } + if (End <= growth) + { + pokemod->ValidationMsg("Invalid growth style"); + isValid = false; + } + if (pokemod->GetSpeciesCount() <= pokedexNumber) + { + pokemod->ValidationMsg("Invalid PokéDex number"); + isValid = false; + } + if (!weight) + pokemod->ValidationMsg("Species weighs nothing", Pokemod::V_Warn); + if (12 <= heightInches) + { + pokemod->ValidationMsg("Invalid height inches"); + isValid = false; + } + if (!QFile(pokemod->GetPath() + "pokemon/" + name + "/front" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png").exists()) + { + pokemod->ValidationMsg(QString("Cannot find the front%1 image").arg(pokemod->IsGenderAllowed() ? " male" : "")); + isValid = false; + } + if (!QFile(pokemod->GetPath() + "pokemon/" + name + "/back" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png").exists()) + { + pokemod->ValidationMsg(QString("Cannot find the back%1 image").arg(pokemod->IsGenderAllowed() ? " male" : "")); + isValid = false; + } + if (pokemod->IsGenderAllowed()) + { + if (!QFile(pokemod->GetPath() + "pokemon/" + name + "/front-female.png").exists()) + { + pokemod->ValidationMsg("Cannot find the front female image"); + isValid = false; + } + if (!QFile(pokemod->GetPath() + "pokemon/" + name + "/front-female.png").exists()) + { + pokemod->ValidationMsg("Cannot find the back female image"); + isValid = false; + } + } + if (!QFile(pokemod->GetPath() + "pokemon/" + name + "/list.png").exists()) + { + pokemod->ValidationMsg("Cannot find the list sprite"); + isValid = false; + } + if (pokemod->GetSpeciesByID(eggSpecies) == UINT_MAX) + pokemod->ValidationMsg("Invalid egg species", Pokemod::V_Warn); + else if (!eggSteps) + { + pokemod->ValidationMsg("Invalid egg steps"); + isValid = false; + } + QMap<unsigned, unsigned> idChecker; + QMap<unsigned, unsigned> nameChecker; + for (unsigned i = 0; i < GetTypeCount(); ++i) + { + if (pokemod->GetTypeByID(types[i]) == UINT_MAX) + isValid = false; + ++nameChecker[types[i]]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("%1 instances of type %s").arg(i.value()).arg(i.key())); + isValid = false; + } + } + nameChecker.clear(); + for (unsigned i = 0; i < GetEggGroupCount(); ++i) + { + if (pokemod->GetEggGroupByID(eggGroups[i]) == UINT_MAX) + isValid = false; + ++nameChecker[eggGroups[i]]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("%1 instances of egg group %s").arg(i.value()).arg(i.key())); + isValid = false; + } + } + nameChecker.clear(); + if (pokemod->IsAbilityAllowed()) + { + if (GetAbilityCount()) + { + for (QList<SpeciesAbility>::Iterator i = abilities.begin(); i != abilities.end(); ++i) + { + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++nameChecker[i->GetAbility()]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 abilities with id %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 abilities with the ability %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + idChecker.clear(); + nameChecker.clear(); + } + else + pokemod->ValidationMsg("There are no abilities", Pokemod::V_Warn); + } + if (GetEvolutionCount()) + { + for (QList<SpeciesEvolution>::Iterator i = evolutions.begin(); i != evolutions.end(); ++i) + { + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++nameChecker[i->GetSpecies()]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 evolutions with id %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 evoltions with the speices %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + idChecker.clear(); + nameChecker.clear(); + } + else + pokemod->ValidationMsg("There are no evolutions", Pokemod::V_Warn); + if (pokemod->GetHoldItems()) + { + if (GetItemCount()) + { + for (QList<SpeciesItem>::Iterator i = items.begin(); i != items.end(); ++i) + { + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++nameChecker[i->GetItem()]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 items with id %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 items with the item %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + idChecker.clear(); + nameChecker.clear(); + } + else + pokemod->ValidationMsg("There are no items", Pokemod::V_Warn); + } + if (GetMoveCount()) + { + for (QList<SpeciesMove>::Iterator i = moves.begin(); i != moves.end(); ++i) + { + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++nameChecker[i->GetMove()]; + } + for (QMap<unsigned, unsigned>::ConstIterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 moves with id %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + for (QMap<unsigned, unsigned>::ConstIterator i = nameChecker.begin(); i != nameChecker.end(); ++i) + { + if (1 < i.value()) + { + pokemod->ValidationMsg(QString("There are %1 moves with the move %2").arg(i.value()).arg(i.key())); + isValid = false; + } + } + idChecker.clear(); + nameChecker.clear(); + } + else + { + pokemod->ValidationMsg("There are no moves"); + isValid = false; + } + return isValid; +} + +void PokeGen::PokeMod::Species::ImportIni(Ini& ini, const unsigned _id) +{ + if (_id == UINT_MAX) + ini.GetValue("id", id); + else + id = _id; + unsigned i; + unsigned j; + ini.GetValue("name", name); + ini.GetValue("numTypes", i); + for (unsigned k = 0; k < i; ++k) + { + ini.GetValue(QString("types-%1").arg(i), j); + if (j != UINT_MAX) + types.append(j); + } + for (unsigned i = 0; i < ST_End_GSC; ++i) + ini.GetValue(QString("baseStats-%d").arg(i), baseStats[i], 0); + for (unsigned i = 0; i < ST_End_GSC; ++i) + ini.GetValue(QString("effortValues-%1").arg(i), effortValues[i], 0); + ini.GetValue("growth", growth); + ini.GetValue("experienceValue", experienceValue, 0); + ini.GetValue("catchValue", catchValue, 0); + ini.GetValue("runChance-n", i, 1); + ini.GetValue("runChance-d", j, 1); + runChance.Set(i, j); + ini.GetValue("itemChance-i", i, 1); + ini.GetValue("itemChance-j", j, 1); + itemChance.Set(i, j); + ini.GetValue("pokedexNumber", pokedexNumber); + ini.GetValue("weight", weight, 0); + ini.GetValue("heightFeet", heightFeet, 0); + ini.GetValue("heightInches", heightInches, 0); + ini.GetValue("pokedexEntry", pokedexEntry); + ini.GetValue("genderFactor-n", i, 1); + ini.GetValue("genderFactor-d", j, 1); + genderFactor.Set(i, j, true); + ini.GetValue("numEggGroups", i); + for (unsigned k = 0; k < i; ++k) + { + ini.GetValue(QString("eggGroups-%1").arg(i), j); + if (j != UINT_MAX) + types.append(j); + } + ini.GetValue("eggSpecies", eggSpecies); + ini.GetValue("eggSteps", eggSteps, 0); + ini.GetValue("isDitto", isDitto, false); + ini.GetValue("nidoranGroup", nidoranGroup); + abilities.clear(); + evolutions.clear(); + items.clear(); + moves.clear(); +} + +void PokeGen::PokeMod::Species::ExportIni(QFile& fout) const +{ + Ini exSpecies("species"); + exSpecies.AddField("id", id); + exSpecies.AddField("name", name); + exSpecies.AddField("numTypes", GetTypeCount()); + for (unsigned i = 0; i < GetTypeCount(); ++i) + exSpecies.AddField(QString("types-%1").arg(i), types[i]); + for (unsigned i = 0; i < ST_End_GSC; ++i) + exSpecies.AddField(QString("baseStats-%1").arg(i), baseStats[i]); + for (unsigned i = 0; i < ST_End_GSC; ++i) + exSpecies.AddField(QString("effortValues-%1").arg(i), effortValues[i]); + exSpecies.AddField("growth", growth); + exSpecies.AddField("experienceValue", experienceValue); + exSpecies.AddField("catchValue", catchValue); + exSpecies.AddField("runChance-n", runChance.GetNum()); + exSpecies.AddField("runChance-d", runChance.GetDenom()); + exSpecies.AddField("itemChance-n", itemChance.GetNum()); + exSpecies.AddField("itemChance-d", itemChance.GetDenom()); + exSpecies.AddField("pokedexNumber", pokedexNumber); + exSpecies.AddField("weight", weight); + exSpecies.AddField("heightFeet", heightFeet); + exSpecies.AddField("heightInches", heightInches); + exSpecies.AddField("pokedexEntry", pokedexEntry); + exSpecies.AddField("genderFactor-n", genderFactor.GetNum()); + exSpecies.AddField("genderFactor-d", genderFactor.GetDenom()); + exSpecies.AddField("numTypes", GetTypeCount()); + for (unsigned i = 0; i < GetEggGroupCount(); ++i) + exSpecies.AddField(QString("eggGroups-%1").arg(i), eggGroups[i]); + exSpecies.AddField("eggSpecies", eggSpecies); + exSpecies.AddField("eggSteps", eggSteps); + exSpecies.AddField("isDitto", isDitto); + exSpecies.AddField("nidoranGroup", nidoranGroup); + exSpecies.Export(fout); + for (QList<SpeciesAbility>::ConstIterator i = abilities.begin(); i != abilities.end(); ++i) + i->ExportIni(fout, name); + for (QList<SpeciesEvolution>::ConstIterator i = evolutions.begin(); i != evolutions.end(); ++i) + i->ExportIni(fout, name); + for (QList<SpeciesItem>::ConstIterator i = items.begin(); i != items.end(); ++i) + i->ExportIni(fout, name); + for (QList<SpeciesMove>::ConstIterator i = moves.begin(); i != moves.end(); ++i) + i->ExportIni(fout, name); +} + +void PokeGen::PokeMod::Species::SetName(const QString& n) +{ + name = n; +} + +bool PokeGen::PokeMod::Species::SetBaseStat(const unsigned s, const unsigned b) +{ + if ((s < ST_End_RBY) || ((s == ST_SpecialDefense) && pokemod->IsSpecialSplit())) + { + baseStats[s] = b; + return true; + } + return false; +} + +bool PokeGen::PokeMod::Species::SetEffortValue(const unsigned s, const unsigned e) +{ + if ((s < ST_End_RBY) || ((s == ST_SpecialDefense) && pokemod->IsSpecialSplit())) + { + effortValues[s] = e; + return true; + } + return false; +} + +bool PokeGen::PokeMod::Species::SetGrowth(const unsigned g) +{ + if (g < End) + growth = g; + return (growth == g); +} + +void PokeGen::PokeMod::Species::SetExperienceValue(const unsigned e) +{ + experienceValue = e; +} + +void PokeGen::PokeMod::Species::SetCatchValue(const unsigned char c) +{ + catchValue = c; +} + +bool PokeGen::PokeMod::Species::SetRunChance(const unsigned n, const unsigned d) +{ + return runChance.Set(n, d); +} + +bool PokeGen::PokeMod::Species::SetRunChanceNumerator(const unsigned n) +{ + return runChance.SetNum(n); +} + +bool PokeGen::PokeMod::Species::SetRunChanceDenominator(const unsigned d) +{ + return runChance.SetDenom(d); +} + +bool PokeGen::PokeMod::Species::SetItemChance(const unsigned n, const unsigned d) +{ + return itemChance.Set(n, d); +} + +bool PokeGen::PokeMod::Species::SetItemChanceNumerator(const unsigned n) +{ + return itemChance.SetNum(n); +} + +bool PokeGen::PokeMod::Species::SetItemChanceDenominator(const unsigned d) +{ + return itemChance.SetDenom(d); +} + +void PokeGen::PokeMod::Species::SetPokedexNumber(const unsigned p) +{ + pokedexNumber = p; +} + +void PokeGen::PokeMod::Species::SetWeight(const unsigned w) +{ + weight = w; +} + +void PokeGen::PokeMod::Species::SetHeightFeet(const unsigned f) +{ + heightFeet = f; +} + +bool PokeGen::PokeMod::Species::SetHeightInches(const unsigned char i) +{ + if (i < 12) + heightInches = i; + return (heightInches == i); +} + +void PokeGen::PokeMod::Species::SetPokedexEntry(const QString& p) +{ + pokedexEntry = p; +} + +bool PokeGen::PokeMod::Species::SetFrontMaleSprite(const QString& f) +{ + QFile file(pokemod->GetPath() + "pokemon/" + name + "/front" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png"); + if (file.exists() && !file.remove()) + return false; + return QFile::copy(f, pokemod->GetPath() + "pokemon/" + name + "/front" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png"); +} + +bool PokeGen::PokeMod::Species::SetBackMaleSprite(const QString& b) +{ + QFile file(pokemod->GetPath() + "pokemon/" + name + "/back" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png"); + if (file.exists() && !file.remove()) + return false; + return QFile::copy(b, pokemod->GetPath() + "pokemon/" + name + "/back" + (pokemod->IsGenderAllowed() ? "-male" : "") + ".png"); +} + +bool PokeGen::PokeMod::Species::SetFrontFemaleSprite(const QString& f) +{ + if (pokemod->IsGenderAllowed()) + { + QFile file(pokemod->GetPath() + "pokemon/" + name + "/front-female.png"); + if (file.exists() && !file.remove()) + return false; + return QFile::copy(f, pokemod->GetPath() + "pokemon/" + name + "/front-female.png"); + } + return false; +} + +bool PokeGen::PokeMod::Species::SetBackFemaleSprite(const QString& b) +{ + if (pokemod->IsGenderAllowed()) + { + QFile file(pokemod->GetPath() + "pokemon/" + name + "/back-female.png"); + if (file.exists() && !file.remove()) + return false; + return QFile::copy(b, pokemod->GetPath() + "pokemon/" + name + "/back-female.png"); + } + return false; +} + +bool PokeGen::PokeMod::Species::SetListSprite(const QString& l) +{ + QFile file(pokemod->GetPath() + "pokemon/" + name + "/list.png"); + if (file.exists() && !file.remove()) + return false; + return QFile::copy(l, pokemod->GetPath() + "pokemon/" + name + "/list.png"); +} + +bool PokeGen::PokeMod::Species::SetGenderFactor(const unsigned n, const unsigned d) +{ + return genderFactor.Set(n, d); +} + +bool PokeGen::PokeMod::Species::SetGenderFactorNumerator(const unsigned n) +{ + return genderFactor.SetNum(n); +} + +bool PokeGen::PokeMod::Species::SetGenderFactorDenominator(const unsigned d) +{ + return genderFactor.SetDenom(d); +} + +bool PokeGen::PokeMod::Species::SetEggSpecies(const unsigned e) +{ + if (pokemod->GetSpecies(e)) + eggSpecies = e; + return (eggSpecies == e); +} + +void PokeGen::PokeMod::Species::SetEggSteps(const unsigned e) +{ + eggSteps = e; +} + +void PokeGen::PokeMod::Species::SetIsDitto(const bool i) +{ + isDitto = i; +} + +void PokeGen::PokeMod::Species::SetNidoranGroup(const unsigned n) +{ + nidoranGroup = n; +} + +QString PokeGen::PokeMod::Species::GetName() const +{ + return name; +} + +unsigned PokeGen::PokeMod::Species::GetBaseStat(const unsigned s) const +{ + if ((s < ST_End_RBY) || ((s == ST_SpecialDefense) && pokemod->IsSpecialSplit())) + return baseStats[s]; + return 0; +} + +unsigned PokeGen::PokeMod::Species::GetEffortValue(const unsigned s) const +{ + if ((s < ST_End_RBY) || ((s == ST_SpecialDefense) && pokemod->IsSpecialSplit())) + return effortValues[s]; + return 0; +} + +unsigned PokeGen::PokeMod::Species::GetGrowth() const +{ + return growth; +} + +unsigned PokeGen::PokeMod::Species::GetExperienceValue() const +{ + return experienceValue; +} + +unsigned char PokeGen::PokeMod::Species::GetCatchValue() const +{ + return catchValue; +} + +PokeGen::Frac PokeGen::PokeMod::Species::GetRunChance() const +{ + return runChance; +} + +unsigned PokeGen::PokeMod::Species::GetRunChanceNumerator() const +{ + return runChance.GetNum(); +} + +unsigned PokeGen::PokeMod::Species::GetRunChanceDenominator() const +{ + return runChance.GetDenom(); +} + +PokeGen::Frac PokeGen::PokeMod::Species::GetItemChance() const +{ + return itemChance; +} + +unsigned PokeGen::PokeMod::Species::GetItemChanceNumerator() const +{ + return itemChance.GetNum(); +} + +unsigned PokeGen::PokeMod::Species::GetItemChanceDenominator() const +{ + return itemChance.GetDenom(); +} + +unsigned PokeGen::PokeMod::Species::GetPokedexNumber() const +{ + return pokedexNumber; +} + +unsigned PokeGen::PokeMod::Species::GetWeight() const +{ + return weight; +} + +unsigned PokeGen::PokeMod::Species::GetHeightFeet() const +{ + return heightFeet; +} + +unsigned PokeGen::PokeMod::Species::GetHeightInches() const +{ + return heightInches; +} + +QString PokeGen::PokeMod::Species::GetPokedexEntry() const +{ + return pokedexEntry; +} + +PokeGen::Frac PokeGen::PokeMod::Species::GetGenderFactor() const +{ + return genderFactor; +} + +unsigned PokeGen::PokeMod::Species::GetGenderFactorNumerator() const +{ + return genderFactor.GetNum(); +} + +unsigned PokeGen::PokeMod::Species::GetGenderFactorDenominator() const +{ + return genderFactor.GetDenom(); +} + +unsigned PokeGen::PokeMod::Species::GetEggSpecies() const +{ + return eggSpecies; +} + +unsigned PokeGen::PokeMod::Species::GetEggSteps() const +{ + return eggSteps; +} + +bool PokeGen::PokeMod::Species::GetIsDitto() const +{ + return isDitto; +} + +unsigned PokeGen::PokeMod::Species::GetNidoranGroup() const +{ + return nidoranGroup; +} + +unsigned PokeGen::PokeMod::Species::GetType(const unsigned i) const +{ + if (i < GetTypeCount()) + return types[i]; + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetTypeByID(const unsigned _id) const +{ + for (unsigned i = 0; i < GetTypeCount(); ++i) + { + if (types[i] == _id) + return types[i]; + } + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetTypeCount() const +{ + return types.size(); +} + +bool PokeGen::PokeMod::Species::NewType(const unsigned i) +{ + if (pokemod->GetTypeByID(i) == UINT_MAX) + { + types.append(i); + return true; + } + return false; +} + +bool PokeGen::PokeMod::Species::DeleteType(const unsigned i) +{ + if (i < GetTypeCount()) + { + types.erase(types.begin() + i); + return true; + } + return false; +} + +unsigned PokeGen::PokeMod::Species::GetEggGroup(const unsigned i) const +{ + if (i < GetEggGroupCount()) + return eggGroups[i]; + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetEggGroupByID(const unsigned i) const +{ + if (i < GetEggGroupCount() <= i) + return eggGroups[i]; + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetEggGroupCount() const +{ + return eggGroups.size(); +} + +bool PokeGen::PokeMod::Species::NewEggGroup(const unsigned i) +{ + if (pokemod->GetEggGroupByID(i) == UINT_MAX) + { + eggGroups.append(i); + return true; + } + return false; +} + +bool PokeGen::PokeMod::Species::DeleteEggGroup(const unsigned i) +{ + if (i < GetEggGroupCount()) + { + eggGroups.erase(eggGroups.begin() + i); + return true; + } + return false; +} + +const PokeGen::PokeMod::SpeciesAbility* PokeGen::PokeMod::Species::GetAbility(const unsigned i) const +{ + if (i < GetAbilityCount()) + return &abilities[i]; + return NULL; +} + +unsigned PokeGen::PokeMod::Species::GetAbilityByID(const unsigned _id) const +{ + for (unsigned i = 0; i < GetAbilityCount(); ++i) + { + if (abilities[i].GetId() == _id) + return i; + } + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetAbilityCount() const +{ + return abilities.size(); +} + +const PokeGen::PokeMod::SpeciesAbility* PokeGen::PokeMod::Species::NewAbility(Ini* const ini) +{ + unsigned i = 0; + for (; (i < GetAbilityCount()) && (GetAbilityByID(i) != UINT_MAX); ++i) + ; + SpeciesAbility newAbility(pokemod, i); + if (ini) + newAbility.ImportIni(*ini); + abilities.append(newAbility); + return &abilities[GetAbilityCount() - 1]; +} + +bool PokeGen::PokeMod::Species::DeleteAbility(const unsigned i) +{ + if (i < GetAbilityCount()) + { + abilities.erase(abilities.begin() + i); + return true; + } + return false; +} + +const PokeGen::PokeMod::SpeciesEvolution* PokeGen::PokeMod::Species::GetEvolution(const unsigned i) const +{ + if (i < GetEvolutionCount()) + return &evolutions[i]; + return NULL; +} + +unsigned PokeGen::PokeMod::Species::GetEvolutionByID(const unsigned _id) const +{ + for (unsigned i = 0; i < GetEvolutionCount(); ++i) + { + if (evolutions[i].GetId() == _id) + return i; + } + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetEvolutionCount() const +{ + return evolutions.size(); +} + +const PokeGen::PokeMod::SpeciesEvolution* PokeGen::PokeMod::Species::NewEvolution(Ini* const ini) +{ + unsigned i = 0; + for (; (i < GetItemCount()) && (GetItemByID(i) != UINT_MAX); ++i) + ; + SpeciesEvolution newEvolution(pokemod, i); + if (ini) + newEvolution.ImportIni(*ini); + evolutions.append(newEvolution); + return &evolutions[GetEvolutionCount() - 1]; +} + +bool PokeGen::PokeMod::Species::DeleteEvolution(const unsigned i) +{ + if (i < GetEvolutionCount()) + { + evolutions.erase(evolutions.begin() + i); + return true; + } + return false; +} + +const PokeGen::PokeMod::SpeciesItem* PokeGen::PokeMod::Species::GetItem(const unsigned i) const +{ + if (i < GetItemCount()) + return &items[i]; + return NULL; +} + +unsigned PokeGen::PokeMod::Species::GetItemByID(const unsigned _id) const +{ + for (unsigned i = 0; i < GetItemCount(); ++i) + { + if (items[i].GetId() == _id) + return i; + } + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetItemCount() const +{ + return items.size(); +} + +const PokeGen::PokeMod::SpeciesItem* PokeGen::PokeMod::Species::NewItem(Ini* const ini) +{ + unsigned i = 0; + for (; (i < GetItemCount()) && (GetItemByID(i) != UINT_MAX); ++i) + ; + SpeciesItem newItem(pokemod, i); + if (ini) + newItem.ImportIni(*ini); + items.append(newItem); + return &items[GetItemCount() - 1]; +} + +bool PokeGen::PokeMod::Species::DeleteItem(const unsigned i) +{ + if (i < GetItemCount()) + { + items.erase(items.begin() + i); + return true; + } + return false; +} + +const PokeGen::PokeMod::SpeciesMove* PokeGen::PokeMod::Species::GetMove(const unsigned i) const +{ + if (i < GetMoveCount()) + return &moves[i]; + return NULL; +} + +unsigned PokeGen::PokeMod::Species::GetMoveByID(const unsigned _id) const +{ + for (unsigned i = 0; i < GetMoveCount(); ++i) + { + if (moves[i].GetId() == _id) + return i; + } + return UINT_MAX; +} + +unsigned PokeGen::PokeMod::Species::GetMoveCount() const +{ + return moves.size(); +} + +const PokeGen::PokeMod::SpeciesMove* PokeGen::PokeMod::Species::NewMove(Ini* const ini) +{ + unsigned i = 0; + for (; (i < GetMoveCount()) && (GetMoveByID(i) != UINT_MAX); ++i) + ; + SpeciesMove newSpeciesMove(pokemod, i); + if (ini) + newSpeciesMove.ImportIni(*ini); + moves.append(newSpeciesMove); + return &moves[GetMoveCount() - 1]; +} + +bool PokeGen::PokeMod::Species::DeleteMove(const unsigned i) +{ + if (i < GetMoveCount()) + { + moves.erase(moves.begin() + i); + return true; + } + return false; +} |