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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
/*
* 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/Game.h
*/
#ifndef SIGMOD_GAME
#define SIGMOD_GAME
// Sigcore includes
#include <sigcore/Fraction.h>
#include <sigcore/Matrix.h>
#include <sigcore/Script.h>
// Sigmod includes
#include "Object.h"
#include "Subclass.h"
// Qt includes
#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QPoint>
namespace Sigmod
{
// Forward declarations
class Ability;
class Author;
class Badge;
class CoinList;
class EggGroup;
class GlobalScript;
class Item;
class ItemType;
class Map;
class Move;
class Nature;
class Rules;
class Skin;
class Sound;
class Specie;
class Sprite;
class Status;
class Store;
class Tile;
class Time;
class Trainer;
class Type;
class Weather;
/**
* \class Sigmod::Game Game.h sigmod/Game.h
* \brief Main class that describes a Sigmod.
*
* The Game class describes an entire set of objects for use with the game engine.
* Games will refuse to run if the \link Game::validate validate \endlink method
* returns any errors. Warnings will not stop the engine from running the Sigmod,
* but they should be minimized.
*/
class SIGMOD_EXPORT Game : public Object
{
Q_OBJECT
public:
typedef Subclass<Ability, Game> Abilities;
typedef Subclass<Author, Game> Authors;
typedef Subclass<Badge, Game> Badges;
typedef Subclass<CoinList, Game> CoinLists;
typedef Subclass<EggGroup, Game> EggGroups;
typedef Subclass<GlobalScript, Game> GlobalScripts;
typedef Subclass<Item, Game> Items;
typedef Subclass<ItemType, Game> ItemTypes;
typedef Subclass<Map, Game> Maps;
typedef Subclass<Move, Game> Moves;
typedef Subclass<Nature, Game> Natures;
typedef Subclass<Skin, Game> Skins;
typedef Subclass<Sound, Game> Sounds;
typedef Subclass<Specie, Game> Species;
typedef Subclass<Sprite, Game> Sprites;
typedef Subclass<Status, Game> Statuses;
typedef Subclass<Store, Game> Stores;
typedef Subclass<Tile, Game> Tiles;
typedef Subclass<Time, Game> Times;
typedef Subclass<Trainer, Game> Trainers;
typedef Subclass<Type, Game> Types;
typedef Subclass<Weather, Game> Weathers;
/**
* Default constructor.
*/
Game();
/**
* Copy constructor.
*
* \param sigmod The game to copy.
*/
Game(const Game& game);
/**
* XML data constructor.
*
* \param xml The XML structure to extract the data from.
*/
Game(const QDomElement& xml);
/**
* Destructor.
*/
~Game();
/**
* Check to make sure the game is 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 badge in XML format.
*
* \return The XML structure representing the badge.
*/
QDomElement save() const;
void setTitle(const QString& title);
void setVersion(const QString& version);
void setDescription(const QString& description);
void setSinglePlayer(const bool singlePlayer);
void setStartScript(const Sigcore::Script& startScript);
void setTypechart(const int attack, const int defense, const Sigcore::Fraction& multiplier);
void setMapPosition(const int map, const QPoint& position, const bool remove = false);
void setRules(const Rules& rules);
void setRules(const QDomElement& xml);
QString title() const;
QString version() const;
QString description() const;
bool singlePlayer() const;
Sigcore::Script startScript() const;
const Sigcore::Matrix<Sigcore::Fraction>& typechart() const;
Sigcore::Matrix<Sigcore::Fraction>& typechart();
Sigcore::Fraction typechart(const int attack, const int defense) const;
QPoint mapPosition(const int map) const;
QMap<int, QPoint> mapPosition() const;
const Rules* rules() const;
Rules* rules();
const Abilities& abilities() const;
Abilities& abilities();
const Authors& authors() const;
Authors& authors();
const Badges& badges() const;
Badges& badges();
const CoinLists& coinLists() const;
CoinLists& coinLists();
const EggGroups& eggGroups() const;
EggGroups& eggGroups();
const GlobalScripts& globalScripts() const;
GlobalScripts& globalScripts();
const Items& items() const;
Items& items();
const ItemTypes& itemTypes() const;
ItemTypes& itemTypes();
const Maps& maps() const;
Maps& maps();
const Moves& moves() const;
Moves& moves();
const Natures& natures() const;
Natures& natures();
const Skins& skins() const;
Skins& skins();
const Sounds& sounds() const;
Sounds& sounds();
const Species& species() const;
Species& species();
const Sprites& sprites() const;
Sprites& sprites();
const Statuses& statuses() const;
Statuses& statuses();
const Stores& stores() const;
Stores& stores();
const Tiles& tiles() const;
Tiles& tiles();
const Trainers& times() const;
Trainers& trainers();
const Types& types() const;
Types& types();
const Weathers& weathers() const;
Weathers& weathers();
bool titleCheck(const QString& title) const;
bool versionCheck(const QString& version) const;
bool descriptionCheck(const QString& description) const;
bool singlePlayerCheck(const bool singlePlayer) const;
bool startScriptCheck(const Sigcore::Script& startScript) const;
bool mapPositionCheck(const QPoint& position) const;
bool typechartCheck(const Sigcore::Fraction& multiplier) const;
Game& operator=(const Game& rhs);
private:
void clear();
void typeAdded(const int newSize);
void typeRemoved(const int index);
// FIXME: friend the class for callbacks
friend class Subclass<Type, Game>;
// friend Type* Subclass<Type, Game>::add(Type*);
// friend void Subclass<Type, Game>::deleteAt(const int);
QString m_title;
QString m_version;
QString m_description;
bool m_singlePlayer;
Sigcore::Script m_startScript;
Sigcore::Matrix<Sigcore::Fraction> m_typechart;
QMap<int, QPoint> m_mapPosition;
Rules* m_rules;
Abilities m_abilities;
Authors m_authors;
Badges m_badges;
CoinLists m_coinLists;
EggGroups m_eggGroups;
GlobalScripts m_globalScripts;
Items m_items;
ItemTypes m_itemTypes;
Maps m_maps;
Moves m_moves;
Natures m_natures;
Skins m_skins;
Sounds m_sounds;
Species m_species;
Sprites m_sprites;
Statuses m_statuses;
Stores m_stores;
Tiles m_tiles;
Times m_times;
Trainers m_trainers;
Types m_types;
Weathers m_weathers;
};
}
#endif
|