]> git.localhorst.tv Git - l2e.git/blob - src/main.cpp
added interpretation of PartyLayout
[l2e.git] / src / main.cpp
1 /*
2  * main.cpp
3  *
4  *  Created on: Aug 1, 2012
5  *      Author: holy
6  */
7
8 #include "app/Application.h"
9 #include "app/Input.h"
10 #include "battle/BattleState.h"
11 #include "battle/Hero.h"
12 #include "battle/Monster.h"
13 #include "battle/PartyLayout.h"
14 #include "battle/Resources.h"
15 #include "battle/Stats.h"
16 #include "common/Ikari.h"
17 #include "common/Inventory.h"
18 #include "common/Item.h"
19 #include "common/Spell.h"
20 #include "geometry/Vector.h"
21 #include "graphics/ComplexAnimation.h"
22 #include "graphics/Font.h"
23 #include "graphics/Frame.h"
24 #include "graphics/Gauge.h"
25 #include "graphics/Menu.h"
26 #include "graphics/SimpleAnimation.h"
27 #include "graphics/Sprite.h"
28 #include "loader/Interpreter.h"
29 #include "loader/ParsedSource.h"
30 #include "loader/Parser.h"
31 #include "sdl/InitImage.h"
32 #include "sdl/InitScreen.h"
33 #include "sdl/InitSDL.h"
34
35 #include <cstdlib>
36 #include <ctime>
37 #include <exception>
38 #include <iostream>
39 #include <SDL.h>
40 #include <SDL_image.h>
41
42 using app::Application;
43 using app::Input;
44 using battle::BattleState;
45 using battle::Hero;
46 using battle::Monster;
47 using battle::PartyLayout;
48 using battle::Stats;
49 using common::Ikari;
50 using common::Inventory;
51 using common::Item;
52 using common::Spell;
53 using geometry::Vector;
54 using graphics::ComplexAnimation;
55 using graphics::Font;
56 using graphics::Frame;
57 using graphics::Gauge;
58 using graphics::Menu;
59 using graphics::SimpleAnimation;
60 using graphics::Sprite;
61 using loader::Interpreter;
62 using loader::ParsedSource;
63 using loader::Parser;
64 using sdl::InitImage;
65 using sdl::InitScreen;
66 using sdl::InitSDL;
67
68 using std::cerr;
69 using std::cout;
70 using std::endl;
71 using std::exception;
72
73 int main(int argc, char **argv) {
74         const int width = 800;
75         const int height = 480;
76
77         const int framerate = 33;
78
79 //      std::srand(std::time(0));
80
81         try {
82                 InitSDL sdl;
83                 InitImage image(IMG_INIT_PNG);
84
85                 ParsedSource source;
86                 Parser parser("test-data/test.l2s", source);
87                 parser.Parse();
88                 Interpreter intp(source);
89                 intp.ReadSource();
90
91                 InitScreen screen(width, height);
92
93                 // temporary test data
94                 SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
95                 PartyLayout monstersLayout(*intp.GetPartyLayout("monstersLayout"));
96                 PartyLayout heroesLayout(*intp.GetPartyLayout("heroesLayout"));
97
98                 Monster monster(*intp.GetMonster("lizard"));
99                 Hero maxim(*intp.GetHero("maxim"));
100                 Hero selan(*intp.GetHero("selan"));
101                 Hero guy(*intp.GetHero("guy"));
102                 Hero dekar(*intp.GetHero("dekar"));
103
104                 battle::Resources battleRes;
105
106                 SDL_Surface *swapCursorImg(IMG_Load("test-data/swap-cursor.png"));
107                 Sprite swapCursorSprite(swapCursorImg, 32, 32);
108                 battleRes.swapCursor = &swapCursorSprite;
109                 SDL_Surface *attackIconsImg(IMG_Load("test-data/attack-type-icons.png"));
110                 Sprite attackIconsSprite(attackIconsImg, 32, 32);
111                 battleRes.attackIcons = &attackIconsSprite;
112                 SDL_Surface *attackChoiceIconsImg(IMG_Load("test-data/attack-choice-icons.png"));
113                 Sprite attackChoiceIconsSprite(attackChoiceIconsImg, 16, 16);
114                 battleRes.attackChoiceIcons = &attackChoiceIconsSprite;
115                 SDL_Surface *moveIconsImg(IMG_Load("test-data/move-icons.png"));
116                 Sprite moveIconsSprite(moveIconsImg, 32, 32);
117                 battleRes.moveIcons = &moveIconsSprite;
118
119                 SDL_Surface *titleFrameImg(IMG_Load("test-data/title-frame.png"));
120                 Frame titleFrame(titleFrameImg, 16, 16);
121                 battleRes.titleFrame = &titleFrame;
122
123                 SDL_Surface *largeFontImg(IMG_Load("test-data/large-font.png"));
124                 Sprite largeFontSprite(largeFontImg, 16, 32);
125                 Font largeFont(&largeFontSprite, 0, -2);
126                 battleRes.titleFont = &largeFont;
127
128                 ComplexAnimation numberAnimationPrototype(0, framerate);
129                 numberAnimationPrototype.AddFrame(0, 0);
130                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
131                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
132                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -48));
133                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -42));
134                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -26));
135                 numberAnimationPrototype.AddFrame(0, 0);
136                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
137                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
138                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -24));
139                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -20));
140                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
141                 numberAnimationPrototype.AddFrame(0, 0);
142                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
143                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
144                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -12));
145                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -10));
146                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -6));
147                 numberAnimationPrototype.AddFrames(0, 0, Vector<int>(), 14);
148                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -36));
149                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -32));
150                 numberAnimationPrototype.AddFrame(0, 0, Vector<int>(0, -18));
151                 battleRes.numberAnimationPrototype = &numberAnimationPrototype;
152
153                 SDL_Surface *bigNumbersImg(IMG_Load("test-data/big-numbers.png"));
154                 Sprite bigNumbersSprite(bigNumbersImg, 16, 32);
155                 battleRes.bigNumberSprite = &bigNumbersSprite;
156                 SDL_Surface *bigGreenNumbersImg(IMG_Load("test-data/big-green-numbers.png"));
157                 Sprite bigGreenNumbersSprite(bigGreenNumbersImg, 16, 32);
158                 battleRes.greenNumberSprite = &bigGreenNumbersSprite;
159
160                 SDL_Surface *heroTagImg(IMG_Load("test-data/hero-tag-sprites.png"));
161                 Sprite heroTagSprite(heroTagImg, 32, 16);
162                 battleRes.heroTagLabels = &heroTagSprite;
163                 battleRes.levelLabelCol = 0;
164                 battleRes.levelLabelRow = 0;
165                 battleRes.healthLabelCol = 0;
166                 battleRes.healthLabelRow = 1;
167                 battleRes.manaLabelCol = 0;
168                 battleRes.manaLabelRow = 2;
169                 battleRes.moveLabelCol = 0;
170                 battleRes.moveLabelRow = 3;
171                 battleRes.ikariLabelCol = 0;
172                 battleRes.ikariLabelRow = 4;
173
174                 SDL_Surface *numbersImg(IMG_Load("test-data/numbers.png"));
175                 Sprite numbersSprite(numbersImg, 16, 16);
176                 Font heroTagFont(&numbersSprite, 0, -3);
177                 battleRes.heroTagFont = &heroTagFont;
178                 SDL_Surface *tagFramesImg(IMG_Load("test-data/tag-frames.png"));
179                 Frame heroTagFrame(tagFramesImg, 16, 16, 1, 1, 0, 33);
180                 battleRes.heroTagFrame = &heroTagFrame;
181                 Frame activeHeroTagFrame(tagFramesImg, 16, 16);
182                 battleRes.activeHeroTagFrame = &activeHeroTagFrame;
183                 SDL_Surface *smallTagFrameImg(IMG_Load("test-data/small-tag-frame.png"));
184                 Frame smallTagFrame(smallTagFrameImg, 8, 16);
185                 battleRes.smallHeroTagFrame = &smallTagFrame;
186                 Frame lastSmallTagFrame(smallTagFrameImg, 8, 16, 1, 1, 0, 33);
187                 battleRes.lastSmallHeroTagFrame = &lastSmallTagFrame;
188                 battleRes.heroesBgColor = SDL_MapRGB(screen.Screen()->format, 0x18, 0x28, 0x31);
189
190                 SDL_Surface *gauges(IMG_Load("test-data/gauges.png"));
191                 Gauge healthGauge(gauges, 0, 16, 0, 0, 16, 6, 1, 6);
192                 battleRes.healthGauge = &healthGauge;
193                 Gauge manaGauge(gauges, 0, 32, 0, 0, 16, 6, 1, 6);
194                 battleRes.manaGauge = &manaGauge;
195                 Gauge ikariGauge(gauges, 0, 48, 0, 0, 16, 6, 1, 6);
196                 battleRes.ikariGauge = &ikariGauge;
197
198                 SDL_Surface *selectFrameImg(IMG_Load("test-data/select-frame.png"));
199                 Frame selectFrame(selectFrameImg, 16, 16);
200                 battleRes.selectFrame = &selectFrame;
201
202                 SDL_Surface *normalFontImg(IMG_Load("test-data/normal-font.png"));
203                 Sprite normalFontSprite(normalFontImg, 16, 16);
204                 Font normalFont(&normalFontSprite, 0, -2);
205                 battleRes.normalFont = &normalFont;
206
207                 SDL_Surface *disabledFontImg(IMG_Load("test-data/disabled-font.png"));
208                 Sprite disabledFontSprite(disabledFontImg, 16, 16);
209                 Font disabledFont(&disabledFontSprite, 0, -2);
210                 battleRes.disabledFont = &disabledFont;
211
212                 SDL_Surface *handCursorImg(IMG_Load("test-data/cursor-hand.png"));
213                 Sprite handCursorSprite(handCursorImg, 32, 32);
214                 battleRes.menuCursor = &handCursorSprite;
215
216                 SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
217                 Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
218                 Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
219                 Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
220                 battleRes.weaponTargetCursor = &weaponTargetCursor;
221                 battleRes.magicTargetCursor = &magicTargetCursor;
222                 battleRes.itemTargetCursor = &itemTargetCursor;
223
224                 Spell resetSpell;
225                 resetSpell.SetName("Reset");
226                 maxim.AddSpell(&resetSpell);
227                 Spell strongSpell;
228                 strongSpell.SetName("Strong");
229                 strongSpell.SetCost(3);
230                 strongSpell.SetUsableInBattle();
231                 strongSpell.GetTargetingMode().TargetMultipleAllies();
232                 maxim.AddSpell(&strongSpell);
233                 selan.AddSpell(&strongSpell);
234                 Spell strongerSpell;
235                 strongerSpell.SetName("Stronger");
236                 strongerSpell.SetCost(8);
237                 strongerSpell.SetUsableInBattle();
238                 strongerSpell.GetTargetingMode().TargetMultipleAllies();
239                 maxim.AddSpell(&strongerSpell);
240                 selan.AddSpell(&strongerSpell);
241                 Spell championSpell;
242                 championSpell.SetName("Champion");
243                 championSpell.SetCost(16);
244                 championSpell.SetUsableInBattle();
245                 championSpell.GetTargetingMode().TargetMultipleAllies();
246                 maxim.AddSpell(&championSpell);
247                 selan.AddSpell(&championSpell);
248                 Spell rallySpell;
249                 rallySpell.SetName("Rally");
250                 rallySpell.SetCost(10);
251                 rallySpell.SetUsableInBattle();
252                 rallySpell.GetTargetingMode().TargetMultipleAllies();
253                 maxim.AddSpell(&rallySpell);
254                 selan.AddSpell(&rallySpell);
255                 Spell escapeSpell;
256                 escapeSpell.SetName("Escape");
257                 escapeSpell.SetCost(8);
258                 selan.AddSpell(&escapeSpell);
259                 Spell valorSpell;
260                 valorSpell.SetName("Valor");
261                 valorSpell.SetCost(30);
262                 valorSpell.SetUsableInBattle();
263                 valorSpell.GetTargetingMode().TargetMultipleAllies();
264                 maxim.AddSpell(&valorSpell);
265                 selan.AddSpell(&valorSpell);
266
267                 battleRes.spellMenuHeadline = "Please choose a spell.";
268                 battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
269
270                 SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
271                 Sprite potionIcon(itemIcons, 16, 16);
272                 Sprite ballIcon(itemIcons, 16, 16, 0, 16);
273                 Sprite crankIcon(itemIcons, 16, 16, 0, 32);
274                 Sprite spearIcon(itemIcons, 16, 16, 0, 48);
275                 Sprite swordIcon(itemIcons, 16, 16, 0, 64);
276                 Sprite axIcon(itemIcons, 16, 16, 0, 80);
277                 Sprite rodIcon(itemIcons, 16, 16, 0, 96);
278                 Sprite armorIcon(itemIcons, 16, 16, 0, 112);
279                 Sprite shieldIcon(itemIcons, 16, 16, 0, 128);
280                 Sprite helmetIcon(itemIcons, 16, 16, 0, 144);
281                 Sprite ringIcon(itemIcons, 16, 16, 0, 160);
282                 Sprite jewelIcon(itemIcons, 16, 16, 0, 176);
283
284                 battleRes.weaponMenuIcon = &swordIcon;
285                 battleRes.armorMenuIcon = &armorIcon;
286                 battleRes.shieldMenuIcon = &shieldIcon;
287                 battleRes.helmetMenuIcon = &helmetIcon;
288                 battleRes.ringMenuIcon = &ringIcon;
289                 battleRes.jewelMenuIcon = &jewelIcon;
290
291                 Inventory inventory;
292                 Item antidote;
293                 antidote.SetName("Antidote");
294                 antidote.SetMenuIcon(&potionIcon);
295                 antidote.SetUsableInBattle();
296                 antidote.GetTargetingMode().TargetSingleAlly();
297                 inventory.Add(&antidote, 9);
298                 Item magicJar;
299                 magicJar.SetName("Magic jar");
300                 magicJar.SetMenuIcon(&potionIcon);
301                 magicJar.SetUsableInBattle();
302                 magicJar.GetTargetingMode().TargetSingleAlly();
303                 inventory.Add(&magicJar, 4);
304                 Item hiPotion;
305                 hiPotion.SetName("Hi-Potion");
306                 hiPotion.SetMenuIcon(&potionIcon);
307                 hiPotion.SetUsableInBattle();
308                 hiPotion.GetTargetingMode().TargetSingleAlly();
309                 inventory.Add(&hiPotion, 4);
310                 Item powerPotion;
311                 powerPotion.SetName("Power potion");
312                 powerPotion.SetMenuIcon(&potionIcon);
313                 inventory.Add(&powerPotion, 4);
314                 Item escape;
315                 escape.SetName("Escape");
316                 inventory.Add(&escape, 2);
317                 Item sleepBall;
318                 sleepBall.SetName("Sleep ball");
319                 sleepBall.SetMenuIcon(&ballIcon);
320                 sleepBall.SetUsableInBattle();
321                 sleepBall.GetTargetingMode().TargetSingleEnemy();
322                 inventory.Add(&sleepBall, 1);
323                 Item multiBall;
324                 multiBall.SetName("Multi-ball!");
325                 multiBall.SetMenuIcon(&ballIcon);
326                 multiBall.SetUsableInBattle();
327                 multiBall.GetTargetingMode().TargetMultipleEnemies();
328                 inventory.Add(&multiBall, 1);
329                 Item figgoru;
330                 figgoru.SetName("Figgoru");
331                 figgoru.SetMenuIcon(&crankIcon);
332                 figgoru.GetTargetingMode().TargetAllEnemies();
333                 inventory.Add(&figgoru, 1);
334                 battleRes.inventory = &inventory;
335
336                 battleRes.itemMenuHeadline = "Please choose an item.";
337                 battleRes.itemMenuPrototype = Menu<const common::Item *>(&normalFont, &disabledFont, &handCursorSprite, 15, 6, 8, 16, 1, 32, 2, ':');
338
339                 SDL_Surface *swordAttackImg(IMG_Load("test-data/attack-sword.png"));
340                 Sprite swordAttackSprite(swordAttackImg, 96, 96);
341                 SimpleAnimation swordAttackAnimation(&swordAttackSprite, 2 * framerate, 4);
342
343                 Item zircoSword;
344                 zircoSword.SetName("Zirco sword");
345                 zircoSword.SetMenuIcon(&swordIcon);
346                 zircoSword.GetTargetingMode().TargetSingleEnemy();
347                 Ikari firestorm;
348                 firestorm.SetName("Firestorm");
349                 firestorm.SetCost(224);
350                 firestorm.GetTargetingMode().TargetAllEnemies();
351                 firestorm.SetPhysical();
352                 zircoSword.SetIkari(&firestorm);
353                 zircoSword.SetAttackAnimation(&swordAttackAnimation);
354                 maxim.SetWeapon(&zircoSword);
355                 Item zirconArmor;
356                 zirconArmor.SetName("Zircon armor");
357                 zirconArmor.SetMenuIcon(&armorIcon);
358                 Ikari magicCure;
359                 magicCure.SetName("Magic cure");
360                 magicCure.SetCost(128);
361                 magicCure.GetTargetingMode().TargetSingleAlly();
362                 magicCure.SetMagical();
363                 zirconArmor.SetIkari(&magicCure);
364                 maxim.SetArmor(&zirconArmor);
365                 Item holyShield;
366                 holyShield.SetName("Holy shield");
367                 holyShield.SetMenuIcon(&shieldIcon);
368                 Ikari lightGuard;
369                 lightGuard.SetName("Light guard");
370                 lightGuard.SetCost(128);
371                 lightGuard.GetTargetingMode().TargetAllAllies(); // actually only targets self
372                 lightGuard.SetMagical();
373                 holyShield.SetIkari(&lightGuard);
374                 maxim.SetShield(&holyShield);
375                 Item legendHelm;
376                 legendHelm.SetName("Legend helm");
377                 legendHelm.SetMenuIcon(&helmetIcon);
378                 Ikari boomerang;
379                 boomerang.SetName("Boomerang");
380                 boomerang.SetCost(164);
381                 boomerang.GetTargetingMode().TargetAllAllies(); // actually only targets self
382                 boomerang.SetMagical();
383                 legendHelm.SetIkari(&boomerang);
384                 maxim.SetHelmet(&legendHelm);
385                 Item sProRing;
386                 sProRing.SetName("S-pro ring");
387                 sProRing.SetMenuIcon(&ringIcon);
388                 Ikari courage;
389                 courage.SetName("Courage");
390                 courage.SetCost(64);
391                 courage.GetTargetingMode().TargetMultipleAllies();
392                 courage.SetMagical();
393                 sProRing.SetIkari(&courage);
394                 maxim.SetRing(&sProRing);
395                 Item evilJewel;
396                 evilJewel.SetName("Evil jewel");
397                 evilJewel.SetMenuIcon(&jewelIcon);
398                 Ikari gloomy;
399                 gloomy.SetName("Gloomy");
400                 gloomy.SetCost(164);
401                 gloomy.GetTargetingMode().TargetAllEnemies();
402                 gloomy.SetMagical();
403                 evilJewel.SetIkari(&gloomy);
404                 maxim.SetJewel(&evilJewel);
405
406                 Item zircoWhip;
407                 zircoWhip.SetName("Zirco whip");
408                 zircoWhip.SetMenuIcon(&rodIcon);
409                 zircoWhip.GetTargetingMode().TargetSingleEnemy();
410                 Ikari thundershriek;
411                 thundershriek.SetName("Thundershriek");
412                 thundershriek.SetCost(224);
413                 thundershriek.GetTargetingMode().TargetAllEnemies();
414                 thundershriek.SetPhysical();
415                 zircoWhip.SetIkari(&thundershriek);
416 //              selan.SetWeapon(&zircoWhip);
417                 Item zirconPlate;
418                 zirconPlate.SetName("Zircon plate");
419                 zirconPlate.SetMenuIcon(&armorIcon);
420                 Ikari suddenCure;
421                 suddenCure.SetName("Sudden cure");
422                 suddenCure.SetCost(96);
423                 suddenCure.GetTargetingMode().TargetAllAllies();
424                 suddenCure.SetMagical();
425                 zirconPlate.SetIkari(&suddenCure);
426                 selan.SetArmor(&zirconPlate);
427                 Item zircoGloves;
428                 zircoGloves.SetName("Zirco gloves");
429                 zircoGloves.SetMenuIcon(&shieldIcon);
430                 Ikari forcefield;
431                 forcefield.SetName("Forcefield");
432                 forcefield.SetCost(64);
433                 forcefield.GetTargetingMode().TargetAllAllies();
434                 forcefield.SetMagical();
435                 zircoGloves.SetIkari(&forcefield);
436                 selan.SetShield(&zircoGloves);
437                 Item holyCap;
438                 holyCap.SetName("Holy cap");
439                 holyCap.SetMenuIcon(&helmetIcon);
440                 Ikari vulnerable;
441                 vulnerable.SetName("Vulnerable");
442                 vulnerable.SetCost(196);
443                 vulnerable.GetTargetingMode().TargetAllEnemies();
444                 vulnerable.SetPhysical();
445                 holyCap.SetIkari(&vulnerable);
446                 selan.SetHelmet(&holyCap);
447                 Item ghostRing;
448                 ghostRing.SetName("Ghost ring");
449                 ghostRing.SetMenuIcon(&ringIcon);
450                 Ikari destroy;
451                 destroy.SetName("Destroy");
452                 destroy.SetCost(128);
453                 destroy.GetTargetingMode().TargetMultipleEnemies();
454                 destroy.SetMagical();
455                 ghostRing.SetIkari(&destroy);
456                 selan.SetRing(&ghostRing);
457                 Item eagleRock;
458                 eagleRock.SetName("Eagle rock");
459                 eagleRock.SetMenuIcon(&jewelIcon);
460                 Ikari dive;
461                 dive.SetName("Dive");
462                 dive.SetCost(128);
463                 dive.GetTargetingMode().TargetSingleEnemy();
464                 dive.SetPhysical();
465                 eagleRock.SetIkari(&dive);
466                 selan.SetJewel(&eagleRock);
467
468                 Item zircoAx;
469                 zircoAx.SetName("Zirco ax");
470                 zircoAx.SetMenuIcon(&axIcon);
471                 zircoAx.GetTargetingMode().TargetSingleEnemy();
472                 Ikari torrent;
473                 torrent.SetName("Torrent");
474                 torrent.SetCost(224);
475                 torrent.GetTargetingMode().TargetAllEnemies();
476                 torrent.SetPhysical();
477                 zircoAx.SetIkari(&torrent);
478 //              guy.SetWeapon(&zircoAx);
479                 guy.SetArmor(&zirconArmor);
480                 Item megaShield;
481                 megaShield.SetName("Mega shield");
482                 megaShield.SetMenuIcon(&shieldIcon);
483                 Ikari ironBarrier;
484                 ironBarrier.SetName("Iron barrier");
485                 ironBarrier.SetCost(255);
486                 ironBarrier.GetTargetingMode().TargetAllAllies(); // actually only targets self
487                 ironBarrier.SetMagical();
488                 megaShield.SetIkari(&ironBarrier);
489                 guy.SetShield(&megaShield);
490                 Item zircoHelmet;
491                 zircoHelmet.SetName("Zirco helmet");
492                 zircoHelmet.SetMenuIcon(&helmetIcon);
493                 Ikari slow;
494                 slow.SetName("Slow");
495                 slow.SetCost(196);
496                 slow.GetTargetingMode().TargetAllEnemies();
497                 slow.SetPhysical();
498                 zircoHelmet.SetIkari(&slow);
499                 guy.SetHelmet(&zircoHelmet);
500                 Item powerRing;
501                 powerRing.SetName("Power ring");
502                 powerRing.SetMenuIcon(&ringIcon);
503                 Ikari trick;
504                 trick.SetName("Trick");
505                 trick.SetCost(32);
506                 trick.GetTargetingMode().TargetAllEnemies();
507                 trick.SetMagical();
508                 zircoHelmet.SetIkari(&trick);
509                 guy.SetRing(&powerRing);
510                 guy.SetJewel(&evilJewel);
511
512                 // NOTE: this is actually Artea equipment
513                 Item lizardBlow;
514                 lizardBlow.SetName("Lizard blow");
515                 lizardBlow.SetMenuIcon(&swordIcon);
516                 lizardBlow.GetTargetingMode().TargetSingleEnemy();
517                 Ikari dragonRush;
518                 dragonRush.SetName("Dragon rush");
519                 dragonRush.SetCost(164);
520                 dragonRush.GetTargetingMode().TargetSingleEnemy();
521                 dragonRush.SetPhysical();
522                 lizardBlow.SetIkari(&dragonRush);
523 //              dekar.SetWeapon(&lizardBlow);
524                 Item holyRobe;
525                 holyRobe.SetName("Holy robe");
526                 holyRobe.SetMenuIcon(&armorIcon);
527                 Ikari crisisCure;
528                 crisisCure.SetName("Crisis cure");
529                 crisisCure.SetCost(164);
530                 crisisCure.GetTargetingMode().TargetAllAllies();
531                 crisisCure.SetMagical();
532                 holyRobe.SetIkari(&crisisCure);
533                 dekar.SetArmor(&holyRobe);
534                 dekar.SetShield(&zircoGloves);
535                 dekar.SetHelmet(&holyCap);
536                 Item rocketRing;
537                 rocketRing.SetName("Rocket ring");
538                 rocketRing.SetMenuIcon(&ringIcon);
539                 Ikari fake;
540                 fake.SetName("Fake");
541                 fake.SetCost(32);
542                 fake.GetTargetingMode().TargetSingleAlly();
543                 fake.SetMagical();
544                 rocketRing.SetIkari(&fake);
545                 dekar.SetRing(&rocketRing);
546                 Item krakenRock;
547                 krakenRock.SetName("Kraken rock");
548                 krakenRock.SetMenuIcon(&jewelIcon);
549                 Ikari tenLegger;
550                 tenLegger.SetName("Ten-legger");
551                 tenLegger.SetCost(164);
552                 tenLegger.GetTargetingMode().TargetAllEnemies();
553                 tenLegger.SetPhysical();
554                 rocketRing.SetIkari(&tenLegger);
555                 dekar.SetJewel(&krakenRock);
556
557                 battleRes.ikariMenuHeadline = "Please choose equipment.";
558                 battleRes.noEquipmentText = "No equip";
559                 battleRes.ikariMenuPrototype = Menu<const Item *>(&normalFont, &disabledFont, &handCursorSprite, 12, 6, normalFont.CharHeight() / 2, normalFont.CharWidth(), 1, normalFont.CharWidth() * 2, 0, ':', 12, normalFont.CharWidth());
560
561                 battleRes.escapeText = "Escapes.";
562
563                 BattleState *battleState(new BattleState(bg, monstersLayout, heroesLayout, &battleRes));
564                 battleState->AddMonster(monster);
565                 battleState->AddMonster(monster);
566                 battleState->AddMonster(monster);
567                 battleState->AddMonster(monster);
568                 battleState->AddHero(maxim);
569                 battleState->AddHero(selan);
570                 battleState->AddHero(guy);
571                 battleState->AddHero(dekar);
572                 Application app(&screen, battleState);
573                 app.Buttons().MapKey(SDLK_w, Input::PAD_UP);
574                 app.Buttons().MapKey(SDLK_d, Input::PAD_RIGHT);
575                 app.Buttons().MapKey(SDLK_s, Input::PAD_DOWN);
576                 app.Buttons().MapKey(SDLK_a, Input::PAD_LEFT);
577                 app.Buttons().MapKey(SDLK_RIGHT, Input::ACTION_A);
578                 app.Buttons().MapKey(SDLK_DOWN, Input::ACTION_B);
579                 app.Buttons().MapKey(SDLK_UP, Input::ACTION_X);
580                 app.Buttons().MapKey(SDLK_LEFT, Input::ACTION_Y);
581                 app.Buttons().MapKey(SDLK_RETURN, Input::START);
582                 app.Buttons().MapKey(SDLK_SPACE, Input::SELECT);
583                 app.Buttons().MapKey(SDLK_RSHIFT, Input::SHOULDER_RIGHT);
584                 app.Buttons().MapKey(SDLK_LSHIFT, Input::SHOULDER_LEFT);
585                 app.Run();
586
587                 return 0;
588         } catch (Parser::Error &e) {
589                 cerr << "parsing exception in file " << e.File() << " on line " << e.Line() << ": " << e.what() << endl;
590                 return 1;
591         } catch (exception &e) {
592                 cerr << "exception in main(): " << e.what() << endl;
593                 return 1;
594         }
595 }