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