/* * Copyright 2007-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 . */ #ifndef SIGBATTLE_TEAMMEMBER #define SIGBATTLE_TEAMMEMBER // Sigbattle includes #include "Global.h" // Sigscript includes #include "../sigscript/Config.h" // Sigmod includes #include "../sigmod/Global.h" // Qt includes #include #include #include #include #include #include #include #include // Forward declarations namespace Sigscript { class AbilityWrapper; class ItemWrapper; class MoveWrapper; class NatureWrapper; class MapTrainerTeamMemberWrapper; class SigmodWrapper; class SpeciesWrapper; class StatusWrapper; } namespace Kross { class Action; } namespace Sigbattle { class Arena; class Containment; class SIGBATTLE_EXPORT TeamMember : public Sigscript::Config { Q_OBJECT public: enum Gender { Male = 0, Female = 1, Genderless = 2 }; enum ActionType { Attack = 0, Item = 1, Switch = 2, Run = 3, Skip = 4, Timeout = 5, Invalid = 6 }; typedef QList Targets; typedef QPair ActionData; typedef QPair Action; typedef QPair > RequestedAction; TeamMember(const int speciesId, const QString& name, const int level, Containment* containment, const bool suppressItems = false); TeamMember(Sigscript::MapTrainerTeamMemberWrapper* teamMember, Containment* containment); Containment* containment() const; QUuid id() const; QString name() const; long long currentHp() const; Sigscript::SpeciesWrapper* species() const; int level() const; Gender gender() const; long long levelExperience() const; int baseStat(const Sigmod::Stat stat) const; long long statExperience(const Sigmod::Stat stat) const; int dv(const Sigmod::Stat stat) const; long long statValue(const Sigmod::Stat stat, const long long exp = -1) const; long long calcExp(int level = -1) const; bool canLearnMove(Sigscript::MoveWrapper* move) const; long long timer() const; Sigscript::SigmodWrapper* sigmod() const; public slots: void boostLevels(const int levels); void evolveInto(Sigscript::SpeciesWrapper* newSpecies); void setName(const QString& name); void cureStatus(Sigscript::StatusWrapper* status); void giveStatus(Sigscript::StatusWrapper* status); void giveLevelExp(const int exp); void giveStatExp(const Sigmod::Stat stat, const int exp); void takeItem(Sigscript::ItemWrapper* item); void giveItem(Sigscript::ItemWrapper* item); void forgetMove(Sigscript::MoveWrapper* move); void teachMove(Sigscript::MoveWrapper* move); Action requestAction(); Action latestAction() const; void makeActive(Arena* arena); void leaveArena(); void advanceTimer(const long long jump); virtual void writeBack(); signals: void speciesChanged(Sigscript::SpeciesWrapper* species); void evolveStart(); void evolveEnd(); void nameChanged(const QString& oldName, const QString& newName); void statusCured(Sigscript::StatusWrapper* status); void statusInflicted(Sigscript::StatusWrapper* status); void expGained(const int exp); void levelAboutToGrow(); void levelGrown(const int newLevel); void statChanged(const Sigmod::Stat stat, const int value); void effortFull(const int stat); void totalEffortFull(); void itemTaken(Sigscript::ItemWrapper* item); void itemGiven(Sigscript::ItemWrapper* item); void moveForgotten(Sigscript::MoveWrapper* move); void moveLearned(Sigscript::MoveWrapper* move); void movesFull(Sigscript::MoveWrapper* move); void unlearnableMove(Sigscript::MoveWrapper* move); void knockedOut(); protected: bool checkWeight(const Sigscript::ItemWrapper* item); Containment* m_containment; const QUuid m_id; QString m_name; long long m_currentHp; Sigscript::SpeciesWrapper* m_species; Gender m_gender; long long m_levelExp; int m_level; long long m_statExp[Sigmod::ST_SpecialDefense - Sigmod::ST_HP + 1]; int m_dv[Sigmod::ST_SpecialDefense - Sigmod::ST_HP + 1]; QMultiMap m_status; QMap m_abilities; QList m_items; QList m_moves; QList m_natures; long long m_timer; Action m_lastAction; QList m_abilityBattleScripts; QList m_statusBattleScripts; protected slots: void setSpecies(Sigscript::SpeciesWrapper* species); void setLevel(const int level); private: void makeConnections(); void initAbility(Sigscript::AbilityWrapper* ability); void initItems(); void initAbilities(const QList& initial = QList()); void initMoves(const QList& initial = QList()); void initNatures(const QList& initial = QList()); void initStats(); private slots: void levelGrown(); }; SIGBATTLE_EXPORT int actionPriority(TeamMember* teamMember, const TeamMember::Action& action); } Q_DECLARE_METATYPE(Sigbattle::TeamMember*) Q_DECLARE_METATYPE(Sigbattle::TeamMember::Gender) Q_DECLARE_METATYPE(Sigbattle::TeamMember::ActionType) Q_DECLARE_METATYPE(Sigbattle::TeamMember::Targets) Q_DECLARE_METATYPE(Sigbattle::TeamMember::ActionData) Q_DECLARE_METATYPE(Sigbattle::TeamMember::Action) Q_DECLARE_METATYPE(Sigbattle::TeamMember::RequestedAction) #endif