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