PlayerGotTurn.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * PlayerGotTurn.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 "PlayerGotTurn.h"
  12. #include <vcmi/events/EventBus.h>
  13. namespace events
  14. {
  15. SubscriptionRegistry<PlayerGotTurn> * PlayerGotTurn::getRegistry()
  16. {
  17. static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = make_unique<SubscriptionRegistry<PlayerGotTurn>>();
  18. return Instance.get();
  19. }
  20. void PlayerGotTurn::defaultExecute(const EventBus * bus, const ExecHandler & execHandler, PlayerColor & player)
  21. {
  22. CPlayerGotTurn event;
  23. event.setPlayer(player);
  24. bus->executeEvent(event, execHandler);
  25. player = event.getPlayer();
  26. }
  27. CPlayerGotTurn::CPlayerGotTurn() = default;
  28. bool CPlayerGotTurn::isEnabled() const
  29. {
  30. return true;
  31. }
  32. PlayerColor CPlayerGotTurn::getPlayer() const
  33. {
  34. return player;
  35. }
  36. void CPlayerGotTurn::setPlayer(const PlayerColor & value)
  37. {
  38. player = value;
  39. }
  40. int32_t CPlayerGotTurn::getPlayerIndex() const
  41. {
  42. return player.getNum();
  43. }
  44. void CPlayerGotTurn::setPlayerIndex(int32_t value)
  45. {
  46. player = PlayerColor(value);
  47. }
  48. }