~ubuntu-branches/ubuntu/maverick/lordsawar/maverick

« back to all changes in this revision

Viewing changes to src/history.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese
  • Date: 2010-04-10 09:29:33 UTC
  • mfrom: (1.1.9 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100410092933-23uq4dxig30kmtcw
Tags: 0.1.8-1
* New upstream release.
* Add misc:Depends for -data package.
* Bump Standards Version to 3.8.4. (No changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "heroproto.h"
25
25
#include "city.h"
26
26
#include "xmlhelper.h"
 
27
#include "ruin.h"
27
28
 
28
29
std::string History::d_tag = "history";
29
30
using namespace std;
86
87
      return (new History_HeroFindsAllies(helper));
87
88
    case END_TURN:
88
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));
89
94
    }
90
95
 
91
96
  return 0;
162
167
    case END_TURN:
163
168
      return 
164
169
        (new History_EndTurn(*dynamic_cast<const History_EndTurn*>(a)));
 
170
    case HERO_RUIN_EXPLORED:
 
171
      return 
 
172
        (new History_HeroRuinExplored
 
173
         (*dynamic_cast<const History_HeroRuinExplored*>(a)));
 
174
    case HERO_REWARD_RUIN:
 
175
      return 
 
176
        (new History_HeroRewardRuin
 
177
         (*dynamic_cast<const History_HeroRewardRuin*>(a)));
165
178
    }
166
179
 
167
180
  return 0;
1090
1103
{
1091
1104
  return true;
1092
1105
}
 
1106
//-----------------------------------------------------------------------------
 
1107
//History_HeroRuinExplored
 
1108
 
 
1109
History_HeroRuinExplored::History_HeroRuinExplored()
 
1110
:History(History::HERO_RUIN_EXPLORED), d_hero(""), d_ruin(0)
 
1111
{
 
1112
}
 
1113
 
 
1114
History_HeroRuinExplored::History_HeroRuinExplored(const History_HeroRuinExplored &history)
 
1115
:History(history), d_hero(history.d_hero), d_ruin(history.d_ruin)
 
1116
{
 
1117
}
 
1118
 
 
1119
History_HeroRuinExplored::History_HeroRuinExplored(XML_Helper* helper)
 
1120
:History(helper)
 
1121
{
 
1122
  helper->getData(d_ruin, "ruin");
 
1123
  helper->getData(d_hero, "hero");
 
1124
}
 
1125
 
 
1126
History_HeroRuinExplored::~History_HeroRuinExplored()
 
1127
{
 
1128
}
 
1129
 
 
1130
std::string History_HeroRuinExplored::dump() const
 
1131
{
 
1132
  std::stringstream s;
 
1133
 
 
1134
  s <<"ruin " << d_ruin << " has been searched";
 
1135
  s <<" by " << d_hero;
 
1136
  s <<"\n";
 
1137
 
 
1138
  return s.str();
 
1139
}
 
1140
 
 
1141
bool History_HeroRuinExplored::doSave(XML_Helper* helper) const
 
1142
{
 
1143
  bool retval = true;
 
1144
 
 
1145
  retval &= helper->saveData("ruin", d_ruin);
 
1146
  retval &= helper->saveData("hero", d_hero);
 
1147
 
 
1148
  return retval;
 
1149
}
 
1150
 
 
1151
bool History_HeroRuinExplored::fillData(Hero *hero, Ruin *ruin)
 
1152
{
 
1153
  d_ruin = ruin->getId();
 
1154
  d_hero = hero->getName();
 
1155
  return true;
 
1156
}
 
1157
 
 
1158
//-----------------------------------------------------------------------------
 
1159
//History_HeroRewardRuin
 
1160
 
 
1161
History_HeroRewardRuin::History_HeroRewardRuin()
 
1162
:History(History::HERO_REWARD_RUIN), d_hero(""), d_ruin(0)
 
1163
{
 
1164
}
 
1165
 
 
1166
History_HeroRewardRuin::History_HeroRewardRuin(const History_HeroRewardRuin &history)
 
1167
:History(history), d_hero(history.d_hero), d_ruin(history.d_ruin)
 
1168
{
 
1169
}
 
1170
 
 
1171
History_HeroRewardRuin::History_HeroRewardRuin(XML_Helper* helper)
 
1172
:History(helper)
 
1173
{
 
1174
  helper->getData(d_ruin, "ruin");
 
1175
  helper->getData(d_hero, "hero");
 
1176
}
 
1177
 
 
1178
History_HeroRewardRuin::~History_HeroRewardRuin()
 
1179
{
 
1180
}
 
1181
 
 
1182
std::string History_HeroRewardRuin::dump() const
 
1183
{
 
1184
  std::stringstream s;
 
1185
 
 
1186
  s <<"the location of ruin " << d_ruin << " has been given ";
 
1187
  s <<"to " << d_hero;
 
1188
  s <<"\n";
 
1189
 
 
1190
  return s.str();
 
1191
}
 
1192
 
 
1193
bool History_HeroRewardRuin::doSave(XML_Helper* helper) const
 
1194
{
 
1195
  bool retval = true;
 
1196
 
 
1197
  retval &= helper->saveData("ruin", d_ruin);
 
1198
  retval &= helper->saveData("hero", d_hero);
 
1199
 
 
1200
  return retval;
 
1201
}
 
1202
 
 
1203
bool History_HeroRewardRuin::fillData(Hero *hero, Ruin *ruin)
 
1204
{
 
1205
  d_ruin = ruin->getId();
 
1206
  d_hero = hero->getName();
 
1207
  return true;
 
1208
}
1093
1209
 
1094
1210
std::string History::historyTypeToString(const History::Type type)
1095
1211
{
1133
1249
      return "History::HERO_FINDS_ALLIES";
1134
1250
    case History::END_TURN:
1135
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";
1136
1256
    }
1137
1257
  return "History::START_TURN";
1138
1258
}
1179
1299
    return History::HERO_FINDS_ALLIES;
1180
1300
  else if (str == "History::END_TURN")
1181
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;
1182
1306
  return History::START_TURN;
1183
1307
}