summaryrefslogtreecommitdiffstats
path: root/sigencore/TeamMember.h
blob: 6cebbf6b79d878d7a37880668573aee7b1c66a9d (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
/*
 * Copyright 2007-2009 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 SIGENCORE_TEAMMEMBER
#define SIGENCORE_TEAMMEMBER

// Sigencore includes
#include "Creature.h"
#include "Global.h"

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

// Forward declarations
namespace Kross
{
class Action;
class ActionCollection;
}

namespace Sigencore
{
class Arena;
class Team;

class SIGENCORE_EXPORT TeamMember : public Creature
{
    Q_OBJECT
    
    public:
        enum ActionType
        {
            Invalid = -2,
            Timeout = -1,
            Attack = 0,
            Item = 1,
            Switch = 2,
            Run = 3,
            UserAction = 20
        };
        
        typedef QList<QUuid> Targets;
        typedef QPair<QVariant, Targets> ActionData;
        typedef QPair<int, ActionData> Action;
        typedef QPair<TeamMember*, QFuture<Action> > RequestedAction;
        
        TeamMember(Sigscript::SpeciesWrapper* species, const int level, Team* team, const bool suppressInitialization = true);
        virtual ~TeamMember();
        
        virtual bool setContainment(Containment* containment);
        virtual bool setTeam(Team* team);
        Q_SCRIPTABLE Team* team() const;
        
        Q_SCRIPTABLE int statStage(const Sigmod::Stat stat) const;
        Q_SCRIPTABLE int statValue(const Sigmod::Stat stat) const;
    public slots:
        bool setStatStage(const Sigmod::Stat stat, const int stage);
        bool giveStatStages(const Sigmod::Stat stat, const int stages);
        
        bool addAbility(Sigscript::AbilityWrapper* ability);
        bool removeAbility(Sigscript::AbilityWrapper* ability);
        
        bool addItems(Sigscript::ItemWrapper* item, const int count, const bool allOrNothing = false);
        
        bool addMove(Sigscript::MoveWrapper* move);
        bool removeMove(Sigscript::MoveWrapper* move);
        
        bool addNature(Sigscript::NatureWrapper* nature);
        bool removeNature(Sigscript::NatureWrapper* nature);
        
        bool addStatus(Sigscript::StatusWrapper* status);
        bool removeStatus(Sigscript::StatusWrapper* status);
        
        virtual void makeActive(Arena* arena);
        virtual void exitArena();
    signals:
        void statStageChanged(const Sigmod::Stat stat, const int newStage);
    protected:
        virtual void makeConnections();
        
        Team* m_team;
        Arena* m_arena;
        
        int m_stages[Sigmod::ST_Evasion - Sigmod::ST_Attack + 1];
        
        Kross::ActionCollection* m_abilityBattleScripts;
        Kross::ActionCollection* m_abilityWorldScripts;
        Kross::ActionCollection* m_heldItemScripts;
        Kross::ActionCollection* m_moveBattleScripts;
        Kross::ActionCollection* m_moveWorldScripts;
        Kross::ActionCollection* m_statusBattleScripts;
        Kross::ActionCollection* m_statusWorldScripts;
        
        QMap<Sigscript::AbilityWrapper*, Kross::Action*> m_abilityBattleScriptsMap;
        QMap<Sigscript::AbilityWrapper*, Kross::Action*> m_abilityWorldScriptsMap;
        QMap<Sigscript::ItemWrapper*, Kross::Action*> m_heldItemsScriptsMap;
        QMap<Sigscript::MoveWrapper*, Kross::Action*> m_moveBattleScriptsMap;
        QMap<Sigscript::MoveWrapper*, Kross::Action*> m_moveWorldScriptsMap;
        QMap<Sigscript::StatusWrapper*, Kross::Action*> m_statusBattleScriptsMap;
        QMap<Sigscript::StatusWrapper*, Kross::Action*> m_statusWorldScriptsMap;
};

SIGENCORE_EXPORT int actionPriority(TeamMember* teamMember, const TeamMember::Action& action);

}
Q_DECLARE_METATYPE(Sigencore::TeamMember*)
Q_DECLARE_METATYPE(Sigencore::TeamMember::ActionType)
Q_DECLARE_METATYPE(Sigencore::TeamMember::Targets)
Q_DECLARE_METATYPE(Sigencore::TeamMember::ActionData)
Q_DECLARE_METATYPE(Sigencore::TeamMember::Action)
Q_DECLARE_METATYPE(Sigencore::TeamMember::RequestedAction)

#endif