PlayerGotTurn.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 ExecHandler & execHandler, PlayerColor & player)
  22. {
  23. CPlayerGotTurn event;
  24. event.setPlayer(player);
  25. bus->executeEvent(event, execHandler);
  26. player = event.getPlayer();
  27. }
  28. CPlayerGotTurn::CPlayerGotTurn() = default;
  29. bool CPlayerGotTurn::isEnabled() const
  30. {
  31. return true;
  32. }
  33. PlayerColor CPlayerGotTurn::getPlayer() const
  34. {
  35. return player;
  36. }
  37. void CPlayerGotTurn::setPlayer(const PlayerColor & value)
  38. {
  39. player = value;
  40. }
  41. int32_t CPlayerGotTurn::getPlayerIndex() const
  42. {
  43. return player.getNum();
  44. }
  45. void CPlayerGotTurn::setPlayerIndex(int32_t value)
  46. {
  47. player = PlayerColor(value);
  48. }
  49. }
  50. VCMI_LIB_NAMESPACE_END