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