TurnOrderProcessor.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * TurnOrderProcessor.h, 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. #pragma once
  11. #include "../../lib/GameConstants.h"
  12. class CGameHandler;
  13. class TurnOrderProcessor : boost::noncopyable
  14. {
  15. CGameHandler * gameHandler;
  16. std::set<PlayerColor> awaitingPlayers;
  17. std::set<PlayerColor> actingPlayers;
  18. std::set<PlayerColor> actedPlayers;
  19. /// Returns date on which simturns must end unconditionally
  20. int simturnsTurnsLimit() const;
  21. /// Returns true if players are close enough to each other for their heroes to meet on this turn
  22. bool playersInContact(PlayerColor left, PlayerColor right) const;
  23. /// Returns true if waiting player can act alongside with currently acting player
  24. bool canActSimultaneously(PlayerColor active, PlayerColor waiting) const;
  25. /// Returns true if left player must act before right player
  26. bool mustActBefore(PlayerColor left, PlayerColor right) const;
  27. /// Returns true if player is ready to start turn
  28. bool canStartTurn(PlayerColor which) const;
  29. /// Starts turn for all players that can start turn
  30. void tryStartTurnsForPlayers();
  31. void doStartNewDay();
  32. void doStartPlayerTurn(PlayerColor which);
  33. void doEndPlayerTurn(PlayerColor which);
  34. bool isPlayerAwaitsTurn(PlayerColor which) const;
  35. bool isPlayerMakingTurn(PlayerColor which) const;
  36. bool isPlayerAwaitsNewDay(PlayerColor which) const;
  37. public:
  38. TurnOrderProcessor(CGameHandler * owner);
  39. /// Add new player to handle (e.g. on game start)
  40. void addPlayer(PlayerColor which);
  41. /// NetPack call-in
  42. bool onPlayerEndsTurn(PlayerColor which);
  43. /// Ends player turn and removes this player from turn order
  44. void onPlayerEndsGame(PlayerColor which);
  45. /// Start game (or resume from save) and send PlayerStartsTurn pack to player(s)
  46. void onGameStarted();
  47. template<typename Handler>
  48. void serialize(Handler & h, const int version)
  49. {
  50. h & awaitingPlayers;
  51. h & actingPlayers;
  52. h & actedPlayers;
  53. }
  54. };