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