summaryrefslogtreecommitdiffstats
path: root/sigmod/Species.h
blob: 7ea1bf1b07194244677b34e7a37c32cf79380981 (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
/*
 * 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 __SIGMOD_SPECIES__
#define __SIGMOD_SPECIES__

// Sigmod includes
#include "Fraction.h"
#include "Object.h"
#include "Script.h"

// Qt includes
#include <QtCore/QList>

namespace Sigmod
{
// Forward declarations
class Sigmod;
class SpeciesAbility;
class SpeciesItem;
class SpeciesMove;

class SIGMOD_EXPORT Species : public Object
{
    Q_OBJECT
    Q_ENUMS(Style)
    
    public:
        enum Style
        {
            Fluctuating = 0,
            Fading = 1,
            Slow = 2,
            Normal = 3,
            Fast = 4,
            Erratic = 5
        };
        static const QStringList StyleStr;
        
        Species(const Species& species);
        Species(const Sigmod* parent, const int id);
        Species(const Species& species, const Sigmod* parent, const int id);
        Species(const QDomElement& xml, const Sigmod* parent, const int id = -1);
        ~Species();
        
        void validate();
        
        void load(const QDomElement& xml);
        QDomElement save() const;
        
        void setName(const QString& name);
        void setBaseStat(const Stat stat, const int base);
        void setEffortValue(const Stat stat, const int effortValue);
        void setGrowth(const Style growth);
        void setExperienceValue(const int experienceValue);
        void setCatchValue(const int catchValue);
        void setRunChance(const Fraction& runChance);
        void setFleeChance(const Fraction& fleeChance);
        void setItemChance(const Fraction& itemChance);
        void setEncyclopediaNumber(const int encyclopediaNumber);
        void setWeight(const int weight);
        void setHeight(const int height);
        void setEncyclopediaEntry(const QString& encyclopediaEntry);
        void setFrontMaleSprite(const int frontMaleSprite);
        void setBackMaleSprite(const int backMaleSprite);
        void setFrontFemaleSprite(const int frontFemaleSprite);
        void setBackFemaleSprite(const int backFemaleSprite);
        void setGenderFactor(const Fraction& genderFactor);
        void setSkin(const int skin);
        void setEggSpecies(const int eggSpecies);
        void setEggSteps(const int eggSteps);
        void setType(const int type, const bool state);
        void setEggGroup(const int eggGroup, const bool state);
        void setEvolution(const Script& evolution);
        
        QString name() const;
        int baseStat(const Stat stat) const;
        int effortValue(const Stat stat) const;
        Style growth() const;
        int experienceValue() const;
        int catchValue() const;
        Fraction runChance() const;
        Fraction fleeChance() const;
        Fraction itemChance() const;
        int encyclopediaNumber() const;
        int weight() const;
        int height() const;
        QString encyclopediaEntry() const;
        int frontMaleSprite() const;
        int backMaleSprite() const;
        int frontFemaleSprite() const;
        int backFemaleSprite() const;
        int skin() const;
        Fraction genderFactor() const;
        int eggSpecies() const;
        int eggSteps() const;
        bool type(const int type) const;
        QList<int> types() const;
        bool eggGroup(const int eggGroup) const;
        QList<int> eggGroups() const;
        Script evolution() const;
        
        const SpeciesAbility* ability(const int index) const;
        SpeciesAbility* ability(const int index);
        const SpeciesAbility* abilityById(const int id) const;
        SpeciesAbility* abilityById(const int id);
        int abilityIndex(const int id) const;
        int abilityCount() const;
        SpeciesAbility* newAbility();
        SpeciesAbility* newAbility(const QDomElement& xml);
        SpeciesAbility* newAbility(const SpeciesAbility& ability);
        void deleteAbility(const int index);
        void deleteAbilityById(const int id);
        
        const SpeciesItem* item(const int index) const;
        SpeciesItem* item(const int index);
        const SpeciesItem* itemById(const int i) const;
        SpeciesItem* itemById(const int i);
        int itemIndex(const int id) const;
        int itemCount() const;
        SpeciesItem* newItem();
        SpeciesItem* newItem(const QDomElement& xml);
        SpeciesItem* newItem(const SpeciesItem& item);
        void deleteItem(const int index);
        void deleteItemById(const int id);
        
        const SpeciesMove* move(const int index) const;
        SpeciesMove* move(const int index);
        const SpeciesMove* moveById(const int id) const;
        SpeciesMove* moveById(const int id);
        int moveIndex(const int id) const;
        int moveCount() const;
        SpeciesMove* newMove();
        SpeciesMove* newMove(const QDomElement& xml);
        SpeciesMove* newMove(const SpeciesMove& move);
        void deleteMove(const int index);
        void deleteMoveById(const int id);
        
        Species& operator=(const Species& rhs);
    private:
        void setEffortValue(const int effortValue);
        
        int newAbilityId() const;
        SpeciesAbility* newAbility(SpeciesAbility* ability);
        
        int newItemId() const;
        SpeciesItem* newItem(SpeciesItem* item);
        
        int newMoveId() const;
        SpeciesMove* newMove(SpeciesMove* move);
        
        void clear();
        
        QString m_name;
        QVarLengthArray<bool, ST_End_GSC> m_baseStat;
        QVarLengthArray<bool, ST_End_GSC> m_effortValue;
        Style m_growth;
        int m_experienceValue;
        int m_catchValue;
        Fraction m_runChance;
        Fraction m_fleeChance;
        Fraction m_itemChance;
        int m_encyclopediaNumber;
        int m_weight;
        int m_height;
        int m_frontMaleSprite;
        int m_backMaleSprite;
        int m_frontFemaleSprite;
        int m_backFemaleSprite;
        int m_skin;
        QString m_encyclopediaEntry;
        Fraction m_genderFactor;
        int m_eggSpecies;
        int m_eggSteps;
        QList<int> m_type;
        QList<int> m_eggGroup;
        Script m_evolution;
        QList<SpeciesAbility*> m_abilities;
        QList<SpeciesItem*> m_items;
        QList<SpeciesMove*> m_moves;
};
}
Q_DECLARE_METATYPE(Sigmod::Species::Style)

#endif