/* * Copyright 2008 Ben Boeckel * * 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 . */ // 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::SpeciesWrapper::abilityHat() { Pokemod::Hat hat; for (int i = 0; i < abilityCount(); ++i) hat.add(ability(i)->ability(), ability(i)->weight()); return hat; } Pokemod::Hat Pokescripting::SpeciesWrapper::itemHat() { Pokemod::Hat 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()) return value("runChance").value(); return m_species->runChance(); } Pokemod::Fraction Pokescripting::SpeciesWrapper::fleeChance() const { if (value("fleeChance").canConvert()) return value("fleeChance").value(); return m_species->fleeChance(); } Pokemod::Fraction Pokescripting::SpeciesWrapper::itemChance() const { if (value("itemChance").canConvert()) return value("itemChance").value(); 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()) return value("eggSpecies").toInt(); return m_species->eggSpecies(); } int Pokescripting::SpeciesWrapper::eggSteps() const { return m_species->eggSteps(); } QList Pokescripting::SpeciesWrapper::types() { QList typeIds = m_species->types(); QList types; foreach (int id, typeIds) types.append(TypeWrapper::create(pokemod()->typeById(id), this)); return types; } QList Pokescripting::SpeciesWrapper::eggGroups() { QList eggGroupIds = m_species->eggGroups(); QList 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(); }