PlayerGotTurn.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. VCMI_LIB_NAMESPACE_BEGIN
  14. namespace events
  15. {
  16. SubscriptionRegistry<PlayerGotTurn> * PlayerGotTurn::getRegistry()
  17. {
  18. static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = std::make_unique<SubscriptionRegistry<PlayerGotTurn>>();
  19. return Instance.get();
  20. }
  21. void PlayerGotTurn::defaultExecute(const EventBus * bus, const PlayerColor & player)
  22. {
  23. CPlayerGotTurn event;
  24. event.setPlayer(player);
  25. bus->executeEvent(event);
  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. }
  49. VCMI_LIB_NAMESPACE_END