CPlayerState.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * CPlayerState.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "CPlayerState.h"
  12. #include "CGameStateFwd.h"
  13. PlayerState::PlayerState()
  14. : color(-1), human(false), enteredWinningCheatCode(false),
  15. enteredLosingCheatCode(false), status(EPlayerStatus::INGAME)
  16. {
  17. setNodeType(PLAYER);
  18. }
  19. PlayerState::PlayerState(PlayerState && other):
  20. CBonusSystemNode(std::move(other)),
  21. color(other.color),
  22. human(other.human),
  23. team(other.team),
  24. resources(other.resources),
  25. enteredWinningCheatCode(other.enteredWinningCheatCode),
  26. enteredLosingCheatCode(other.enteredLosingCheatCode),
  27. status(other.status),
  28. daysWithoutCastle(other.daysWithoutCastle)
  29. {
  30. std::swap(visitedObjects, other.visitedObjects);
  31. std::swap(heroes, other.heroes);
  32. std::swap(towns, other.towns);
  33. std::swap(availableHeroes, other.availableHeroes);
  34. std::swap(dwellings, other.dwellings);
  35. std::swap(quests, other.quests);
  36. }
  37. std::string PlayerState::nodeName() const
  38. {
  39. return "Player " + color.getStrCap(false);
  40. }
  41. PlayerColor PlayerState::getColor() const
  42. {
  43. return color;
  44. }
  45. TeamID PlayerState::getTeam() const
  46. {
  47. return team;
  48. }
  49. bool PlayerState::isHuman() const
  50. {
  51. return human;
  52. }
  53. const IBonusBearer * PlayerState::accessBonuses() const
  54. {
  55. return this;
  56. }
  57. int PlayerState::getResourceAmount(int type) const
  58. {
  59. return vstd::atOrDefault(resources, static_cast<size_t>(type), 0);
  60. }