1 // Copyright (C) 2007, 2008 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <sigc++/functors/mem_fun.h>
24 #include "heroproto.h"
26 #include "xmlhelper.h"
29 std::string History::d_tag = "history";
32 #define debug(x) {cerr<<__FILE__<<": "<<__LINE__<<": "<< x << endl<<flush;}
35 History::History(Type type)
44 History* History::handle_load(XML_Helper* helper)
47 helper->getData(type_str, "type");
48 History::Type t = historyTypeFromString(type_str);
53 return (new History_StartTurn(helper));
55 return (new History_FoundSage(helper));
57 return (new History_GoldTotal(helper));
59 return (new History_HeroEmerges(helper));
61 return (new History_CityWon(helper));
63 return (new History_HeroCityWon(helper));
65 return (new History_CityRazed(helper));
66 case HERO_QUEST_STARTED:
67 return (new History_HeroQuestStarted(helper));
68 case HERO_QUEST_COMPLETED:
69 return (new History_HeroQuestCompleted(helper));
70 case HERO_KILLED_IN_CITY:
71 return (new History_HeroKilledInCity(helper));
72 case HERO_KILLED_IN_BATTLE:
73 return (new History_HeroKilledInBattle(helper));
74 case HERO_KILLED_SEARCHING:
75 return (new History_HeroKilledSearching(helper));
77 return (new History_Score(helper));
78 case PLAYER_VANQUISHED:
79 return (new History_PlayerVanquished(helper));
80 case DIPLOMATIC_PEACE:
81 return (new History_DiplomacyPeace(helper));
83 return (new History_DiplomacyWar(helper));
84 case DIPLOMATIC_TREACHERY:
85 return (new History_DiplomacyTreachery(helper));
86 case HERO_FINDS_ALLIES:
87 return (new History_HeroFindsAllies(helper));
89 return (new History_EndTurn(helper));
90 case HERO_RUIN_EXPLORED:
91 return (new History_HeroRuinExplored(helper));
92 case HERO_REWARD_RUIN:
93 return (new History_HeroRewardRuin(helper));
99 History* History::copy(const History* a)
105 (new History_StartTurn(*dynamic_cast<const History_StartTurn*>(a)));
108 (new History_FoundSage(*dynamic_cast<const History_FoundSage*>(a)));
111 (new History_GoldTotal(*dynamic_cast<const History_GoldTotal*>(a)));
114 (new History_HeroEmerges(*dynamic_cast<const History_HeroEmerges*>(a)));
117 (new History_CityWon(*dynamic_cast<const History_CityWon*>(a)));
120 (new History_HeroCityWon(*dynamic_cast<const History_HeroCityWon*>(a)));
123 (new History_CityRazed(*dynamic_cast<const History_CityRazed*>(a)));
124 case HERO_QUEST_STARTED:
126 (new History_HeroQuestStarted
127 (*dynamic_cast<const History_HeroQuestStarted*>(a)));
128 case HERO_QUEST_COMPLETED:
130 (new History_HeroQuestCompleted
131 (*dynamic_cast<const History_HeroQuestCompleted*>(a)));
132 case HERO_KILLED_IN_CITY:
134 (new History_HeroKilledInCity
135 (*dynamic_cast<const History_HeroKilledInCity*>(a)));
136 case HERO_KILLED_IN_BATTLE:
138 (new History_HeroKilledInBattle
139 (*dynamic_cast<const History_HeroKilledInBattle*>(a)));
140 case HERO_KILLED_SEARCHING:
142 (new History_HeroKilledSearching
143 (*dynamic_cast<const History_HeroKilledSearching*>(a)));
146 (new History_Score(*dynamic_cast<const History_Score*>(a)));
147 case PLAYER_VANQUISHED:
149 (new History_PlayerVanquished
150 (*dynamic_cast<const History_PlayerVanquished*>(a)));
151 case DIPLOMATIC_PEACE:
153 (new History_DiplomacyPeace
154 (*dynamic_cast<const History_DiplomacyPeace*>(a)));
157 (new History_DiplomacyWar
158 (*dynamic_cast<const History_DiplomacyWar*>(a)));
159 case DIPLOMATIC_TREACHERY:
161 (new History_DiplomacyTreachery
162 (*dynamic_cast<const History_DiplomacyTreachery*>(a)));
163 case HERO_FINDS_ALLIES:
165 (new History_HeroFindsAllies
166 (*dynamic_cast<const History_HeroFindsAllies*>(a)));
169 (new History_EndTurn(*dynamic_cast<const History_EndTurn*>(a)));
170 case HERO_RUIN_EXPLORED:
172 (new History_HeroRuinExplored
173 (*dynamic_cast<const History_HeroRuinExplored*>(a)));
174 case HERO_REWARD_RUIN:
176 (new History_HeroRewardRuin
177 (*dynamic_cast<const History_HeroRewardRuin*>(a)));
183 History::History (XML_Helper *helper)
185 std::string type_str;
186 helper->getData(type_str, "type");
187 d_type = historyTypeFromString(type_str);
190 bool History::save(XML_Helper* helper) const
194 retval &= helper->openTag(History::d_tag);
195 retval &= saveContents(helper);
196 retval &= helper->closeTag();
201 bool History::saveContents(XML_Helper* helper) const
205 std::string type_str = historyTypeToString(History::Type(d_type));
206 retval &= helper->saveData("type", type_str);
207 retval &= doSave(helper);
212 //-----------------------------------------------------------------------------
215 History_StartTurn::History_StartTurn()
216 :History(History::START_TURN)
220 History_StartTurn::History_StartTurn(const History_StartTurn &history)
225 History_StartTurn::History_StartTurn(XML_Helper* helper)
230 History_StartTurn::~History_StartTurn()
234 std::string History_StartTurn::dump() const
238 s <<"player starts a turn" << "\n";
243 bool History_StartTurn::doSave(XML_Helper* helper) const
250 bool History_StartTurn::fillData()
255 //-----------------------------------------------------------------------------
258 History_FoundSage::History_FoundSage()
259 :History(History::FOUND_SAGE), d_hero("")
263 History_FoundSage::History_FoundSage(const History_FoundSage &history)
264 :History(history), d_hero(history.d_hero)
268 History_FoundSage::History_FoundSage(XML_Helper* helper)
271 helper->getData(d_hero, "hero");
274 History_FoundSage::~History_FoundSage()
278 std::string History_FoundSage::dump() const
282 s <<"player found a sage with hero " << d_hero<< "\n";
287 bool History_FoundSage::doSave(XML_Helper* helper) const
291 retval &= helper->saveData("hero", d_hero);
296 bool History_FoundSage::fillData(Hero *hero)
298 d_hero = hero->getName();
302 //-----------------------------------------------------------------------------
305 History_GoldTotal::History_GoldTotal()
306 :History(History::GOLD_TOTAL), d_gold(0)
310 History_GoldTotal::History_GoldTotal(const History_GoldTotal &history)
311 :History(history), d_gold(history.d_gold)
315 History_GoldTotal::History_GoldTotal(XML_Helper* helper)
318 helper->getData(d_gold, "gold");
321 History_GoldTotal::~History_GoldTotal()
325 std::string History_GoldTotal::dump() const
329 s <<"player has " << d_gold<< " gold pieces in total\n";
334 bool History_GoldTotal::doSave(XML_Helper* helper) const
338 retval &= helper->saveData("gold", d_gold);
343 bool History_GoldTotal::fillData(int gold)
349 //-----------------------------------------------------------------------------
350 //History_HeroEmerges
352 History_HeroEmerges::History_HeroEmerges()
353 :History(History::HERO_EMERGES), d_hero(""), d_hero_id(0), d_city("")
357 History_HeroEmerges::History_HeroEmerges(const History_HeroEmerges &history)
358 :History(history), d_hero(history.d_hero), d_hero_id(history.d_hero_id),
359 d_city(history.d_city)
363 History_HeroEmerges::History_HeroEmerges(XML_Helper* helper)
366 helper->getData(d_hero, "hero");
367 helper->getData(d_city, "city");
368 helper->getData(d_hero_id, "hero_id");
371 History_HeroEmerges::~History_HeroEmerges()
375 std::string History_HeroEmerges::dump() const
379 s <<"hero " << d_hero_id <<" (" << d_hero << ") emerges in " << d_city << "\n";
384 bool History_HeroEmerges::doSave(XML_Helper* helper) const
388 retval &= helper->saveData("hero", d_hero);
389 retval &= helper->saveData("city", d_city);
390 retval &= helper->saveData("hero_id", d_hero_id);
395 bool History_HeroEmerges::fillData(Hero *hero, City *city)
397 d_hero = hero->getName();
398 d_city = city->getName();
399 d_hero_id = hero->getId();
403 //-----------------------------------------------------------------------------
406 History_CityWon::History_CityWon()
407 :History(History::CITY_WON), d_city(0)
411 History_CityWon::History_CityWon(const History_CityWon &history)
412 :History(history), d_city(history.d_city)
416 History_CityWon::History_CityWon(XML_Helper* helper)
419 helper->getData(d_city, "city");
422 History_CityWon::~History_CityWon()
426 std::string History_CityWon::dump() const
430 s <<"city " << d_city << " has been won";
436 bool History_CityWon::doSave(XML_Helper* helper) const
440 retval &= helper->saveData("city", d_city);
445 bool History_CityWon::fillData(City *city)
447 d_city = city->getId();
451 //-----------------------------------------------------------------------------
452 //History_HeroCityWon
454 History_HeroCityWon::History_HeroCityWon()
455 :History(History::HERO_CITY_WON), d_hero(""), d_city("")
459 History_HeroCityWon::History_HeroCityWon(const History_HeroCityWon &history)
460 :History(history), d_hero(history.d_hero), d_city(history.d_city)
464 History_HeroCityWon::History_HeroCityWon(XML_Helper* helper)
467 helper->getData(d_city, "city");
468 helper->getData(d_hero, "hero");
471 History_HeroCityWon::~History_HeroCityWon()
475 std::string History_HeroCityWon::dump() const
479 s <<"city " << d_city << " has been won";
480 s <<" by " << d_hero;
486 bool History_HeroCityWon::doSave(XML_Helper* helper) const
490 retval &= helper->saveData("city", d_city);
491 retval &= helper->saveData("hero", d_hero);
496 bool History_HeroCityWon::fillData(Hero *hero, City *city)
498 d_city = city->getName();
499 d_hero = hero->getName();
503 //-----------------------------------------------------------------------------
506 History_CityRazed::History_CityRazed()
507 :History(History::CITY_RAZED), d_city(0)
511 History_CityRazed::History_CityRazed(const History_CityRazed &history)
512 :History(history), d_city(history.d_city)
516 History_CityRazed::History_CityRazed(XML_Helper* helper)
519 helper->getData(d_city, "city");
522 History_CityRazed::~History_CityRazed()
526 std::string History_CityRazed::dump() const
530 s <<"city " << d_city << " has been razed\n";
535 bool History_CityRazed::doSave(XML_Helper* helper) const
539 retval &= helper->saveData("city", d_city);
544 bool History_CityRazed::fillData(City *city)
546 d_city = city->getId();
550 //-----------------------------------------------------------------------------
551 //History_HeroQuestStarted
553 History_HeroQuestStarted::History_HeroQuestStarted()
554 :History(History::HERO_QUEST_STARTED), d_hero("")
558 History_HeroQuestStarted::History_HeroQuestStarted(const History_HeroQuestStarted &history)
559 :History(history), d_hero(history.d_hero)
563 History_HeroQuestStarted::History_HeroQuestStarted(XML_Helper* helper)
566 helper->getData(d_hero, "hero");
569 History_HeroQuestStarted::~History_HeroQuestStarted()
573 std::string History_HeroQuestStarted::dump() const
577 s <<"hero " << d_hero<< " gets a quest\n";
582 bool History_HeroQuestStarted::doSave(XML_Helper* helper) const
586 retval &= helper->saveData("hero", d_hero);
591 bool History_HeroQuestStarted::fillData(Hero *hero)
593 d_hero = hero->getName();
597 //-----------------------------------------------------------------------------
598 //History_HeroQuestCompleted
600 History_HeroQuestCompleted::History_HeroQuestCompleted()
601 :History(History::HERO_QUEST_COMPLETED), d_hero("")
605 History_HeroQuestCompleted::History_HeroQuestCompleted(const History_HeroQuestCompleted &history)
606 :History(history), d_hero(history.d_hero)
610 History_HeroQuestCompleted::History_HeroQuestCompleted(XML_Helper* helper)
613 helper->getData(d_hero, "hero");
616 History_HeroQuestCompleted::~History_HeroQuestCompleted()
620 std::string History_HeroQuestCompleted::dump() const
624 s <<"hero " << d_hero<< " gets a quest\n";
629 bool History_HeroQuestCompleted::doSave(XML_Helper* helper) const
633 retval &= helper->saveData("hero", d_hero);
638 bool History_HeroQuestCompleted::fillData(Hero *hero)
640 d_hero = hero->getName();
644 //-----------------------------------------------------------------------------
645 //History_HeroKilledInCity
647 History_HeroKilledInCity::History_HeroKilledInCity()
648 :History(History::HERO_KILLED_IN_CITY), d_hero(""), d_city("")
652 History_HeroKilledInCity::History_HeroKilledInCity(const History_HeroKilledInCity &history)
653 :History(history), d_hero(history.d_hero), d_city(history.d_city)
657 History_HeroKilledInCity::History_HeroKilledInCity(XML_Helper* helper)
660 helper->getData(d_hero, "hero");
661 helper->getData(d_city, "city");
664 History_HeroKilledInCity::~History_HeroKilledInCity()
668 std::string History_HeroKilledInCity::dump() const
672 s <<"hero " << d_hero << " died in city " << d_city << "\n";
677 bool History_HeroKilledInCity::doSave(XML_Helper* helper) const
681 retval &= helper->saveData("hero", d_hero);
682 retval &= helper->saveData("city", d_city);
687 bool History_HeroKilledInCity::fillData(Hero *hero, City *city)
689 d_hero = hero->getName();
690 d_city = city->getName();
694 //-----------------------------------------------------------------------------
695 //History_HeroKilledInBattle
697 History_HeroKilledInBattle::History_HeroKilledInBattle()
698 :History(History::HERO_KILLED_IN_BATTLE), d_hero("")
702 History_HeroKilledInBattle::History_HeroKilledInBattle(const History_HeroKilledInBattle &history)
703 :History(history), d_hero(history.d_hero)
707 History_HeroKilledInBattle::History_HeroKilledInBattle(XML_Helper* helper)
710 helper->getData(d_hero, "hero");
713 History_HeroKilledInBattle::~History_HeroKilledInBattle()
717 std::string History_HeroKilledInBattle::dump() const
721 s <<"hero " << d_hero<< " was killed in battle\n";
726 bool History_HeroKilledInBattle::doSave(XML_Helper* helper) const
730 retval &= helper->saveData("hero", d_hero);
735 bool History_HeroKilledInBattle::fillData(Hero *hero)
737 d_hero = hero->getName();
741 //-----------------------------------------------------------------------------
742 //History_Hero KilledSearching
744 History_HeroKilledSearching::History_HeroKilledSearching()
745 :History(History::HERO_KILLED_SEARCHING), d_hero("")
749 History_HeroKilledSearching::History_HeroKilledSearching(const History_HeroKilledSearching &history)
750 :History(history), d_hero(history.d_hero)
754 History_HeroKilledSearching::History_HeroKilledSearching(XML_Helper* helper)
757 helper->getData(d_hero, "hero");
760 History_HeroKilledSearching::~History_HeroKilledSearching()
764 std::string History_HeroKilledSearching::dump() const
768 s <<"hero " << d_hero<< " killed searching a ruin\n";
773 bool History_HeroKilledSearching::doSave(XML_Helper* helper) const
777 retval &= helper->saveData("hero", d_hero);
782 bool History_HeroKilledSearching::fillData(Hero *hero)
784 d_hero = hero->getName();
788 //-----------------------------------------------------------------------------
791 History_Score::History_Score()
792 :History(History::SCORE), d_score(0)
796 History_Score::History_Score(const History_Score &history)
797 :History(history), d_score(history.d_score)
801 History_Score::History_Score(XML_Helper* helper)
804 helper->getData(d_score, "score");
807 History_Score::~History_Score()
811 std::string History_Score::dump() const
815 s <<"player has a score of " << d_score<< "\n";
820 bool History_Score::doSave(XML_Helper* helper) const
824 retval &= helper->saveData("score", d_score);
829 bool History_Score::fillData(guint32 score)
835 //-----------------------------------------------------------------------------
836 //History_PlayerVanquished
838 History_PlayerVanquished::History_PlayerVanquished()
839 :History(History::PLAYER_VANQUISHED)
843 History_PlayerVanquished::History_PlayerVanquished(const History_PlayerVanquished &history)
848 History_PlayerVanquished::History_PlayerVanquished(XML_Helper* helper)
853 History_PlayerVanquished::~History_PlayerVanquished()
857 std::string History_PlayerVanquished::dump() const
861 s <<"player has been vanquished!\n";
866 bool History_PlayerVanquished::doSave(XML_Helper* helper) const
873 //-----------------------------------------------------------------------------
874 //History_DiplomacyPeace
876 History_DiplomacyPeace::History_DiplomacyPeace()
877 :History(History::DIPLOMATIC_PEACE), d_opponent_id(0)
881 History_DiplomacyPeace::History_DiplomacyPeace(const History_DiplomacyPeace &history)
882 :History(history), d_opponent_id(history.d_opponent_id)
886 History_DiplomacyPeace::History_DiplomacyPeace(XML_Helper* helper)
889 helper->getData(d_opponent_id, "opponent_id");
892 History_DiplomacyPeace::~History_DiplomacyPeace()
896 std::string History_DiplomacyPeace::dump() const
900 s <<"peace has been won with player " << d_opponent_id;
906 bool History_DiplomacyPeace::doSave(XML_Helper* helper) const
910 retval &= helper->saveData("opponent_id", d_opponent_id);
915 bool History_DiplomacyPeace::fillData(Player *opponent)
917 d_opponent_id = opponent->getId();
921 //-----------------------------------------------------------------------------
922 //History_DiplomacyWar
924 History_DiplomacyWar::History_DiplomacyWar()
925 :History(History::DIPLOMATIC_WAR), d_opponent_id(0)
929 History_DiplomacyWar::History_DiplomacyWar(const History_DiplomacyWar &history)
930 :History(history), d_opponent_id(history.d_opponent_id)
934 History_DiplomacyWar::History_DiplomacyWar(XML_Helper* helper)
937 helper->getData(d_opponent_id, "opponent_id");
940 History_DiplomacyWar::~History_DiplomacyWar()
944 std::string History_DiplomacyWar::dump() const
948 s <<"war has been declared with player " << d_opponent_id;
954 bool History_DiplomacyWar::doSave(XML_Helper* helper) const
958 retval &= helper->saveData("opponent_id", d_opponent_id);
963 bool History_DiplomacyWar::fillData(Player *opponent)
965 d_opponent_id = opponent->getId();
969 //-----------------------------------------------------------------------------
970 //History_DiplomacyTreachery
972 History_DiplomacyTreachery::History_DiplomacyTreachery()
973 :History(History::DIPLOMATIC_TREACHERY), d_opponent_id(0)
977 History_DiplomacyTreachery::History_DiplomacyTreachery(const History_DiplomacyTreachery &history)
978 :History(history), d_opponent_id(history.d_opponent_id)
982 History_DiplomacyTreachery::History_DiplomacyTreachery(XML_Helper* helper)
985 helper->getData(d_opponent_id, "opponent_id");
988 History_DiplomacyTreachery::~History_DiplomacyTreachery()
992 std::string History_DiplomacyTreachery::dump() const
996 s <<"treachery on player " << d_opponent_id;
1002 bool History_DiplomacyTreachery::doSave(XML_Helper* helper) const
1006 retval &= helper->saveData("opponent_id", d_opponent_id);
1011 bool History_DiplomacyTreachery::fillData(Player *opponent)
1013 d_opponent_id = opponent->getId();
1017 //-----------------------------------------------------------------------------
1018 //History_HeroFindsAllies
1020 History_HeroFindsAllies::History_HeroFindsAllies()
1021 :History(History::HERO_FINDS_ALLIES), d_hero("")
1025 History_HeroFindsAllies::History_HeroFindsAllies(const History_HeroFindsAllies &history)
1026 :History(history), d_hero(history.d_hero)
1030 History_HeroFindsAllies::History_HeroFindsAllies(XML_Helper* helper)
1033 helper->getData(d_hero, "hero");
1036 History_HeroFindsAllies::~History_HeroFindsAllies()
1040 std::string History_HeroFindsAllies::dump() const
1042 std::stringstream s;
1044 s <<"hero " << d_hero<< " finds some allies\n";
1049 bool History_HeroFindsAllies::doSave(XML_Helper* helper) const
1053 retval &= helper->saveData("hero", d_hero);
1058 bool History_HeroFindsAllies::fillData(Hero *hero)
1060 d_hero = hero->getName();
1064 //-----------------------------------------------------------------------------
1067 History_EndTurn::History_EndTurn()
1068 :History(History::END_TURN)
1072 History_EndTurn::History_EndTurn(const History_EndTurn &history)
1077 History_EndTurn::History_EndTurn(XML_Helper* helper)
1082 History_EndTurn::~History_EndTurn()
1086 std::string History_EndTurn::dump() const
1088 std::stringstream s;
1090 s <<"player ends a turn" << "\n";
1095 bool History_EndTurn::doSave(XML_Helper* helper) const
1102 bool History_EndTurn::fillData()
1106 //-----------------------------------------------------------------------------
1107 //History_HeroRuinExplored
1109 History_HeroRuinExplored::History_HeroRuinExplored()
1110 :History(History::HERO_RUIN_EXPLORED), d_hero(""), d_ruin(0)
1114 History_HeroRuinExplored::History_HeroRuinExplored(const History_HeroRuinExplored &history)
1115 :History(history), d_hero(history.d_hero), d_ruin(history.d_ruin)
1119 History_HeroRuinExplored::History_HeroRuinExplored(XML_Helper* helper)
1122 helper->getData(d_ruin, "ruin");
1123 helper->getData(d_hero, "hero");
1126 History_HeroRuinExplored::~History_HeroRuinExplored()
1130 std::string History_HeroRuinExplored::dump() const
1132 std::stringstream s;
1134 s <<"ruin " << d_ruin << " has been searched";
1135 s <<" by " << d_hero;
1141 bool History_HeroRuinExplored::doSave(XML_Helper* helper) const
1145 retval &= helper->saveData("ruin", d_ruin);
1146 retval &= helper->saveData("hero", d_hero);
1151 bool History_HeroRuinExplored::fillData(Hero *hero, Ruin *ruin)
1153 d_ruin = ruin->getId();
1154 d_hero = hero->getName();
1158 //-----------------------------------------------------------------------------
1159 //History_HeroRewardRuin
1161 History_HeroRewardRuin::History_HeroRewardRuin()
1162 :History(History::HERO_REWARD_RUIN), d_hero(""), d_ruin(0)
1166 History_HeroRewardRuin::History_HeroRewardRuin(const History_HeroRewardRuin &history)
1167 :History(history), d_hero(history.d_hero), d_ruin(history.d_ruin)
1171 History_HeroRewardRuin::History_HeroRewardRuin(XML_Helper* helper)
1174 helper->getData(d_ruin, "ruin");
1175 helper->getData(d_hero, "hero");
1178 History_HeroRewardRuin::~History_HeroRewardRuin()
1182 std::string History_HeroRewardRuin::dump() const
1184 std::stringstream s;
1186 s <<"the location of ruin " << d_ruin << " has been given ";
1187 s <<"to " << d_hero;
1193 bool History_HeroRewardRuin::doSave(XML_Helper* helper) const
1197 retval &= helper->saveData("ruin", d_ruin);
1198 retval &= helper->saveData("hero", d_hero);
1203 bool History_HeroRewardRuin::fillData(Hero *hero, Ruin *ruin)
1205 d_ruin = ruin->getId();
1206 d_hero = hero->getName();
1210 std::string History::historyTypeToString(const History::Type type)
1214 case History::START_TURN:
1215 return "History::START_TURN";
1216 case History::FOUND_SAGE:
1217 return "History::FOUND_SAGE";
1218 case History::GOLD_TOTAL:
1219 return "History::GOLD_TOTAL";
1220 case History::HERO_EMERGES:
1221 return "History::HERO_EMERGES";
1222 case History::CITY_WON:
1223 return "History::CITY_WON";
1224 case History::HERO_CITY_WON:
1225 return "History::HERO_CITY_WON";
1226 case History::CITY_RAZED:
1227 return "History::CITY_RAZED";
1228 case History::HERO_QUEST_STARTED:
1229 return "History::HERO_QUEST_STARTED";
1230 case History::HERO_QUEST_COMPLETED:
1231 return "History::HERO_QUEST_COMPLETED";
1232 case History::HERO_KILLED_IN_CITY:
1233 return "History::HERO_KILLED_IN_CITY";
1234 case History::HERO_KILLED_IN_BATTLE:
1235 return "History::HERO_KILLED_IN_BATTLE";
1236 case History::HERO_KILLED_SEARCHING:
1237 return "History::HERO_KILLED_SEARCHING";
1238 case History::SCORE:
1239 return "History::SCORE";
1240 case History::PLAYER_VANQUISHED:
1241 return "History::PLAYER_VANQUISHED";
1242 case History::DIPLOMATIC_PEACE:
1243 return "History::DIPLOMATIC_PEACE";
1244 case History::DIPLOMATIC_WAR:
1245 return "History::DIPLOMATIC_WAR";
1246 case History::DIPLOMATIC_TREACHERY:
1247 return "History::DIPLOMATIC_TREACHERY";
1248 case History::HERO_FINDS_ALLIES:
1249 return "History::HERO_FINDS_ALLIES";
1250 case History::END_TURN:
1251 return "History::END_TURN";
1252 case History::HERO_RUIN_EXPLORED:
1253 return "History::HERO_RUIN_EXPLORED";
1254 case History::HERO_REWARD_RUIN:
1255 return "History::HERO_REWARD_RUIN";
1257 return "History::START_TURN";
1260 History::Type History::historyTypeFromString(const std::string str)
1262 if (str.size() > 0 && isdigit(str.c_str()[0]))
1263 return History::Type(atoi(str.c_str()));
1264 if (str == "History::START_TURN")
1265 return History::START_TURN;
1266 else if (str == "History::FOUND_SAGE")
1267 return History::FOUND_SAGE;
1268 else if (str == "History::GOLD_TOTAL")
1269 return History::GOLD_TOTAL;
1270 else if (str == "History::HERO_EMERGES")
1271 return History::HERO_EMERGES;
1272 else if (str == "History::CITY_WON")
1273 return History::CITY_WON;
1274 else if (str== "History::HERO_CITY_WON")
1275 return History::HERO_CITY_WON;
1276 else if (str == "History::CITY_RAZED")
1277 return History::CITY_RAZED;
1278 else if (str == "History::HERO_QUEST_STARTED")
1279 return History::HERO_QUEST_STARTED;
1280 else if (str == "History::HERO_QUEST_COMPLETED")
1281 return History::HERO_QUEST_COMPLETED;
1282 else if (str == "History::HERO_KILLED_IN_CITY")
1283 return History::HERO_KILLED_IN_CITY;
1284 else if (str == "History::HERO_KILLED_IN_BATTLE")
1285 return History::HERO_KILLED_IN_BATTLE;
1286 else if (str == "History::HERO_KILLED_SEARCHING")
1287 return History::HERO_KILLED_SEARCHING;
1288 else if (str == "History::SCORE")
1289 return History::SCORE;
1290 else if (str == "History::PLAYER_VANQUISHED")
1291 return History::PLAYER_VANQUISHED;
1292 else if (str == "History::DIPLOMATIC_PEACE")
1293 return History::DIPLOMATIC_PEACE;
1294 else if (str == "History::DIPLOMATIC_WAR")
1295 return History::DIPLOMATIC_WAR;
1296 else if (str == "History::DIPLOMATIC_TREACHERY")
1297 return History::DIPLOMATIC_TREACHERY;
1298 else if (str == "History::HERO_FINDS_ALLIES")
1299 return History::HERO_FINDS_ALLIES;
1300 else if (str == "History::END_TURN")
1301 return History::END_TURN;
1302 else if (str == "History::HERO_RUIN_EXPLORED")
1303 return History::HERO_RUIN_EXPLORED;
1304 else if (str == "History::HERO_REWARD_RUIN")
1305 return History::HERO_REWARD_RUIN;
1306 return History::START_TURN;