summaryrefslogtreecommitdiffstats
path: root/sigscript/GameWrapper.cpp
blob: 82355b44a7e9dae04daa48cfab0907a6a0166a0a (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
/*
 * Copyright 2008-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/>.
 */

// Header include
#include "GameWrapper.h"

// Sigscript includes
#include "AbilityWrapper.h"
#include "AuthorWrapper.h"
#include "BadgeWrapper.h"
#include "CoinListWrapper.h"
#include "EggGroupWrapper.h"
#include "GlobalScriptWrapper.h"
#include "ItemWrapper.h"
#include "ItemTypeWrapper.h"
#include "MapWrapper.h"
#include "MapWarpWrapper.h"
#include "MoveWrapper.h"
#include "NatureWrapper.h"
#include "RulesWrapper.h"
#include "SkinWrapper.h"
#include "SoundWrapper.h"
#include "SpeciesWrapper.h"
#include "SpriteWrapper.h"
#include "StatusWrapper.h"
#include "StoreWrapper.h"
#include "TileWrapper.h"
#include "TimeWrapper.h"
#include "TrainerWrapper.h"
#include "TypeWrapper.h"
#include "WeatherWrapper.h"

// Sigmod includes
#include <sigmod/Ability.h>
#include <sigmod/Author.h>
#include <sigmod/Badge.h>
#include <sigmod/CoinList.h>
#include <sigmod/EggGroup.h>
#include <sigmod/Game.h>
#include <sigmod/GlobalScript.h>
#include <sigmod/Item.h>
#include <sigmod/Move.h>
#include <sigmod/Nature.h>
#include <sigmod/Store.h>
#include <sigmod/Skin.h>
#include <sigmod/Sprite.h>
#include <sigmod/Status.h>
#include <sigmod/Tile.h>
#include <sigmod/Time.h>
#include <sigmod/Type.h>
#include <sigmod/Weather.h>

using namespace Sigcore;
using namespace Sigmod;
using namespace Sigscript;

GameWrapper::GameWrapper(const Game* game) :
        ObjectWrapper(game, NULL),
        m_game(game)
{
}

Hat<NatureWrapper*> GameWrapper::natureHat()
{
    Hat<NatureWrapper*> hat;
    for (int i = 0; i < m_game->natureCount(); ++i)
    {
        NatureWrapper* nature = NatureWrapper::create(m_game->nature(i), this);
        hat.add(nature, nature->weight());
    }
    return hat;
}

AbilityWrapper* GameWrapper::ability(const int id)
{
    return AbilityWrapper::create(m_game->abilityById(id), this);
}

AuthorWrapper* GameWrapper::author(const int id)
{
    return AuthorWrapper::create(m_game->authorById(id), this);
}

BadgeWrapper* GameWrapper::badge(const int id)
{
    return BadgeWrapper::create(m_game->badgeById(id), this);
}

CoinListWrapper* GameWrapper::coinList(const int id)
{
    return CoinListWrapper::create(m_game->coinListById(id), this);
}

EggGroupWrapper* GameWrapper::eggGroup(const int id)
{
    return EggGroupWrapper::create(m_game->eggGroupById(id), this);
}

GlobalScriptWrapper* GameWrapper::globalScript(const int id)
{
    return GlobalScriptWrapper::create(m_game->globalScriptById(id), this);
}

ItemWrapper* GameWrapper::item(const int id)
{
    return ItemWrapper::create(m_game->itemById(id), this);
}

ItemTypeWrapper* GameWrapper::itemType(const int id)
{
    return ItemTypeWrapper::create(m_game->itemTypeById(id), this);
}

MapWrapper* GameWrapper::map(const int id)
{
    return MapWrapper::create(m_game->mapById(id), this);
}

MoveWrapper* GameWrapper::move(const int id)
{
    return MoveWrapper::create(m_game->moveById(id), this);
}

NatureWrapper* GameWrapper::nature(const int id)
{
    return NatureWrapper::create(m_game->natureById(id), this);
}

SkinWrapper* GameWrapper::skin(const int id)
{
    return SkinWrapper::create(m_game->skinById(id), this);
}

SoundWrapper* GameWrapper::sound(const int id)
{
    return SoundWrapper::create(m_game->soundById(id), this);
}

SpeciesWrapper* GameWrapper::species(const int id)
{
    return SpeciesWrapper::create(m_game->speciesById(id), this);
}

SpriteWrapper* GameWrapper::sprite(const int id)
{
    return SpriteWrapper::create(m_game->spriteById(id), this);
}

StatusWrapper* GameWrapper::status(const int id)
{
    return StatusWrapper::create(m_game->statusById(id), this);
}

StoreWrapper* GameWrapper::store(const int id)
{
    return StoreWrapper::create(m_game->storeById(id), this);
}

TileWrapper* GameWrapper::tile(const int id)
{
    return TileWrapper::create(m_game->tileById(id), this);
}

TimeWrapper* GameWrapper::time(const int id)
{
    return TimeWrapper::create(m_game->timeById(id), this);
}

TrainerWrapper* GameWrapper::trainer(const int id)
{
    return TrainerWrapper::create(m_game->trainerById(id), this);
}

TypeWrapper* GameWrapper::type(const int id)
{
    return TypeWrapper::create(m_game->typeById(id), this);
}

WeatherWrapper* GameWrapper::weather(const int id)
{
    return WeatherWrapper::create(m_game->weatherById(id), this);
}

Stat GameWrapper::stat(const QString& name) const
{
    if (name == "HP")
        return ST_HP;
    else if (name == "Attack")
        return ST_Attack;
    else if (name == "Defense")
        return ST_Defense;
    else if (name == "Speed")
        return ST_Speed;
    else if (name == "Special")
        return ST_Special;
    else if (name == "Special Attack")
        return ST_SpecialAttack;
    else if (name == "Special Defense")
        return ST_SpecialAttack;
    else if (name == "Accuracy")
        return ST_Accuracy;
    else if (name == "Evasion")
        return ST_Evasion;
    return QVariant(-1).value<Stat>();
}

Direction GameWrapper::direction(const QString& name) const
{
    if (name == "Up")
        return D_Up;
    else if (name == "Down")
        return D_Down;
    else if (name == "Left")
        return D_Left;
    else if (name == "Right")
        return D_Right;
    else if (name == "None")
        return D_None;
    return QVariant(-1).value<Direction>();
}

QString GameWrapper::title() const
{
    return m_game->title();
}

QString GameWrapper::version() const
{
    return m_game->version();
}

QString GameWrapper::description() const
{
    return m_game->description();
}

bool GameWrapper::singlePlayer() const
{
    return m_game->singlePlayer();
}

Script GameWrapper::startScript()
{
    return m_game->startScript();
}

Fraction GameWrapper::effectiveness(const TypeWrapper* attacker, const TypeWrapper* defender) const
{
    return m_game->typechart(m_game->typeIndex(attacker->id()), m_game->typeIndex(defender->id()));
}

QPoint GameWrapper::mapPosition(const MapWrapper* map) const
{
    return m_game->mapPosition(map->id());
}

RulesWrapper* GameWrapper::rules()
{
    return RulesWrapper::create(m_game->rules(), this);
}

AbilityWrapper* GameWrapper::ability(const QString& name)
{
    for (int i = 0; i < m_game->abilityCount(); ++i)
    {
        if (m_game->ability(i)->name() == name)
            return AbilityWrapper::create(m_game->ability(i), this);
    }
    return NULL;
}

AuthorWrapper* GameWrapper::author(const QString& name)
{
    for (int i = 0; i < m_game->authorCount(); ++i)
    {
        if (m_game->author(i)->name() == name)
            return AuthorWrapper::create(m_game->author(i), this);
    }
    return NULL;
}

BadgeWrapper* GameWrapper::badge(const QString& name)
{
    for (int i = 0; i < m_game->badgeCount(); ++i)
    {
        if (m_game->badge(i)->name() == name)
            return BadgeWrapper::create(m_game->badge(i), this);
    }
    return NULL;
}

CoinListWrapper* GameWrapper::coinList(const QString& name)
{
    for (int i = 0; i < m_game->coinListCount(); ++i)
    {
        if (m_game->coinList(i)->name() == name)
            return CoinListWrapper::create(m_game->coinList(i), this);
    }
    return NULL;
}

EggGroupWrapper* GameWrapper::eggGroup(const QString& name)
{
    for (int i = 0; i < m_game->eggGroupCount(); ++i)
    {
        if (m_game->eggGroup(i)->name() == name)
            return EggGroupWrapper::create(m_game->eggGroup(i), this);
    }
    return NULL;
}

GlobalScriptWrapper* GameWrapper::globalScript(const QString& name)
{
    for (int i = 0; i < m_game->globalScriptCount(); ++i)
    {
        if (m_game->globalScript(i)->name() == name)
            return GlobalScriptWrapper::create(m_game->globalScript(i), this);
    }
    return NULL;
}

ItemWrapper* GameWrapper::item(const QString& name)
{
    for (int i = 0; i < m_game->itemCount(); ++i)
    {
        if (m_game->item(i)->name() == name)
            return ItemWrapper::create(m_game->item(i), this);
    }
    return NULL;
}

ItemTypeWrapper* GameWrapper::itemType(const QString& name)
{
    for (int i = 0; i < m_game->itemTypeCount(); ++i)
    {
        if (m_game->itemType(i)->name() == name)
            return ItemTypeWrapper::create(m_game->itemType(i), this);
    }
    return NULL;
}

MapWrapper* GameWrapper::map(const QString& name)
{
    for (int i = 0; i < m_game->mapCount(); ++i)
    {
        if (m_game->map(i)->name() == name)
            return MapWrapper::create(m_game->map(i), this);
    }
    return NULL;
}

MoveWrapper* GameWrapper::move(const QString& name)
{
    for (int i = 0; i < m_game->moveCount(); ++i)
    {
        if (m_game->move(i)->name() == name)
            return MoveWrapper::create(m_game->move(i), this);
    }
    return NULL;
}

NatureWrapper* GameWrapper::nature(const QString& name)
{
    for (int i = 0; i < m_game->natureCount(); ++i)
    {
        if (m_game->nature(i)->name() == name)
            return NatureWrapper::create(m_game->nature(i), this);
    }
    return NULL;
}

SkinWrapper* GameWrapper::skin(const QString& name)
{
    for (int i = 0; i < m_game->skinCount(); ++i)
    {
        if (m_game->skin(i)->name() == name)
            return SkinWrapper::create(m_game->skin(i), this);
    }
    return NULL;
}

SoundWrapper* GameWrapper::sound(const QString& name)
{
    for (int i = 0; i < m_game->soundCount(); ++i)
    {
        if (m_game->sound(i)->name() == name)
            return SoundWrapper::create(m_game->sound(i), this);
    }
    return NULL;
}

SpeciesWrapper* GameWrapper::species(const QString& name)
{
    for (int i = 0; i < m_game->speciesCount(); ++i)
    {
        if (m_game->species(i)->name() == name)
            return SpeciesWrapper::create(m_game->species(i), this);
    }
    return NULL;
}

SpriteWrapper* GameWrapper::sprite(const QString& name)
{
    for (int i = 0; i < m_game->spriteCount(); ++i)
    {
        if (m_game->sprite(i)->name() == name)
            return SpriteWrapper::create(m_game->sprite(i), this);
    }
    return NULL;
}

StatusWrapper* GameWrapper::status(const QString& name)
{
    for (int i = 0; i < m_game->statusCount(); ++i)
    {
        if (m_game->status(i)->name() == name)
            return StatusWrapper::create(m_game->status(i), this);
    }
    return NULL;
}

StoreWrapper* GameWrapper::store(const QString& name)
{
    for (int i = 0; i < m_game->storeCount(); ++i)
    {
        if (m_game->store(i)->name() == name)
            return StoreWrapper::create(m_game->store(i), this);
    }
    return NULL;
}

TileWrapper* GameWrapper::tile(const QString& name)
{
    for (int i = 0; i < m_game->tileCount(); ++i)
    {
        if (m_game->tile(i)->name() == name)
            return TileWrapper::create(m_game->tile(i), this);
    }
    return NULL;
}

TimeWrapper* GameWrapper::time(const QString& name)
{
    for (int i = 0; i < m_game->timeCount(); ++i)
    {
        if (m_game->time(i)->name() == name)
            return TimeWrapper::create(m_game->time(i), this);
    }
    return NULL;
}

TrainerWrapper* GameWrapper::trainer(const QString& name)
{
    for (int i = 0; i < m_game->trainerCount(); ++i)
    {
        if (m_game->trainer(i)->name() == name)
            return TrainerWrapper::create(m_game->trainer(i), this);
    }
    return NULL;
}

TypeWrapper* GameWrapper::type(const QString& name)
{
    for (int i = 0; i < m_game->typeCount(); ++i)
    {
        if (m_game->type(i)->name() == name)
            return TypeWrapper::create(m_game->type(i), this);
    }
    return NULL;
}

WeatherWrapper* GameWrapper::weather(const QString& name)
{
    for (int i = 0; i < m_game->weatherCount(); ++i)
    {
        if (m_game->weather(i)->name() == name)
            return WeatherWrapper::create(m_game->weather(i), this);
    }
    return NULL;
}