R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
IRoom.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Created by hugo on 06/12/2025
4** File description:
5** IRoom.hpp
6*/
7
8#pragma once
9
10#include <cstdint>
11#include <string>
12#include <vector>
13
14namespace server {
15
20 enum class RoomState {
21 WAITING, // Waiting for players
22 STARTING, // Countdown before game starts
23 IN_PROGRESS, // Game is running
24 FINISHED // Game ended
25 };
26
31 struct RoomInfo {
32 std::string id;
33 std::string name;
36 size_t maxPlayers;
38 std::string hostPlayerId;
39 };
40
47 class IRoom {
48 public:
49 virtual ~IRoom() = default;
50
56 virtual bool join(uint32_t playerId) = 0;
57
63 virtual bool joinAsSpectator(uint32_t playerId) = 0;
64
70 virtual bool leave(uint32_t playerId) = 0;
71
76 virtual std::string getId() const = 0;
77
82 virtual std::string getName() const = 0;
83
88 virtual RoomState getState() const = 0;
89
94 virtual void setState(RoomState state) = 0;
95
100 virtual size_t getPlayerCount() const = 0;
101
106 virtual size_t getMaxPlayers() const = 0;
107
112 virtual bool isFull() const = 0;
113
118 virtual std::vector<uint32_t> getPlayers() const = 0;
119
124 virtual std::vector<uint32_t> getSpectators() const = 0;
125
131 virtual bool hasPlayer(uint32_t playerId) const = 0;
132
138 virtual bool hasSpectator(uint32_t playerId) const = 0;
139
144 virtual RoomInfo getInfo() const = 0;
145 };
146
147} // namespace server
Interface for a game room.
Definition IRoom.hpp:47
virtual std::vector< uint32_t > getPlayers() const =0
Get list of player IDs in this room.
virtual size_t getMaxPlayers() const =0
Get maximum number of players allowed.
virtual bool hasPlayer(uint32_t playerId) const =0
Check if a player is in this room.
virtual void setState(RoomState state)=0
Set the state of the room.
virtual bool isFull() const =0
Check if room is full.
virtual std::vector< uint32_t > getSpectators() const =0
Get list of spectator IDs in this room.
virtual bool joinAsSpectator(uint32_t playerId)=0
Join a player to the room as a spectator.
virtual std::string getId() const =0
Get the room's unique identifier.
virtual bool hasSpectator(uint32_t playerId) const =0
Check if a spectator is in this room.
virtual RoomState getState() const =0
Get current state of the room.
virtual bool join(uint32_t playerId)=0
Join a player to the room.
virtual size_t getPlayerCount() const =0
Get number of players currently in room.
virtual RoomInfo getInfo() const =0
Get room information.
virtual ~IRoom()=default
virtual bool leave(uint32_t playerId)=0
Remove a player from the room.
virtual std::string getName() const =0
Get the room's display name.
RoomState
State of a game room.
Definition IRoom.hpp:20
Information about a room.
Definition IRoom.hpp:31
size_t maxPlayers
Definition IRoom.hpp:36
size_t currentPlayers
Definition IRoom.hpp:35
std::string hostPlayerId
Definition IRoom.hpp:38
std::string id
Definition IRoom.hpp:32
std::string name
Definition IRoom.hpp:33
RoomState state
Definition IRoom.hpp:34