IGameServer.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * IGameServer.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/serializer/GameConnectionID.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class PlayerColor;
  14. struct CPackForClient;
  15. VCMI_LIB_NAMESPACE_END
  16. enum class EServerState : ui8
  17. {
  18. LOBBY,
  19. GAMEPLAY,
  20. SHUTDOWN
  21. };
  22. /// Interface through which GameHandler can interact with server that controls it
  23. class IGameServer
  24. {
  25. public:
  26. virtual ~IGameServer() = default;
  27. virtual void setState(EServerState value) = 0;
  28. virtual EServerState getState() const = 0;
  29. virtual bool isPlayerHost(const PlayerColor & color) const = 0;
  30. virtual bool hasPlayerAt(PlayerColor player, GameConnectionID connectionID) const = 0;
  31. virtual bool hasBothPlayersAtSameConnection(PlayerColor left, PlayerColor right) const = 0;
  32. virtual void applyPack(CPackForClient & pack) = 0;
  33. virtual void sendPack(CPackForClient & pack, GameConnectionID connectionID) = 0;
  34. };