37 explicit Room(
const std::string &
id,
const std::string &name =
"",
size_t maxPlayers = 4,
38 bool isPrivate =
false,
float gameSpeedMultiplier = 1.0f,
39 std::shared_ptr<EventBus> eventBus =
nullptr);
42 bool join(uint32_t playerId)
override;
44 bool leave(uint32_t playerId)
override;
45 std::string
getId()
const override {
return _id; };
52 std::vector<uint32_t>
getPlayers()
const override;
54 bool hasPlayer(uint32_t playerId)
const override;
88 void update(
float deltaTime);
94 void setHost(uint32_t playerId);
109 const std::string &message);
Interface for a game room.
Concrete implementation of IRoom with game instance management.
RoomInfo getInfo() const override
Get room information.
bool leave(uint32_t playerId) override
Remove a player from the room.
void broadcastChatMessage(uint32_t senderId, const std::string &senderName, const std::string &message)
Broadcast a chat message to all players in the room.
bool isFull() const override
Check if room is full.
bool tryMarkGameStartSent()
Atomically check and set GameStart sent flag (thread-safe)
std::shared_ptr< EventBus > _eventBus
std::vector< uint32_t > _spectators
bool join(uint32_t playerId) override
Join a player to the room.
bool isPrivate() const
Check if room is private.
void setState(RoomState state) override
Set the state of the room.
bool isGameStartSent() const
Check if GameStart has been sent.
std::shared_ptr< IGameLogic > getGameLogic() const
Get the game logic instance.
void requestStartGame()
Request to start the game (initiates countdown)
float getGameSpeedMultiplier() const
Get the game speed multiplier.
size_t getMaxPlayers() const override
Get maximum number of players allowed.
bool hasSpectator(uint32_t playerId) const override
Check if a spectator is in this room.
uint32_t getHost() const
Get the host player ID.
void setGameStartSent(bool sent)
Mark GameStart as sent.
std::vector< uint32_t > _players
void setHost(uint32_t playerId)
Set the host player ID.
std::string getName() const override
Get the room's display name.
std::vector< uint32_t > getPlayers() const override
Get list of player IDs in this room.
std::unique_ptr< ServerLoop > _gameLoop
std::string getId() const override
Get the room's unique identifier.
size_t getPlayerCount() const override
Get number of players currently in room.
RoomState getState() const override
Get current state of the room.
ServerLoop * getServerLoop() const
Get the server loop instance for this room.
float _gameSpeedMultiplier
std::shared_ptr< IGameLogic > _gameLogic
bool hasPlayer(uint32_t playerId) const override
Check if a player is in this room.
std::vector< uint32_t > getSpectators() const override
Get list of spectator IDs in this room.
void update(float deltaTime)
Update the room state (called by server loop)
bool startGame()
Start the game for this room.
bool joinAsSpectator(uint32_t playerId) override
Join a player to the room as a spectator.
Deterministic fixed-timestep game loop.
RoomState
State of a game room.
Information about a room.