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