ConnectX 3.0
ConnectX Game Suite
Loading...
Searching...
No Matches
GameSession Class Reference

#include <game_session.hpp>

Public Member Functions

 GameSession (uint32_t id, uint8_t rows, uint8_t cols, uint8_t num_players, uint8_t connect_length, const std::string &name="")
 
uint32_t getId () const
 
const std::string & getName () const
 
void setName (const std::string &name)
 
GameEnginegetEngine ()
 
const GameEnginegetEngine () const
 
uint8_t addPlayer (uint32_t connection_id)
 
void removePlayer (uint32_t connection_id)
 
std::optional< uint8_t > getPlayerId (uint32_t connection_id) const
 
const std::vector< uint32_t > & getConnections () const
 
bool isFull () const
 
size_t getPlayerCount () const
 
uint8_t getMaxPlayers () const
 

Detailed Description

Represents a single game instance on the server

Constructor & Destructor Documentation

◆ GameSession()

GameSession::GameSession ( uint32_t  id,
uint8_t  rows,
uint8_t  cols,
uint8_t  num_players,
uint8_t  connect_length,
const std::string &  name = "" 
)

Member Function Documentation

◆ addPlayer()

uint8_t GameSession::addPlayer ( uint32_t  connection_id)

Add a player to this game

Returns
assigned player_id or 0 if game is full

◆ getConnections()

const std::vector< uint32_t > & GameSession::getConnections ( ) const
inline

Get all connection IDs in this game

◆ getEngine() [1/2]

GameEngine & GameSession::getEngine ( )
inline

Get game engine

◆ getEngine() [2/2]

const GameEngine & GameSession::getEngine ( ) const
inline

◆ getId()

uint32_t GameSession::getId ( ) const
inline

Get game ID

◆ getMaxPlayers()

uint8_t GameSession::getMaxPlayers ( ) const
inline

Get max players

◆ getName()

const std::string & GameSession::getName ( ) const
inline

Get game name

◆ getPlayerCount()

size_t GameSession::getPlayerCount ( ) const
inline

Get current player count

◆ getPlayerId()

std::optional< uint8_t > GameSession::getPlayerId ( uint32_t  connection_id) const

Get player ID for a connection

◆ isFull()

bool GameSession::isFull ( ) const
inline

Check if game is full

◆ removePlayer()

void GameSession::removePlayer ( uint32_t  connection_id)

Remove a player from this game

◆ setName()

void GameSession::setName ( const std::string &  name)
inline

Set game name


The documentation for this class was generated from the following files: