Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
Lobby Struct Reference

Information about the current lobby of players. More...

#include <sharedgamestate.hpp>

Public Member Functions

 Lobby ()
 Default Lobby constructor supports exactly 4 players. More...
 
 Lobby (int max_players)
 
 Lobby (const std::string &name, int max_players)
 
const boost::optional< LobbyPlayer > & getPlayer (int playerIndex) const
 Given a player's 1-indexed player index, this method returns a reference to the boost::optional<LobbyPlayer> that will contain the LobbyPlayer struct for that player if that player index has been assigned. More...
 
const boost::optional< LobbyPlayer > & getPlayer (EntityID id) const
 Returns a player's LobbyPlayer struct by the player's EntityID. More...
 
int numPlayersInLobby () const
 Returns the number of players in the lobby Note: use this method and note players.size() to determine the number of current players in the lobby! players.size() should always equal max_players. More...
 
 DEF_SERIALIZE (Archive &ar, unsigned int version)
 
std::string to_string (unsigned int tab_offset) const
 Generates a string representation of this Lobby struct. More...
 
std::string to_string () const
 

Data Fields

std::string name
 name of the lobby as set by the server More...
 
std::vector< boost::optional< LobbyPlayer > > players
 A vector of length max_players that maps a player's index (technically, index - 1 as player indices are 1-indexed) to their LobbyPlayer info struct (though since a player index could at present not be assigned, this maps to a boost::optional<LobbyPlayer>) More...
 
int max_players
 The maximum number of players that this game instance can support. More...
 

Detailed Description

Information about the current lobby of players.

Constructor & Destructor Documentation

◆ Lobby() [1/3]

Lobby::Lobby ( )
inline

Default Lobby constructor supports exactly 4 players.

◆ Lobby() [2/3]

Lobby::Lobby ( int  max_players)
inlineexplicit

◆ Lobby() [3/3]

Lobby::Lobby ( const std::string &  name,
int  max_players 
)
inline

Member Function Documentation

◆ DEF_SERIALIZE()

Lobby::DEF_SERIALIZE ( Archive &  ar,
unsigned int  version 
)
inline

◆ getPlayer() [1/2]

const boost::optional< LobbyPlayer > & Lobby::getPlayer ( EntityID  id) const

Returns a player's LobbyPlayer struct by the player's EntityID.

Parameters
idEntityID of the player whose LobbyPlayer struct is requested.
Returns
Reference to the boost::optional<LobbyPlayer> that contains the LobbyPlayer struct of the player with the given EntityID; if no player in the lobby has this EntityID, the boost::optional will be empty.

◆ getPlayer() [2/2]

const boost::optional< LobbyPlayer > & Lobby::getPlayer ( int  playerIndex) const

Given a player's 1-indexed player index, this method returns a reference to the boost::optional<LobbyPlayer> that will contain the LobbyPlayer struct for that player if that player index has been assigned.

Parameters
playerIndex1-indexed player index of the player whose LobbyPlayer struct is requested. (I.e., Player 1's 1-indexed player index is 1 though it will be stored at index 0 in the players vector)
Returns
Reference to the boost::optional<LobbyPlayer> that contains the LobbyPlayer struct of the player with the requested 1-indexed player index. If that player index has not been assigned, the boost::optional will be empty.

◆ numPlayersInLobby()

int Lobby::numPlayersInLobby ( ) const

Returns the number of players in the lobby Note: use this method and note players.size() to determine the number of current players in the lobby! players.size() should always equal max_players.

Returns
Number of current players in the lobby

◆ to_string() [1/2]

std::string Lobby::to_string ( ) const
inline

◆ to_string() [2/2]

std::string Lobby::to_string ( unsigned int  tab_offset) const

Generates a string representation of this Lobby struct.

Returns
std::string representation of this Lobby struct

Field Documentation

◆ max_players

int Lobby::max_players

The maximum number of players that this game instance can support.

◆ name

std::string Lobby::name

name of the lobby as set by the server

◆ players

std::vector<boost::optional<LobbyPlayer> > Lobby::players

A vector of length max_players that maps a player's index (technically, index - 1 as player indices are 1-indexed) to their LobbyPlayer info struct (though since a player index could at present not be assigned, this maps to a boost::optional<LobbyPlayer>)


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