+ InitImage image(IMG_INIT_PNG);
+
+ battle::Resources::CreateTypeDescription();
+ ComplexAnimation::CreateTypeDescription();
+ Font::CreateTypeDescription();
+ Frame::CreateTypeDescription();
+ Gauge::CreateTypeDescription();
+ Hero::CreateTypeDescription();
+ Ikari::CreateTypeDescription();
+ Interpreter::CreateTypeDescriptions();
+ Item::CreateTypeDescription();
+ graphics::MenuProperties::CreateTypeDescription();
+ Monster::CreateTypeDescription();
+ PartyLayout::CreateTypeDescription();
+ SimpleAnimation::CreateTypeDescription();
+ Spell::CreateTypeDescription();
+ Sprite::CreateTypeDescription();
+ Stats::CreateTypeDescription();
+ common::TargetingMode::CreateTypeDescription();
+
+ Arguments args;
+ args.Read(argc, argv);
+
+ ParsedSource source;
+
+ for (vector<char *>::const_iterator i(args.Infiles().begin()), end(args.Infiles().end()); i != end; ++i) {
+ Parser(*i, source).Parse();
+ }
+
+ switch (args.DetectRunLevel()) {
+ case Arguments::WRITE:
+ {
+ int length(std::strlen(args.OutfilePath()));
+ switch (args.OutfilePath()[length - 1]) {
+ case 'h': {
+ std::ofstream outstream(args.OutfilePath());
+ source.WriteHeader(outstream);
+ break;
+ }
+ default: {
+ throw std::runtime_error(string("don't know how to write file ") + args.OutfilePath());
+ }
+ }
+ return 0;
+ }
+ case Arguments::DUMP: {
+ std::cout << source << std::endl;
+ return 0;
+ }
+ case Arguments::PLAY:
+ break;
+ }
+
+ Interpreter intp(source);
+ intp.ReadSource();
+
+ if (intp.PostponedDefinitions().size() > 0) {
+ for (vector<Interpreter::PostponedDefinition>::const_iterator i(intp.PostponedDefinitions().begin()), end(intp.PostponedDefinitions().end()); i != end; ++i) {
+ std::cerr << "missing definition of " << TypeDescription::Get(i->linkedType).TypeName() << " " << i->identifier << std::endl;
+ }
+ return 3;
+ }
+
+ Caster caster(intp);
+
+ // temporary test data
+ SDL_Surface *bg(IMG_Load("test-data/battle-bg.png"));
+ PartyLayout monstersLayout(*caster.GetPartyLayout("monstersLayout"));
+ PartyLayout heroesLayout(*caster.GetPartyLayout("heroesLayout"));
+
+ Monster monster(*caster.GetMonster("lizard"));
+ Hero maxim(*caster.GetHero("maxim"));
+ Hero selan(*caster.GetHero("selan"));
+ Hero guy(*caster.GetHero("guy"));
+ Hero dekar(*caster.GetHero("dekar"));
+
+ battle::Resources *battleRes(caster.GetBattleResources("battleResources"));
+
+ maxim.AddSpell(caster.GetSpell("resetSpell"));
+ Spell *strongSpell(caster.GetSpell("strongSpell"));
+ maxim.AddSpell(strongSpell);
+ selan.AddSpell(strongSpell);
+ Spell *strongerSpell(caster.GetSpell("strongerSpell"));
+ maxim.AddSpell(strongerSpell);
+ selan.AddSpell(strongerSpell);
+ Spell *championSpell(caster.GetSpell("championSpell"));
+ maxim.AddSpell(championSpell);
+ selan.AddSpell(championSpell);
+ Spell *rallySpell(caster.GetSpell("rallySpell"));
+ maxim.AddSpell(rallySpell);
+ selan.AddSpell(rallySpell);
+ selan.AddSpell(caster.GetSpell("escapeSpell"));
+ Spell *valorSpell(caster.GetSpell("valorSpell"));
+ maxim.AddSpell(valorSpell);
+ selan.AddSpell(valorSpell);
+
+ Inventory inventory;
+ inventory.Add(caster.GetItem("antidoteItem"), 9);
+ inventory.Add(caster.GetItem("magicJarItem"), 4);
+ inventory.Add(caster.GetItem("hiPotionItem"), 4);
+ inventory.Add(caster.GetItem("powerPotionItem"), 4);
+ inventory.Add(caster.GetItem("escapeItem"), 2);
+ inventory.Add(caster.GetItem("sleepBallItem"), 1);
+ battleRes->inventory = &inventory;
+
+ maxim.SetWeapon(caster.GetItem("zircoSwordItem"));
+ maxim.SetArmor(caster.GetItem("zirconArmorItem"));
+ maxim.SetShield(caster.GetItem("holyShieldItem"));
+ maxim.SetHelmet(caster.GetItem("legendHelmItem"));
+ maxim.SetRing(caster.GetItem("sProRingItem"));
+ maxim.SetJewel(caster.GetItem("evilJewelItem"));
+
+// selan.SetWeapon(cst.GetItem("zircoWhipItem"));
+ selan.SetArmor(caster.GetItem("zirconPlateItem"));
+ selan.SetShield(caster.GetItem("zircoGlovesItem"));
+ selan.SetHelmet(caster.GetItem("holyCapItem"));
+ selan.SetRing(caster.GetItem("ghostRingItem"));
+ selan.SetJewel(caster.GetItem("eagleRockItem"));
+
+// guy.SetWeapon(cst.GetItem("zircoAxItem"));
+ guy.SetArmor(caster.GetItem("zirconArmorItem"));
+ guy.SetShield(caster.GetItem("megaShieldItem"));
+ guy.SetHelmet(caster.GetItem("zircoHelmetItem"));
+ guy.SetRing(caster.GetItem("powerRingItem"));
+ guy.SetJewel(caster.GetItem("evilJewelItem"));
+
+ // NOTE: this is actually Artea equipment
+// dekar.SetWeapon(cst.GetItem("lizardBlowItem"));
+ dekar.SetArmor(caster.GetItem("holyRobeItem"));
+ dekar.SetShield(caster.GetItem("zircoGlovesItem"));
+ dekar.SetHelmet(caster.GetItem("holyCapItem"));
+ dekar.SetRing(caster.GetItem("rocketRingItem"));
+ dekar.SetJewel(caster.GetItem("krakenRockItem"));
+