3 #include "Interpreter.h"
5 #include "TypeDescription.h"
6 #include "../battle/Resources.h"
7 #include "../battle/Monster.h"
8 #include "../battle/PartyLayout.h"
9 #include "../common/Capsule.h"
10 #include "../common/Hero.h"
11 #include "../common/Item.h"
12 #include "../common/Spell.h"
13 #include "../map/Map.h"
14 #include "../menu/Resources.h"
16 using battle::Monster;
17 using battle::PartyLayout;
18 using common::Capsule;
28 Caster::Caster(Loader &ld, Interpreter &intp)
35 battle::Resources *Caster::GetBattleResources(const string &ident) {
36 return reinterpret_cast<battle::Resources *>(
37 GetObject(battle::Resources::TYPE_ID, ident));
40 Capsule *Caster::GetCapsule(const string &ident) {
41 return reinterpret_cast<Capsule *>(
42 GetObject(Capsule::TYPE_ID, ident));
45 Hero *Caster::GetHero(const string &ident) {
46 return reinterpret_cast<Hero *>(
47 GetObject(Hero::TYPE_ID, ident));
50 Item *Caster::GetItem(const string &ident) {
51 return reinterpret_cast<Item *>(
52 GetObject(Item::TYPE_ID, ident));
55 Map *Caster::GetMap(const string &ident) {
56 return reinterpret_cast<Map *>(
57 GetObject(Map::TYPE_ID, ident));
60 menu::Resources *Caster::GetMenuResources(const string &ident) {
61 return reinterpret_cast<menu::Resources *>(
62 GetObject(menu::Resources::TYPE_ID, ident));
65 Monster *Caster::GetMonster(const string &ident) {
66 return reinterpret_cast<Monster *>(
67 GetObject(Monster::TYPE_ID, ident));
70 PartyLayout *Caster::GetPartyLayout(const string &ident) {
71 return reinterpret_cast<PartyLayout *>(
72 GetObject(PartyLayout::TYPE_ID, ident));
75 Spell *Caster::GetSpell(const string &ident) {
76 return reinterpret_cast<Spell *>(
77 GetObject(Spell::TYPE_ID, ident));
81 void *Caster::GetObject(int typeId, const string &ident) {
82 std::map<string, LoadedExport>::const_iterator i(
83 ld.Exports().find(ident));
84 if (i != ld.Exports().end()) {
85 if (i->second.typeId != typeId) {
86 throw std::runtime_error("mismatched type for "
89 return i->second.location;
92 return intp.GetObject(typeId, ident);