summaryrefslogtreecommitdiffstats
path: root/sigmod/MapTrainerTeamMember.h
blob: 25afdaef9fa368f6d229b25c85a8eeb8284d9e8d (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * 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/>.
 */

/**
 * \file sigmod/MapTrainerTeamMember.h
 */

#ifndef SIGMOD_MAPTRAINERTEAMMEMBER
#define SIGMOD_MAPTRAINERTEAMMEMBER

// Sigmod includes
#include "Object.h"

// Qt includes
#include <QtCore/QList>
#include <QtCore/QMap>

namespace Sigmod
{
// Forward dclarations
class MapTrainer;

/**
 * \class Sigmod::MapTrainerTeamMember MapTrainerTeamMember.h sigmod/MapTrainerTeamMember.h
 * \brief Class describing a team member on a trainer's team.
 * 
 * Each member of a trainer's team can be tuned to present specific challenges to a player.
 * If nothing is customized, or not fully customized, it will be completed with information
 * as a randomly encountered creature.
 */
class SIGMOD_EXPORT MapTrainerTeamMember : public Object
{
    Q_OBJECT
    
    public:
        /**
         * Copy constructor.
         * 
         * \param teamMember The team member to copy.
         */
        MapTrainerTeamMember(const MapTrainerTeamMember& teamMember);
        /**
         * Create a new team member belonging to \p parent and id \p id.
         * 
         * \param parent The parent of the team member.
         * \param id The id number for the team member.
         */
        MapTrainerTeamMember(const MapTrainer* parent, const int id);
        /**
         * Data copy constructor. Copies the data from \p teamMember as a child of \p parent with id \p id.
         * 
         * \param teamMember The team member to copy the data from.
         * \param parent The parent of the team member.
         * \param id The id number for the team member.
         */
        MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const MapTrainer* parent, const int id);
        /**
         * XML data constructor.
         * 
         * \param xml The XML structure to extract the data from.
         * \param parent The parent of the team member.
         * \param id The id number for the team member.
         */
        MapTrainerTeamMember(const QDomElement& xml, const MapTrainer* parent, const int id = -1);
        
        /**
         * Check to make sure the team member's values are valid.
         */
        void validate();
        
        /**
         * Load data from XML.
         * 
         * \param xml The XML structure to extract data from.
         */
        void load(const QDomElement& xml);
        /**
         * Get the data for the team member in XML format.
         * 
         * \return The XML structure representing the team member.
         */
        QDomElement save() const;
        
        /**
         * Sets the id of the species of the team member.
         * 
         * \param species The id of the species of the team member.
         */
        void setSpecies(const int species);
        /**
         * Sets the level of the team member.
         * 
         * \param level The level of the team member.
         */
        void setLevel(const int level);
        /**
         * Sets the state for the ability.
         * 
         * \param ability The id of the ability.
         * \param state Whether to turn the ability on or off.
         */
        void setAbility(const int ability, const bool state);
        /**
         * Sets the number of copies the team member holds of a certain item.
         * 
         * \param item The id of the item the team member is holding.
         * \param count The number of copies of \p item the team member holds.
         */
        void setItem(const int item, const int count);
        /**
         * Sets the state for the move.
         * 
         * \param move The id of the move.
         * \param state Whether to turn the move on or off.
         */
        void setMove(const int move, const bool state);
        /**
         * Sets the state for the nature.
         * 
         * \param nature The id of the nature.
         * \param state Whether to turn the nature on or off.
         */
        void setNature(const int nature, const bool state);
        
        /**
         * \sa setSpecies
         * 
         * \return The id of the species of the team member.
         */
        int species() const;
        /**
         * \sa setLevel
         * 
         * \return The level of the team member.
         */
        int level() const;
        /**
         * \sa setAbility
         * 
         * \param ability The id of the ability to check.
         * \return Whether the team member has the ability or not.
         */
        bool ability(const int ability) const;
        /**
         * \sa setAbility
         * 
         * \return The list of id of abilities the team member has.
         */
        QList<int> ability() const;
        /**
         * \sa setItem
         * 
         * \param item The id of the item to check for.
         * \return How many of the item the team member is carrying.
         */
        int item(const int item) const;
        /**
         * \sa setItem
         * 
         * \return The map of item ids to the amount the team member is carrying.
         */
        QMap<int, int> item() const;
        /**
         * \sa setMove
         * 
         * \param move The id of the move to check for.
         * \return Whether the team member knows the move or not.
         */
        bool move(const int move) const;
        /**
         * \sa setMove
         * 
         * \return The list of ids of moves the team member has.
         */
        QList<int> move() const;
        /**
         * \sa setNature
         * 
         * \param nature The id of the nature to check for.
         * \return Whether the team member has the nature or not.
         */
        bool nature(const int nature) const;
        /**
         * \sa setNature
         * 
         * \return The list of ids of natures the team member has.
         */
        QList<int> nature() const;
        
        bool speciesCheck(const int species) const;
        bool levelCheck(const int level) const;
        bool abilityCheck(const int ability) const;
        bool itemCheck(const int item, const int count) const;
        bool moveCheck(const int move) const;
        bool natureCheck(const int nature) const;

        MapTrainerTeamMember& operator=(const MapTrainerTeamMember& p);
    protected:
        // BUG: GCC bug #57 (template in default argument)
        // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57
        int heldWeight(const QMap<int, int>& items = (QMap<int, int>())) const;
        bool checkWeight(const int item, const int count) const;
        
        bool canLearn(const int move) const;
    private:
        void clear();
        
        int m_species;
        int m_level;
        QList<int> m_ability;
        QMap<int, int> m_item;
        QList<int> m_move;
        QList<int> m_nature;
};
}

#endif