summaryrefslogtreecommitdiffstats
path: root/pokemod/Pokemod.h
blob: 72e147bbb73fa7893f44f31166eade86240f296d (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
510
511
512
513
514
515
516
/*
 * 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 __POKEMOD_POKEMOD__
#define __POKEMOD_POKEMOD__

// Qt includes
#include <QList>
#include <QPixmap>
#include <QString>
#include <QStringList>

// General includes
#include <Exception.h>
#include <Frac.h>
#include <Matrix.h>
#include <Point.h>

// Pokemod includes
#include "Object.h"
#include "Rules.h"

// Forward declarations
class Ability;
class Author;
class Badge;
class CoinList;
class Dialog;
class EggGroup;
class Item;
class ItemType;
class Map;
class Move;
class Nature;
class Species;
class Store;
class Tile;
class Time;
class Trainer;
class Type;

class Pokemod : public Object
{
    public:
        enum Validation
        {
            V_Msg = 0,
            V_Warn = 1,
            V_Error = 2,
            V_End = 3
        };
        static const QStringList ValidationStr;
        
        enum Stat
        {
            ST_HP = 0,
            ST_Attack = 1,
            ST_Defense = 2,
            ST_Speed = 3,
            ST_Special = 4,
            ST_End_RBY = 5,
            ST_SpecialAttack = 4,
            ST_SpecialDefense = 5,
            ST_End_GSC = 6,
            ST_Accuracy = 6,
            ST_Evasion = 7,
            ST_End_Battle = 8,
        };
        static const QStringList StatRBYStr;
        static const QStringList StatGSCStr;

        enum BattleMember
        {
            BM_Player = 0,
            BM_Enemy = 1,
            BM_End = 2
        };
        static const QStringList BattleMemberStr;

        enum Weather
        {
            W_Ice = 0,
            W_Rain = 1,
            W_Sun = 2,
            W_Sand = 3,
            W_End_Real = 4,
            W_All = 4,
            W_End_All = 5
        };
        static const QStringList WeatherStr;

        enum Direction
        {
            D_Up = 0,
            D_Down = 1,
            D_Left = 2,
            D_Right = 3,
            D_End = 4,
            D_None = 4,
            D_End_None = 5
        };
        static const QStringList DirectionStr;

        enum Relative
        {
            REL_Less = 0,
            REL_LessOrEqual = 1,
            REL_GreaterOrEqual = 2,
            REL_Greater = 3,
            REL_Equal = 4,
            REL_NotEqual = 5,
            REL_End = 6
        };
        static const QStringList RelativeStr;

        enum Status
        {
            STS_Freeze = 0,
            STS_Paralyze = 1,
            STS_Sleep = 2,
            STS_Poison = 3,
            STS_ToxicPoison = 4,
            STS_Burn = 5,
            STS_Any = 6,
            STS_End = 7
        };
        static const QStringList StatusStr;

        enum HMMove
        {
            HM_Cut = 0,
            HM_Fly = 1,
            HM_Surf = 2,
            HM_Strength = 3,
            HM_Whirlpool = 4,
            HM_Waterfall = 5,
            HM_Dive = 6,
            HM_Headbutt = 7,
            HM_RockSmash = 8,
            HM_RockClimb = 9,
            HM_End = 10,
            HM_Defog = 10,
            HM_Flash = 11,
            HM_Heal = 12,
            HM_Escape = 13,
            HM_End_All = 14
        };
        static const QStringList HMStr;
        
        Pokemod();
        Pokemod(const Pokemod& pokemod);
        Pokemod(const QDomElement& xml);
        ~Pokemod();
        
        void load(const QDomElement& xml, const int = 0) throw(Exception);
        QDomElement save() const;
        
        int maxCompatability(const Pokemod& rhs) const;
        
        void validationMsg(const QString& msg, Validation val = V_Error) const throw(Exception);
        void setValOutput(QStringList& s);
        void unsetValOutput();
        
        void setTitle(const QString& title);
        void setVersion(const QString& version);
        void setDescription(const QString& description);
        void setStartMap(const int startMap) throw(BoundsException);
        void setStartWarp(const int startWarp) throw(BoundsException);
        void setWalkSkin(const QPixmap& walkSkin) throw(Exception);
        void setBikeSkin(const QPixmap& bikeSkin) throw(Exception);
        void setSurfSkin(const QPixmap& surfSkin) throw(Exception);
        void setFlySkin(const QPixmap& slySkin) throw(Exception);
        void setFishSkin(const QPixmap& fishSkin) throw(Exception);
        void setSurfFishSkin(const QPixmap& surfFishSkin) throw(Exception);
        void setSuperPCUname(const QString& username);
        void setSuperPCPasswd(const QString& password);
        void setTypeChart(const int attack, const int defense, const Frac& multiplier) throw(Exception);
        void setRules(const Rules& rules);
        void setRules(const QDomElement& xml);
        
        QString title() const;
        QString version() const;
        QString description() const;
        int startMap() const;
        int startWarp() const;
        QPixmap walkSkin() const;
        QPixmap bikeSkin() const;
        QPixmap surfSkin() const;
        QPixmap flySkin() const;
        QPixmap fishSkin() const;
        QPixmap surfFishSkin() const;
        QString superPCUname() const;
        QString superPCPasswd() const;
        const Matrix<Frac>* typeChart() const;
        Matrix<Frac>* typeChart();
        Frac typeChart(const int attack, const int defense) const;
        const Rules* rules() const;
        Rules* rules();
        
        const Ability* ability(const int index) const throw(IndexException);
        Ability* ability(const int index) throw(IndexException);
        const Ability* abilityById(const int id) const throw(IndexException);
        Ability* abilityById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteAbilityById(const int id) throw(IndexException);
        
        const Author* author(const int index) const throw(IndexException);
        Author* author(const int index) throw(IndexException);
        const Author* authorById(const int id) const throw(IndexException);
        Author* authorById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteAuthorById(const int id) throw(IndexException);
        
        const Badge* badge(const int index) const throw(IndexException);
        Badge* badge(const int index) throw(IndexException);
        const Badge* badgeById(const int id) const throw(IndexException);
        Badge* badgeById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteBadgeById(const int id) throw(IndexException);
        
        const CoinList* coinList(const int index) const throw(IndexException);
        CoinList* coinList(const int index) throw(IndexException);
        const CoinList* coinListById(const int id) const throw(IndexException);
        CoinList* coinListById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteCoinListById(const int id) throw(IndexException);
        
        const Dialog* dialog(const int index) const throw(IndexException);
        Dialog* dialog(const int index) throw(IndexException);
        const Dialog* dialogById(const int id) const throw(IndexException);
        Dialog* dialogById(const int id) throw(IndexException);
        int dialogIndex(const int id) const;
        int dialogCount() const;
        Dialog* newDialog();
        Dialog* newDialog(const QDomElement& xml);
        Dialog* newDialog(const Dialog& dialog);
        void deleteDialog(const int index) throw(IndexException);
        void deleteDialogById(const int id) throw(IndexException);
        
        const EggGroup* eggGroup(const int index) const throw(IndexException);
        EggGroup* eggGroup(const int index) throw(IndexException);
        const EggGroup* eggGroupById(const int id) const throw(IndexException);
        EggGroup* eggGroupById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteEggGroupById(const int id) throw(IndexException);
        
        const Item* item(const int index) const throw(IndexException);
        Item* item(const int index) throw(IndexException);
        const Item* itemById(const int id) const throw(IndexException);
        Item* itemById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteItemById(const int id) throw(IndexException);
        
        const ItemType* itemType(const int index) const throw(IndexException);
        ItemType* itemType(const int index) throw(IndexException);
        const ItemType* itemTypeById(const int id) const throw(IndexException);
        ItemType* itemTypeById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteItemTypeById(const int id) throw(IndexException);
        
        const Map* map(const int index) const throw(IndexException);
        Map* map(const int index) throw(IndexException);
        const Map* mapById(const int id) const throw(IndexException);
        Map* mapById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteMapById(const int id) throw(IndexException);
        
        const Move* move(const int index) const throw(IndexException);
        Move* move(const int index) throw(IndexException);
        const Move* moveById(const int id) const throw(IndexException);
        Move* moveById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteMoveById(const int id) throw(IndexException);
        
        const Nature* nature(const int index) const throw(IndexException);
        Nature* nature(const int index) throw(IndexException);
        const Nature* natureById(const int id) const throw(IndexException);
        Nature* natureById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteNatureById(const int id) throw(IndexException);
        
        const Species* species(const int index) const throw(IndexException);
        Species* species(const int index) throw(IndexException);
        const Species* speciesById(const int id) const throw(IndexException);
        Species* speciesById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteSpeciesById(const int id) throw(IndexException);
        
        const Store* store(const int index) const throw(IndexException);
        Store* store(const int index) throw(IndexException);
        const Store* storeById(const int id) const throw(IndexException);
        Store* storeById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteStoreById(const int id) throw(IndexException);
        
        const Tile* tile(const int index) const throw(IndexException);
        Tile* tile(const int index) throw(IndexException);
        const Tile* tileById(const int id) const throw(IndexException);
        Tile* tileById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteTileById(const int id) throw(IndexException);
        
        const Time* time(const int index) const throw(IndexException);
        Time* time(const int index) throw(IndexException);
        const Time* timeById(const int id) const throw(IndexException);
        Time* timeById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteTimeById(const int id) throw(IndexException);
        
        const Trainer* trainer(const int index) const throw(IndexException);
        Trainer* trainer(const int index) throw(IndexException);
        const Trainer* trainerById(const int id) const throw(IndexException);
        Trainer* trainerById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteTrainerById(const int id) throw(IndexException);
        
        const Type* type(const int index) const throw(IndexException);
        Type* type(const int index) throw(IndexException);
        const Type* typeById(const int id) const throw(IndexException);
        Type* typeById(const int id) throw(IndexException);
        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) throw(IndexException);
        void deleteTypeById(const int id) throw(IndexException);
        
        Pokemod& operator=(const Pokemod& rhs);
    private:
        QStringList* valOutput;
        
        bool validate() const;
        int newAbilityId() const;
        int newAuthorId() const;
        int newBadgeId() const;
        int newCoinListId() const;
        int newDialogId() const;
        int newEggGroupId() const;
        int newItemId() const;
        int newItemTypeId() const;
        int newMapId() const;
        int newMoveId() const;
        int newNatureId() const;
        int newSpeciesId() const;
        int newStoreId() const;
        int newTileId() const;
        int newTimeId() const;
        int newTrainerId() const;
        int newTypeId() const;
        void clear()
        {
            while (abilityCount())
                deleteAbility(0);
            while (authorCount())
                deleteAuthor(0);
            while (badgeCount())
                deleteBadge(0);
            while (coinListCount())
                deleteCoinList(0);
            while (dialogCount())
                deleteDialog(0);
            while (eggGroupCount())
                deleteEggGroup(0);
            while (itemCount())
                deleteItem(0);
            while (itemTypeCount())
                deleteItemType(0);
            while (mapCount())
                deleteMap(0);
            while (moveCount())
                deleteMove(0);
            while (natureCount())
                deleteNature(0);
            while (speciesCount())
                deleteSpecies(0);
            while (storeCount())
                deleteStore(0);
            while (tileCount())
                deleteTile(0);
            while (timeCount())
                deleteTime(0);
            while (trainerCount())
                deleteTrainer(0);
            while (typeCount())
                deleteType(0);
        }
        
        void copyDir(const QString& src, const QString& dest) const;
        
        QString m_title;
        QString m_version;
        QString m_description;
        int m_startMap;
        int m_startWarp;
        QPixmap m_walkSkin;
        QPixmap m_bikeSkin;
        QPixmap m_surfSkin;
        QPixmap m_flySkin;
        QPixmap m_fishSkin;
        QPixmap m_surfFishSkin;
        QString m_superPCUname;
        QString m_superPCPasswd;
        Matrix<Frac> m_typeChart;
        Rules m_rules;
        QList<Ability*> m_abilities;
        QList<Author*> m_authors;
        QList<Badge*> m_badges;
        QList<CoinList*> m_coinLists;
        QList<Dialog*> m_dialogs;
        QList<EggGroup*> m_eggGroups;
        QList<Item*> m_items;
        QList<ItemType*> m_itemTypes;
        QList<Map*> m_maps;
        QList<Move*> m_moves;
        QList<Nature*> m_natures;
        QList<Species*> m_species;
        QList<Store*> m_stores;
        QList<Tile*> m_tiles;
        QList<Time*> m_times;
        QList<Trainer*> m_trainers;
        QList<Type*> m_types;
        
        QString m_path;
};

#endif