TurnOrderProcessor.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 true if waiting player can act alongside with currently acting player
  20. bool canActSimultaneously(PlayerColor active, PlayerColor waiting) const;
  21. /// Returns true if left player must act before right player
  22. bool mustActBefore(PlayerColor left, PlayerColor right) const;
  23. /// Returns true if player is ready to start turn
  24. bool canStartTurn(PlayerColor which) const;
  25. /// Starts turn for all players that can start turn
  26. void tryStartTurnsForPlayers();
  27. void doStartNewDay();
  28. void doStartPlayerTurn(PlayerColor which);
  29. void doEndPlayerTurn(PlayerColor which);
  30. public:
  31. TurnOrderProcessor(CGameHandler * owner);
  32. /// Add new player to handle (e.g. on game start)
  33. void addPlayer(PlayerColor which);
  34. /// NetPack call-in
  35. bool onPlayerEndsTurn(PlayerColor which);
  36. /// Start game (or resume from save) and send YourTurn pack to player(s)
  37. void onGameStarted();
  38. /// Returns true if player turn has not started today
  39. bool playerAwaitsTurn(PlayerColor which) const;
  40. /// Returns true if player is currently making his turn
  41. bool playerMakingTurn(PlayerColor which) const;
  42. /// Returns true if player has finished his turn and is waiting for new day
  43. bool playerAwaitsNewDay(PlayerColor which) const;
  44. template <typename Handler> void serialize(Handler &h, const int version)
  45. {
  46. h & awaitingPlayers;
  47. h & actingPlayers;
  48. h & actedPlayers;
  49. }
  50. };