summaryrefslogtreecommitdiffstats
path: root/pokebattle/TeamMember.h
blob: df1b333b67f2cc7675be7c8e62c7a9cdba37b35d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * Copyright 2007-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/>.
 */

#ifndef __POKEBATTLE_TEAMMEMBER__
#define __POKEBATTLE_TEAMMEMBER__

// Pokebattle includes
#include "Global.h"

// Pokescripting includes
#include "../pokescripting/Config.h"

// Pokemod includes
#include "../pokemod/Global.h"

// Qt includes
#include <QtCore/QFuture>
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QPair>
#include <QtCore/QString>

// Forward declarations
namespace Pokescripting
{
class MapTrainerTeamMemberWrapper;
class PokemodWrapper;
}

namespace Pokebattle
{
class Arena;
class Containment;

class POKEBATTLE_EXPORT TeamMember : public Pokescripting::Config
{
    Q_OBJECT
    
    public:
        enum ActionType
        {
            Attack = 0,
            Item = 1,
            Switch = 2,
            Run = 3,
            Skip = 4,
            Timeout = 5,
            End = 6
        };
        
        typedef QPair<ActionType, QVariant> Action;
        typedef QPair<TeamMember*, QFuture<TeamMember::Action> > RequestedAction;
        
        TeamMember(const int speciesId, const QString& name, const int level, Containment* containment, const bool suppressItems = false);
        TeamMember(Pokescripting::MapTrainerTeamMemberWrapper* teamMember, Containment* containment);
        
        QString name() const;
        int species() const;
        int level() const;
        int statValue(const int stat, const int exp = -1) const;
        int calcExp(int level = -1) const;
        
        bool canLearnMove(const int move);
    signals:
        void speciesChanged(const int species);
        
        void nameChanged(const QString& oldName, const QString& newName);
        void expGained(const int exp);
        void statusCured(const int status);
        void statusInflicted(const int status);
        void levelChanged(int level);
        void statChanged(int stat, int value);
        void effortFull(int stat);
        void totalEffortFull();
        void itemTaken(const int item);
        void itemGiven(const int item);
        void moveForgotten(const int move);
        void moveLearned(const int move);
        
        void knockedOut();
    public slots:
        void boostLevels(const int levels);
        
        void evolveInto(const int newSpecies);
        
        void setName(const QString& name);
        void cureStatus(const int status);
        void giveStatus(const int status);
        void giveLevelExp(const int exp);
        void giveStatExp(const int stat, const int exp);
        void takeItem(const int itemIndex);
        void giveItem(const int item);
        void forgetMove(const int moveIndex);
        void teachMove(const int move);
        
        Action requestAction() const;
        
        void makeActive(Arena* arena);
        
        virtual void writeBack();
    protected slots:
        void setSpecies(const int species);
        void setLevel(const int level);
    private slots:
        void levelGrown();
    protected:
        Pokescripting::PokemodWrapper* pokemod() const;
        
        Containment* m_containment;
        
        QString m_name;
        int m_species;
        int m_gender;
        int m_levelExp;
        int m_level;
        int m_statExp[Pokemod::ST_End_GSC];
        int m_dv[Pokemod::ST_End_GSC];
        QList<int> m_status;
        QList<int> m_abilities;
        QList<int> m_items;
        QList<int> m_moves;
        QList<int> m_natures;
    private:
        void initItems();
        void initAbilities();
        void initMoves();
        void initNatures();
        void initStats();
};
}

#endif