3 * @brief
\83Q
\81[
\83\80\90¢
\8aE
\82ð
\92è
\8b`
\82·
\82é
10 #include "GameWorld.h"
11 #include "Deeangband.h"
13 #include "Coordinates.h"
14 #include "HaveGameTime.h"
18 #include "Authority.h"
21 #include "CreatureTrait.h"
28 #include "FixedArtifact.h"
29 #include "GameMessage.h"
32 #include "ItemTrait.h"
40 #include "StartingClass.h"
50 GameWorld::GameWorld(void)
62 GameWorld::GenerateCreature("VANILLA_STIGMATIC", 0, 10, 10);
63 GameWorld::GenerateCreature("VANILLA_RAVING_LUNATIC", 0, 5, 5);
64 fieldList.emplace(0, boost::make_shared<Field>(dungeonList.find("VANILLA_WOMB"), 1));
67 for(i = 0; i < MAX_KARMAS; i++)
69 karmaList.emplace("VANILLA_", boost::make_shared<Karma>());
72 playerIt = creatureList.begin()++;
75 GameWorld::~GameWorld(void)
79 bool GameWorld::GenerateCreature(TAG creatureTag)
81 creatureList.emplace(this->creatureID, boost::make_shared<Creature>(speciesList.find(creatureTag)));
82 //actionList.push_back(creatureList[this->creatureID]);
86 } while(creatureList.find(this->creatureID) != creatureList.end());
90 bool GameWorld::GenerateCreature(TAG creatureTag, ID fieldID, int x, int y)
92 creatureList.emplace(this->creatureID, boost::make_shared<Creature>(speciesList.find(creatureTag), fieldID, x, y));
93 //actionList.push_back(creatureList[this->creatureID]);
94 creatureList[this->creatureID]->PlusWait(100, TRUE);
98 } while(creatureList.find(this->creatureID) != creatureList.end());
102 bool GameWorld::xmlSaveAir(void)
104 std::ofstream ofs("lib-Vanilla\\Air.xml");
106 boost::archive::xml_oarchive oa(ofs);
107 oa << boost::serialization::make_nvp("Airs", this->airList);
112 bool GameWorld::xmlSaveAbility(void)
114 std::ofstream ofs("lib-Vanilla\\Ability.xml");
116 boost::archive::xml_oarchive oa(ofs);
117 oa << boost::serialization::make_nvp("Abilities", this->abilityList);
122 bool GameWorld::xmlSaveAuthority(void)
124 std::ofstream ofs("lib-Vanilla\\Authority.xml");
126 boost::archive::xml_oarchive oa(ofs);
127 oa << boost::serialization::make_nvp("Authorities", this->authorityList);
132 bool GameWorld::xmlSaveBuilding(void)
134 std::ofstream ofs("lib-Vanilla\\Building.xml");
136 boost::archive::xml_oarchive oa(ofs);
137 oa << boost::serialization::make_nvp("Buildings", this->buildingList);
142 bool GameWorld::xmlSaveCamp(void)
144 std::ofstream ofs("lib-Vanilla\\Camp.xml");
146 boost::archive::xml_oarchive oa(ofs);
147 oa << boost::serialization::make_nvp("Camps", this->campList);
152 bool GameWorld::xmlSaveCreatureTrait(void)
154 std::ofstream ofs("lib-Vanilla\\CreatureTrait.xml");
156 boost::archive::xml_oarchive oa(ofs);
157 oa << boost::serialization::make_nvp("CreatureTraits", this->creatureTraitList);
162 bool GameWorld::xmlSaveDungeon(void)
164 std::ofstream ofs("lib-Vanilla\\Dungeon.xml");
166 boost::archive::xml_oarchive oa(ofs);
167 oa << boost::serialization::make_nvp("Dungeons", this->dungeonList);
172 bool GameWorld::xmlSaveEffect(void)
174 std::ofstream ofs("lib-Vanilla\\Effect.xml");
176 boost::archive::xml_oarchive oa(ofs);
177 oa << boost::serialization::make_nvp("Effects", this->effectList);
182 bool GameWorld::xmlSaveFloor(void)
184 std::ofstream ofs("lib-Vanilla\\Floor.xml");
186 boost::archive::xml_oarchive oa(ofs);
187 oa << boost::serialization::make_nvp("Floors", this->floorList);
192 bool GameWorld::xmlSaveFixedArtifact(void)
194 std::ofstream ofs("lib-Vanilla\\FixedArtifact.xml");
196 boost::archive::xml_oarchive oa(ofs);
197 oa << boost::serialization::make_nvp("FixedArtifacts", this->fixedArtifactList);
202 bool GameWorld::xmlSaveItemBase(void)
204 std::ofstream ofs("lib-Vanilla\\ItemBase.xml");
206 boost::archive::xml_oarchive oa(ofs);
207 oa << boost::serialization::make_nvp("ItemBases", this->itemBaseList);
212 bool GameWorld::xmlSaveItemEgo(void)
214 std::ofstream ofs("lib-Vanilla\\ItemEgo.xml");
216 boost::archive::xml_oarchive oa(ofs);
217 oa << boost::serialization::make_nvp("ItemEgos", this->itemEgoList);
222 bool GameWorld::xmlSaveItemTrait(void)
224 std::ofstream ofs("lib-Vanilla\\ItemTrait.xml");
226 boost::archive::xml_oarchive oa(ofs);
227 oa << boost::serialization::make_nvp("ItemTraits", this->itemTraitList);
232 bool GameWorld::xmlSaveKarma(void)
234 std::ofstream ofs("lib-Vanilla\\Karma.xml");
236 boost::archive::xml_oarchive oa(ofs);
237 oa << boost::serialization::make_nvp("Karmas", this->karmaList);
242 bool GameWorld::xmlSaveQuest(void)
244 std::ofstream ofs("lib-Vanilla\\Quest.xml");
246 boost::archive::xml_oarchive oa(ofs);
247 oa << boost::serialization::make_nvp("Quests", this->questList);
252 bool GameWorld::xmlSaveRace(void)
254 std::ofstream ofs("lib-Vanilla\\Race.xml");
256 boost::archive::xml_oarchive oa(ofs);
257 oa << boost::serialization::make_nvp("Races", this->raceList);
262 bool GameWorld::xmlSaveSpace(void)
264 std::ofstream ofs("lib-Vanilla\\Space.xml");
266 boost::archive::xml_oarchive oa(ofs);
267 oa << boost::serialization::make_nvp("Spaces", this->spaceList);
272 bool GameWorld::xmlSaveSkill(void)
274 std::ofstream ofs("lib-Vanilla\\Skill.xml");
276 boost::archive::xml_oarchive oa(ofs);
277 oa << boost::serialization::make_nvp("Skills", this->skillList);
282 bool GameWorld::xmlSaveSpecie(void)
284 std::ofstream ofs("lib-Vanilla\\Specie.xml");
286 boost::archive::xml_oarchive oa(ofs);
287 oa << boost::serialization::make_nvp("Species", this->speciesList);
292 bool GameWorld::xmlSaveStartingClass(void)
294 std::ofstream ofs("lib-Vanilla\\StartingClass.xml");
296 boost::archive::xml_oarchive oa(ofs);
297 oa << boost::serialization::make_nvp("StartingClasses", this->startingClassList);
302 bool GameWorld::xmlSaveTrapBase(void)
304 std::ofstream ofs("lib-Vanilla\\TrapBase.xml");
306 boost::archive::xml_oarchive oa(ofs);
307 oa << boost::serialization::make_nvp("TrapBases", this->trapBaseList);
312 bool GameWorld::XMLSave(void)
315 this->xmlSaveAbility();
316 this->xmlSaveAuthority();
317 this->xmlSaveBuilding();
319 this->xmlSaveCreatureTrait();
320 this->xmlSaveDungeon();
321 this->xmlSaveEffect();
322 this->xmlSaveFloor();
323 this->xmlSaveFixedArtifact();
324 this->xmlSaveItemBase();
325 this->xmlSaveItemEgo();
326 this->xmlSaveItemTrait();
327 this->xmlSaveKarma();
328 this->xmlSaveQuest();
330 this->xmlSaveSpace();
331 this->xmlSaveSkill();
332 this->xmlSaveSpecie();
333 this->xmlSaveStartingClass();
334 this->xmlSaveTrapBase();
338 bool GameWorld::xmlLoadAir()
340 std::ifstream ifs("lib-Vanilla\\Air.xml");
342 boost::archive::xml_iarchive ia(ifs);
343 ia >> BOOST_SERIALIZATION_NVP(airList);
347 bool GameWorld::xmlLoadAbility()
349 std::ifstream ifs("lib-Vanilla\\Ability.xml");
351 boost::archive::xml_iarchive ia(ifs);
352 ia >> BOOST_SERIALIZATION_NVP(abilityList);
356 bool GameWorld::xmlLoadAuthority()
358 std::ifstream ifs("lib-Vanilla\\Authority.xml");
360 boost::archive::xml_iarchive ia(ifs);
361 ia >> BOOST_SERIALIZATION_NVP(authorityList);
365 bool GameWorld::xmlLoadBuilding()
367 std::ifstream ifs("lib-Vanilla\\Building.xml");
369 boost::archive::xml_iarchive ia(ifs);
370 ia >> BOOST_SERIALIZATION_NVP(buildingList);
374 bool GameWorld::xmlLoadCamp()
376 std::ifstream ifs("lib-Vanilla\\Camp.xml");
378 boost::archive::xml_iarchive ia(ifs);
379 ia >> BOOST_SERIALIZATION_NVP(campList);
383 bool GameWorld::xmlLoadCreatureTrait()
385 std::ifstream ifs("lib-Vanilla\\CreatureTrait.xml");
387 boost::archive::xml_iarchive ia(ifs);
388 ia >> BOOST_SERIALIZATION_NVP(creatureTraitList);
392 bool GameWorld::xmlLoadDungeon()
394 std::ifstream ifs("lib-Vanilla\\Dungeon.xml");
396 boost::archive::xml_iarchive ia(ifs);
397 ia >> BOOST_SERIALIZATION_NVP(dungeonList);
401 bool GameWorld::xmlLoadEffect()
403 std::ifstream ifs("lib-Vanilla\\Effect.xml");
405 boost::archive::xml_iarchive ia(ifs);
406 ia >> BOOST_SERIALIZATION_NVP(effectList);
410 bool GameWorld::xmlLoadFloor()
412 std::ifstream ifs("lib-Vanilla\\Floor.xml");
414 boost::archive::xml_iarchive ia(ifs);
415 ia >> BOOST_SERIALIZATION_NVP(floorList);
419 bool GameWorld::xmlLoadFixedArtifact()
421 std::ifstream ifs("lib-Vanilla\\FixedArtifact.xml");
423 boost::archive::xml_iarchive ia(ifs);
424 ia >> BOOST_SERIALIZATION_NVP(fixedArtifactList);
428 bool GameWorld::xmlLoadItemBase()
430 std::ifstream ifs("lib-Vanilla\\ItemBase.xml");
432 boost::archive::xml_iarchive ia(ifs);
433 ia >> BOOST_SERIALIZATION_NVP(itemBaseList);
437 bool GameWorld::xmlLoadItemEgo()
439 std::ifstream ifs("lib-Vanilla\\ItemEgo.xml");
441 boost::archive::xml_iarchive ia(ifs);
442 ia >> BOOST_SERIALIZATION_NVP(itemEgoList);
446 bool GameWorld::xmlLoadItemTrait()
448 std::ifstream ifs("lib-Vanilla\\ItemTrait.xml");
450 boost::archive::xml_iarchive ia(ifs);
451 ia >> BOOST_SERIALIZATION_NVP(itemTraitList);
455 bool GameWorld::xmlLoadKarma()
457 std::ifstream ifs("lib-Vanilla\\Karma.xml");
459 boost::archive::xml_iarchive ia(ifs);
460 ia >> BOOST_SERIALIZATION_NVP(karmaList);
464 bool GameWorld::xmlLoadQuest()
466 std::ifstream ifs("lib-Vanilla\\Quest.xml");
468 boost::archive::xml_iarchive ia(ifs);
469 ia >> BOOST_SERIALIZATION_NVP(questList);
473 bool GameWorld::xmlLoadRace()
475 std::ifstream ifs("lib-Vanilla\\Race.xml");
477 boost::archive::xml_iarchive ia(ifs);
478 ia >> BOOST_SERIALIZATION_NVP(raceList);
482 bool GameWorld::xmlLoadSpace()
484 std::ifstream ifs("lib-Vanilla\\Space.xml");
486 boost::archive::xml_iarchive ia(ifs);
487 ia >> BOOST_SERIALIZATION_NVP(spaceList);
491 bool GameWorld::xmlLoadSkill()
493 std::ifstream ifs("lib-Vanilla\\Skill.xml");
495 boost::archive::xml_iarchive ia(ifs);
496 ia >> BOOST_SERIALIZATION_NVP(skillList);
500 bool GameWorld::xmlLoadSpecie()
502 std::ifstream ifs("lib-Vanilla\\Specie.xml");
504 boost::archive::xml_iarchive ia(ifs);
505 ia >> BOOST_SERIALIZATION_NVP(speciesList);
509 bool GameWorld::xmlLoadStartingClass()
511 std::ifstream ifs("lib-Vanilla\\StartingClass.xml");
513 boost::archive::xml_iarchive ia(ifs);
514 ia >> BOOST_SERIALIZATION_NVP(startingClassList);
518 bool GameWorld::xmlLoadTrapBase()
520 std::ifstream ifs("lib-Vanilla\\TrapBase.xml");
522 boost::archive::xml_iarchive ia(ifs);
523 ia >> BOOST_SERIALIZATION_NVP(trapBaseList);
527 void GameWorld::XMLLoad(void)
530 this->xmlLoadAbility();
531 this->xmlLoadAuthority();
532 this->xmlLoadBuilding();
534 this->xmlLoadCreatureTrait();
535 this->xmlLoadDungeon();
536 this->xmlLoadEffect();
537 this->xmlLoadFloor();
538 this->xmlLoadFixedArtifact();
539 this->xmlLoadItemBase();
540 this->xmlLoadItemEgo();
541 this->xmlLoadItemTrait();
542 this->xmlLoadKarma();
543 this->xmlLoadQuest();
545 this->xmlLoadSpace();
546 this->xmlLoadSkill();
547 this->xmlLoadSpecie();
548 this->xmlLoadStartingClass();
549 this->xmlLoadTrapBase();
552 Authority *GameWorld::GetAuthority(TAG tag)
554 return &(*authorityList[tag]);
557 CreatureTrait *GameWorld::GetCreatureTrait(TAG tag)
559 return &(*creatureTraitList[tag]);
562 Effect *GameWorld::GetEffect(TAG tag)
564 return &(*effectList[tag]);
567 FixedArtifact *GameWorld::GetFixedArtifact(TAG tag)
569 return &(*fixedArtifactList[tag]);
572 Floor *GameWorld::GetFloor(TAG tag)
574 return &(*floorList[tag]);
577 ItemBase *GameWorld::GetItemBase(TAG tag)
579 return &(*itemBaseList[tag]);
582 ItemEgo *GameWorld::GetItemEgo(TAG tag)
584 return &(*itemEgoList[tag]);
587 ItemTrait *GameWorld::GetItemTrait(TAG tag)
589 return &(*itemTraitList[tag]);
592 Karma *GameWorld::GetKarma(TAG tag)
594 return &(*karmaList[tag]);
597 Skill *GameWorld::GetSkill(TAG tag)
599 return &(*skillList[tag]);
602 Species *GameWorld::GetSpecies(TAG tag)
604 return &(*speciesList[tag]);
607 TrapBase *GameWorld::GetTrapBase(TAG tag)
609 return &(*trapBaseList[tag]);
612 Building *GameWorld::GetBuilding(TAG tag)
614 return &(*buildingList[tag]);
617 Camp *GameWorld::GetCamp(TAG tag)
619 return &(*campList[tag]);
622 Dungeon *GameWorld::GetDungeon(TAG tag)
624 return &(*dungeonList[tag]);
627 Item *GameWorld::GetItem(ID id)
629 return &(*itemList[id]);
632 Field *GameWorld::GetField(ID id)
634 return &(*fieldList[id]);
637 Creature *GameWorld::GetCreature(ID id)
639 return &(*creatureList[id]);
642 std::map<TAG, boost::shared_ptr<Ability>> *GameWorld::GetAbilityList(void)
644 return &(this->abilityList);
647 Quest *GameWorld::GetQuest(TAG tag)
649 return &(*questList[tag]);
652 GAME_TIME GameWorld::GetGameTime(void)
654 return this->gameTime;
657 void GameWorld::WipeCreature(ID id)
659 creatureList.erase(id);
662 CREATURE_IT GameWorld::GetPlayerCreature(void)
664 return this->playerIt;
667 ACTION_LIST* GameWorld::GetActionList(void)
669 return &(this->actionList);
672 Creature *GameWorld::GetCreatureFromPosition(ID fieldID, Coordinates *positionPtr)
674 CREATURE_IT creatureIt;
675 creatureIt = this->creatureList.begin();
676 while(creatureIt != this->creatureList.end())
678 if(creatureIt->second->GetPosition() == *positionPtr && fieldID == creatureIt->second->GetFieldID()) return (creatureIt->second.get());
685 Floor *GameWorld::GetFloorFromPosition(ID fieldID, Coordinates *positionPtr)
687 Square *square = fieldList[fieldID].get()->GetSquare(positionPtr->GetX(), positionPtr->GetY());
688 if(!square) return NULL;
689 TAG tag = square->GetFloorTag();
690 return &(*floorList[tag]);
693 std::map<TAG, boost::shared_ptr<Floor>> *GameWorld::GetFloorList(void)
698 std::map<TAG, boost::shared_ptr<Species>> *GameWorld::GetSpeciesList(void)
703 CREATURE_LIST *GameWorld::GetCreatureList(void)
705 return &creatureList;