summaryrefslogtreecommitdiffstats
path: root/sigmod/Game.h
blob: 1d39a02e10b1f42921fd400b91078a1f9696671b (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
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/*
 * 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"

// Qt includes
#include <QtCore/QList>

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 Species;
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:
        /**
         * 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 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;
        const Rules* rules() const;
        Rules* rules();
        
        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 typechartCheck(const Sigcore::Fraction& multiplier) const;
        
        const Ability* ability(const int index) const;
        Ability* ability(const int index);
        const Ability* abilityById(const int id) const;
        Ability* abilityById(const int id);
        int abilityIndex(const int id) const;
        int abilityCount() const;
        Ability* newAbility();
        Ability* newAbility(const QDomElement& xml);
        Ability* newAbility(const Ability& ability);
        void deleteAbility(const int index);
        void deleteAbilityById(const int id);
        
        const Author* author(const int index) const;
        Author* author(const int index);
        const Author* authorById(const int id) const;
        Author* authorById(const int id);
        int authorIndex(const int id) const;
        int authorCount() const;
        Author* newAuthor();
        Author* newAuthor(const QDomElement& xml);
        Author* newAuthor(const Author& author);
        void deleteAuthor(const int index);
        void deleteAuthorById(const int id);
        
        const Badge* badge(const int index) const;
        Badge* badge(const int index);
        const Badge* badgeById(const int id) const;
        Badge* badgeById(const int id);
        int badgeIndex(const int id) const;
        int badgeCount() const;
        Badge* newBadge();
        Badge* newBadge(const QDomElement& xml);
        Badge* newBadge(const Badge& badge);
        void deleteBadge(const int index);
        void deleteBadgeById(const int id);
        
        const CoinList* coinList(const int index) const;
        CoinList* coinList(const int index);
        const CoinList* coinListById(const int id) const;
        CoinList* coinListById(const int id);
        int coinListIndex(const int id) const;
        int coinListCount() const;
        CoinList* newCoinList();
        CoinList* newCoinList(const QDomElement& xml);
        CoinList* newCoinList(const CoinList& coinList);
        void deleteCoinList(const int index);
        void deleteCoinListById(const int id);
        
        const EggGroup* eggGroup(const int index) const;
        EggGroup* eggGroup(const int index);
        const EggGroup* eggGroupById(const int id) const;
        EggGroup* eggGroupById(const int id);
        int eggGroupIndex(const int id) const;
        int eggGroupCount() const;
        EggGroup* newEggGroup();
        EggGroup* newEggGroup(const QDomElement& xml);
        EggGroup* newEggGroup(const EggGroup& eggGroup);
        void deleteEggGroup(const int index);
        void deleteEggGroupById(const int id);
        
        const GlobalScript* globalScript(const int index) const;
        GlobalScript* globalScript(const int index);
        const GlobalScript* globalScriptById(const int id) const;
        GlobalScript* globalScriptById(const int id);
        int globalScriptIndex(const int id) const;
        int globalScriptCount() const;
        GlobalScript* newGlobalScript();
        GlobalScript* newGlobalScript(const QDomElement& xml);
        GlobalScript* newGlobalScript(const GlobalScript& globalScript);
        void deleteGlobalScript(const int index);
        void deleteGlobalScriptById(const int id);
        
        const Item* item(const int index) const;
        Item* item(const int index);
        const Item* itemById(const int id) const;
        Item* itemById(const int id);
        int itemIndex(const int id) const;
        int itemCount() const;
        Item* newItem();
        Item* newItem(const QDomElement& xml);
        Item* newItem(const Item& item);
        void deleteItem(const int index);
        void deleteItemById(const int id);
        
        const ItemType* itemType(const int index) const;
        ItemType* itemType(const int index);
        const ItemType* itemTypeById(const int id) const;
        ItemType* itemTypeById(const int id);
        int itemTypeIndex(const int id) const;
        int itemTypeCount() const;
        ItemType* newItemType();
        ItemType* newItemType(const QDomElement& xml);
        ItemType* newItemType(const ItemType& itemType);
        void deleteItemType(const int index);
        void deleteItemTypeById(const int id);
        
        const Map* map(const int index) const;
        Map* map(const int index);
        const Map* mapById(const int id) const;
        Map* mapById(const int id);
        int mapIndex(const int id) const;
        int mapCount() const;
        Map* newMap();
        Map* newMap(const QDomElement& xml);
        Map* newMap(const Map& map);
        void deleteMap(const int index);
        void deleteMapById(const int id);
        
        const Move* move(const int index) const;
        Move* move(const int index);
        const Move* moveById(const int id) const;
        Move* moveById(const int id);
        int moveIndex(const int id) const;
        int moveCount() const;
        Move* newMove();
        Move* newMove(const QDomElement& xml);
        Move* newMove(const Move& move);
        void deleteMove(const int index);
        void deleteMoveById(const int id);
        
        const Nature* nature(const int index) const;
        Nature* nature(const int index);
        const Nature* natureById(const int id) const;
        Nature* natureById(const int id);
        int natureIndex(const int id) const;
        int natureCount() const;
        Nature* newNature();
        Nature* newNature(const QDomElement& xml);
        Nature* newNature(const Nature& nature);
        void deleteNature(const int index);
        void deleteNatureById(const int id);
        
        const Skin* skin(const int index) const;
        Skin* skin(const int index);
        const Skin* skinById(const int id) const;
        Skin* skinById(const int id);
        int skinIndex(const int id) const;
        int skinCount() const;
        Skin* newSkin();
        Skin* newSkin(const QDomElement& xml);
        Skin* newSkin(const Skin& status);
        void deleteSkin(const int index);
        void deleteSkinById(const int id);
        
        const Sound* sound(const int index) const;
        Sound* sound(const int index);
        const Sound* soundById(const int id) const;
        Sound* soundById(const int id);
        int soundIndex(const int id) const;
        int soundCount() const;
        Sound* newSound();
        Sound* newSound(const QDomElement& xml);
        Sound* newSound(const Sound& sound);
        void deleteSound(const int index);
        void deleteSoundById(const int id);
        
        const Species* species(const int index) const;
        Species* species(const int index);
        const Species* speciesById(const int id) const;
        Species* speciesById(const int id);
        int speciesIndex(const int id) const;
        int speciesCount() const;
        Species* newSpecies();
        Species* newSpecies(const QDomElement& xml);
        Species* newSpecies(const Species& species);
        void deleteSpecies(const int index);
        void deleteSpeciesById(const int id);
        
        const Sprite* sprite(const int index) const;
        Sprite* sprite(const int index);
        const Sprite* spriteById(const int id) const;
        Sprite* spriteById(const int id);
        int spriteIndex(const int id) const;
        int spriteCount() const;
        Sprite* newSprite();
        Sprite* newSprite(const QDomElement& xml);
        Sprite* newSprite(const Sprite& sprite);
        void deleteSprite(const int index);
        void deleteSpriteById(const int id);
        
        const Status* status(const int index) const;
        Status* status(const int index);
        const Status* statusById(const int id) const;
        Status* statusById(const int id);
        int statusIndex(const int id) const;
        int statusCount() const;
        Status* newStatus();
        Status* newStatus(const QDomElement& xml);
        Status* newStatus(const Status& status);
        void deleteStatus(const int index);
        void deleteStatusById(const int id);
        
        const Store* store(const int index) const;
        Store* store(const int index);
        const Store* storeById(const int id) const;
        Store* storeById(const int id);
        int storeIndex(const int id) const;
        int storeCount() const;
        Store* newStore();
        Store* newStore(const QDomElement& xml);
        Store* newStore(const Store& store);
        void deleteStore(const int index);
        void deleteStoreById(const int id);
        
        const Tile* tile(const int index) const;
        Tile* tile(const int index);
        const Tile* tileById(const int id) const;
        Tile* tileById(const int id);
        int tileIndex(const int id) const;
        int tileCount() const;
        Tile* newTile();
        Tile* newTile(const QDomElement& xml);
        Tile* newTile(const Tile& tile);
        void deleteTile(const int index);
        void deleteTileById(const int id);
        
        const Time* time(const int index) const;
        Time* time(const int index);
        const Time* timeById(const int id) const;
        Time* timeById(const int id);
        int timeIndex(const int id) const;
        int timeCount() const;
        Time* newTime();
        Time* newTime(const QDomElement& xml);
        Time* newTime(const Time& time);
        void deleteTime(const int index);
        void deleteTimeById(const int id);
        
        const Trainer* trainer(const int index) const;
        Trainer* trainer(const int index);
        const Trainer* trainerById(const int id) const;
        Trainer* trainerById(const int id);
        int trainerIndex(const int id) const;
        int trainerCount() const;
        Trainer* newTrainer();
        Trainer* newTrainer(const QDomElement& xml);
        Trainer* newTrainer(const Trainer& trainer);
        void deleteTrainer(const int index);
        void deleteTrainerById(const int id);
        
        const Type* type(const int index) const;
        Type* type(const int index);
        const Type* typeById(const int id) const;
        Type* typeById(const int id);
        int typeIndex(const int id) const;
        int typeCount() const;
        Type* newType();
        Type* newType(const QDomElement& xml);
        Type* newType(const Type& type);
        void deleteType(const int index);
        void deleteTypeById(const int id);
        
        const Weather* weather(const int index) const;
        Weather* weather(const int index);
        const Weather* weatherById(const int id) const;
        Weather* weatherById(const int id);
        int weatherIndex(const int id) const;
        int weatherCount() const;
        Weather* newWeather();
        Weather* newWeather(const QDomElement& xml);
        Weather* newWeather(const Weather& weather);
        void deleteWeather(const int index);
        void deleteWeatherById(const int id);
        
        Game& operator=(const Game& rhs);
    private:
        int newAbilityId() const;
        Ability* newAbility(Ability* ability);
        
        int newAuthorId() const;
        Author* newAuthor(Author* author);
        
        int newBadgeId() const;
        Badge* newBadge(Badge* badge);
        
        int newCoinListId() const;
        CoinList* newCoinList(CoinList* coinList);
        
        int newEggGroupId() const;
        EggGroup* newEggGroup(EggGroup* eggGroup);
        
        int newItemId() const;
        Item* newItem(Item* item);
        
        int newItemTypeId() const;
        ItemType* newItemType(ItemType* itemType);
        
        int newMapId() const;
        Map* newMap(Map* map);
        
        int newMoveId() const;
        Move* newMove(Move* move);
        
        int newNatureId() const;
        Nature* newNature(Nature* nature);
        
        int newGlobalScriptId() const;
        GlobalScript* newGlobalScript(GlobalScript* globalScript);
        
        int newSkinId() const;
        Skin* newSkin(Skin* skin);
        
        int newSoundId() const;
        Sound* newSound(Sound* sound);
        
        int newSpeciesId() const;
        Species* newSpecies(Species* species);
        
        int newSpriteId() const;
        Sprite* newSprite(Sprite* sprite);
        
        int newStatusId() const;
        Status* newStatus(Status* status);
        
        int newStoreId() const;
        Store* newStore(Store* store);
        
        int newTileId() const;
        Tile* newTile(Tile* tile);
        
        int newTimeId() const;
        Time* newTime(Time* time);
        
        int newTrainerId() const;
        Trainer* newTrainer(Trainer* trainer);
        
        int newTypeId() const;
        Type* newType(Type* type);
        
        int newWeatherId() const;
        Weather* newWeather(Weather* weather);
        
        void clear();
        
        QString m_title;
        QString m_version;
        QString m_description;
        bool m_singlePlayer;
        Sigcore::Script m_startScript;
        Sigcore::Matrix<Sigcore::Fraction> m_typechart;
        Rules* m_rules;
        QList<Ability*> m_abilities;
        QList<Author*> m_authors;
        QList<Badge*> m_badges;
        QList<CoinList*> m_coinLists;
        QList<EggGroup*> m_eggGroups;
        QList<GlobalScript*> m_globalScripts;
        QList<Item*> m_items;
        QList<ItemType*> m_itemTypes;
        QList<Map*> m_maps;
        QList<Move*> m_moves;
        QList<Nature*> m_natures;
        QList<Skin*> m_skins;
        QList<Sound*> m_sounds;
        QList<Species*> m_species;
        QList<Sprite*> m_sprites;
        QList<Status*> m_status;
        QList<Store*> m_stores;
        QList<Tile*> m_tiles;
        QList<Time*> m_times;
        QList<Trainer*> m_trainers;
        QList<Type*> m_types;
        QList<Weather*> m_weathers;
};
}

#endif