diff options
Diffstat (limited to 'pokescripting/SpeciesWrapper.cpp')
| -rw-r--r-- | pokescripting/SpeciesWrapper.cpp | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/pokescripting/SpeciesWrapper.cpp b/pokescripting/SpeciesWrapper.cpp new file mode 100644 index 00000000..9c2737e4 --- /dev/null +++ b/pokescripting/SpeciesWrapper.cpp @@ -0,0 +1,218 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +// Header include +#include "SpeciesWrapper.h" + +// Pokescripting includes +#include "AbilityWrapper.h" +#include "EggGroupWrapper.h" +#include "ItemWrapper.h" +#include "SkinWrapper.h" +#include "SpeciesAbilityWrapper.h" +#include "SpeciesItemWrapper.h" +#include "SpeciesMoveWrapper.h" +#include "SpriteWrapper.h" +#include "TypeWrapper.h" + +Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, QObject* parent) : + ObjectWrapper(species, parent), + m_species(species) +{ +} + +Pokemod::Hat<Pokescripting::AbilityWrapper*> Pokescripting::SpeciesWrapper::abilityHat() +{ + Pokemod::Hat<AbilityWrapper*> hat; + for (int i = 0; i < abilityCount(); ++i) + hat.add(ability(i)->ability(), ability(i)->weight()); + return hat; +} + +Pokemod::Hat<Pokescripting::ItemWrapper*> Pokescripting::SpeciesWrapper::itemHat() +{ + Pokemod::Hat<ItemWrapper*> hat; + for (int i = 0; i < itemCount(); ++i) + hat.add(item(i)->item(), item(i)->weight()); + return hat; +} + +QString Pokescripting::SpeciesWrapper::name() const +{ + return m_species->name(); +} + +int Pokescripting::SpeciesWrapper::baseStat(const int stat) const +{ + return m_species->baseStat(stat); +} + +int Pokescripting::SpeciesWrapper::effortValue(const int stat) const +{ + return m_species->effortValue(stat); +} + +int Pokescripting::SpeciesWrapper::growth() const +{ + return m_species->growth(); +} + +int Pokescripting::SpeciesWrapper::experienceValue() const +{ + return m_species->experienceValue(); +} + +int Pokescripting::SpeciesWrapper::catchValue() const +{ + return m_species->catchValue(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::runChance() const +{ + if (value("runChance").canConvert<Pokemod::Fraction>()) + return value("runChance").value<Pokemod::Fraction>(); + return m_species->runChance(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::fleeChance() const +{ + if (value("fleeChance").canConvert<Pokemod::Fraction>()) + return value("fleeChance").value<Pokemod::Fraction>(); + return m_species->fleeChance(); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::itemChance() const +{ + if (value("itemChance").canConvert<Pokemod::Fraction>()) + return value("itemChance").value<Pokemod::Fraction>(); + return m_species->itemChance(); +} + +int Pokescripting::SpeciesWrapper::pokedexNumber() const +{ + return m_species->pokedexNumber(); +} + +int Pokescripting::SpeciesWrapper::weight() const +{ + return m_species->weight(); +} + +int Pokescripting::SpeciesWrapper::height() const +{ + return m_species->height(); +} + +QString Pokescripting::SpeciesWrapper::pokedexEntry() const +{ + return m_species->pokedexEntry(); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontMaleSprite() +{ + return SpriteWrapper::create(pokemod()->spriteById(m_species->frontMaleSprite()), this); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backMaleSprite() +{ + return SpriteWrapper::create(pokemod()->spriteById(m_species->backMaleSprite()), this); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontFemaleSprite() +{ + return SpriteWrapper::create(pokemod()->spriteById(m_species->frontFemaleSprite()), this); +} + +Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backFemaleSprite() +{ + return SpriteWrapper::create(pokemod()->spriteById(m_species->backFemaleSprite()), this); +} + +Pokescripting::SkinWrapper* Pokescripting::SpeciesWrapper::skin() +{ + return SkinWrapper::create(pokemod()->skinById(m_species->skin()), this); +} + +Pokemod::Fraction Pokescripting::SpeciesWrapper::genderFactor() const +{ + return m_species->genderFactor(); +} + +int Pokescripting::SpeciesWrapper::eggSpecies() const +{ + if (value("eggSpecies").canConvert<int>()) + return value("eggSpecies").toInt(); + return m_species->eggSpecies(); +} + +int Pokescripting::SpeciesWrapper::eggSteps() const +{ + return m_species->eggSteps(); +} + +QList<Pokescripting::TypeWrapper*> Pokescripting::SpeciesWrapper::types() +{ + QList<int> typeIds = m_species->types(); + QList<TypeWrapper*> types; + foreach (int id, typeIds) + types.append(TypeWrapper::create(pokemod()->typeById(id), this)); + return types; +} + +QList<Pokescripting::EggGroupWrapper*> Pokescripting::SpeciesWrapper::eggGroups() +{ + QList<int> eggGroupIds = m_species->eggGroups(); + QList<EggGroupWrapper*> eggGroups; + foreach (int id, eggGroupIds) + eggGroups.append(EggGroupWrapper::create(pokemod()->eggGroupById(id), this)); + return eggGroups; +} + +Pokemod::Script Pokescripting::SpeciesWrapper::evolution() const +{ + return m_species->evolution(); +} + +Pokescripting::SpeciesAbilityWrapper* Pokescripting::SpeciesWrapper::ability(const int index) +{ + return SpeciesAbilityWrapper::create(m_species->ability(index), this); +} + +int Pokescripting::SpeciesWrapper::abilityCount() const +{ + return m_species->abilityCount(); +} + +Pokescripting::SpeciesItemWrapper* Pokescripting::SpeciesWrapper::item(const int index) +{ + return SpeciesItemWrapper::create(m_species->item(index), this); +} + +int Pokescripting::SpeciesWrapper::itemCount() const +{ + return m_species->itemCount(); +} + +Pokescripting::SpeciesMoveWrapper* Pokescripting::SpeciesWrapper::move(const int index) +{ + return SpeciesMoveWrapper::create(m_species->move(index), this); +} + +int Pokescripting::SpeciesWrapper::moveCount() const +{ + return m_species->moveCount(); +} |
