1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

- Fixed mantis #1576 (doesn't hang game)

- Implemented output stream operator<< for various classes(BattleAction, BattleHex,...) to improve debugging and logging
This commit is contained in:
beegee1
2013-11-09 16:25:20 +00:00
parent 55577d0ac4
commit e01ef8e36a
8 changed files with 66 additions and 5 deletions

View File

@@ -103,3 +103,28 @@ bool PlayerColor::isValidPlayer() const
{
return num < PLAYER_LIMIT_I;
}
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
{
static const std::map<Battle::ActionType, std::string> actionTypeToString = boost::assign::map_list_of
(Battle::END_TACTIC_PHASE, "End tactic phase")
(Battle::INVALID, "Invalid")
(Battle::NO_ACTION, "No action")
(Battle::HERO_SPELL, "Hero spell")
(Battle::WALK, "Walk")
(Battle::DEFEND, "Defend")
(Battle::RETREAT, "Retreat")
(Battle::SURRENDER, "Surrender")
(Battle::WALK_AND_ATTACK, "Walk and attack")
(Battle::SHOOT, "Shoot")
(Battle::WAIT, "Wait")
(Battle::CATAPULT, "Catapult")
(Battle::MONSTER_SPELL, "Monster spell")
(Battle::BAD_MORALE, "Bad morale")
(Battle::STACK_HEAL, "Stack heal")
(Battle::DAEMON_SUMMONING, "Daemon summoning");
auto it = actionTypeToString.find(actionType);
if (it == actionTypeToString.end()) return os << "<Unknown type>";
else return os << it->second;
}