PRooFPS-dd Dev Doc 1.0
PRooFPS-dd Developer Documentation
Loading...
Searching...
No Matches
proofps_dd::GameMode Class Referenceabstract

GameMode class represent the Frag Table and the winning condition checks. More...

Detailed Description

GameMode class represent the Frag Table and the winning condition checks.

It identifies players by their name thus it is essential that all players have unique name.

TODO: not sure exactly about my original idea, but definitely the current design should be changed a bit. GameMode should NOT contain anything related to "frags", it should be more abstract. It should be called scores, frag limit shall be score limit, which is the round win limit in TRG but frag limit otherwise. Frags, frag table, etc. should be introduced in derived class such as DeathMatchMode. However this definitely won't be "fixed" in 2024.

TODO: regarding fetchConfig(): probably GameMode should autonomuously handle relevant config, including validation. However, for this to happen, it should implement an IConfigHandler so Config class can invoke its validateConfig() function when Config::validate() is invoked. On the long run this mechanism should be extended to other classes as well where the CVAR definitions are also present.

Definition at line 92 of file GameMode.h.

#include <GameMode.h>

+ Inheritance diagram for proofps_dd::GameMode:

Public Member Functions

CConsole & getConsole () const
 
virtual ~GameMode ()
 
virtual void fetchConfig (PGEcfgProfiles &cfgProfiles, pge_network::PgeINetwork &network)
 Fetches configuration from the given PGEcfgProfiles instance.
 
GameModeType getGameModeType () const
 
const char * getGameModeTypeName () const
 
const std::chrono::time_point< std::chrono::steady_clock > & getResetTime () const
 
unsigned int getTimeLimitSecs () const
 
void setTimeLimitSecs (unsigned int secs)
 Set the time limit for the game.
 
unsigned int getTimeRemainingMillisecs () const
 
void clientUpdateTimeRemainingMillisecs (const unsigned int &nRemMillisecs, pge_network::PgeINetwork &network)
 Updates the remaining time on client side, based on the remaining time received from server.
 
virtual void restart (pge_network::PgeINetwork &network)
 Similar to restartWithoutRemovingPlayers() but it also removes all players from this GameMode instance.
 
virtual void restartWithoutRemovingPlayers (pge_network::PgeINetwork &network, const proofps_dd::GameRestartType_KeepPlayers &eRestartType)
 Resets winning time and winning condition, also zeros out relevant members of PlayersTableRow for all players.
 
virtual bool serverCheckAndUpdateWinningConditions (pge_network::PgeINetwork &network)
 Evaluates conditions to see if game is won or not.
 
void clientReceiveAndUpdateWinningConditions (pge_network::PgeINetwork &network, bool bGameSessionWon)
 Handles server's update about current game session goal, e.g.
 
virtual void serverTickUpdateWinningConditions (pge_network::PgeINetwork &network)
 Shall be invoked regularly (per tick or per frame) at the end of server tick or frame loop so hasJustBeenWonThisTick() and further functionalities in derived classes can work properly.
 
virtual void clientTickUpdateWinningConditions (pge_network::PgeINetwork &network)
 Shall be invoked regularly (per tick or per frame) at the end of client tick or frame loop so hasJustBeenWonThisTick() and further functionalities in derived classes can work properly.
 
bool isGameWon () const
 Returns the current game session win state i.e.
 
bool wasGameWonAlreadyInPreviousTick () const
 Returns if the current game session was already won in the previous tick.
 
bool hasJustBeenWonThisTick () const
 Returns if the current game session has been just detected as won in this tick i.e.
 
const std::chrono::time_point< std::chrono::steady_clock > & getWinTime () const
 
const std::list< PlayersTableRow > & getPlayersTable () const
 
const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & getExternalPlayersContainer () const
 
virtual bool addPlayer (const Player &player, pge_network::PgeINetwork &network)=0
 Adds the specified player.
 
virtual bool updatePlayer (const Player &player, pge_network::PgeINetwork &network)=0
 Updates data for the specified player.
 
virtual bool removePlayer (const Player &player, pge_network::PgeINetwork &network)=0
 Removes data for the specified player.
 
bool renamePlayer (const std::string &sOldName, const std::string &sNewName)
 Renames the player.
 
virtual bool isTeamBasedGame () const =0
 Derived class shall return false if it is non-team-based game, otherwise true.
 
virtual bool isRoundBased () const =0
 
virtual bool isRespawnAllowedAfterDie () const =0
 
virtual bool isPlayerAllowedForGameplay (const Player &player) const
 Checks if given player is allowed for gameplay.
 
virtual bool isPlayerMovementAllowed () const
 
unsigned int getSpectatorModePlayersCount () const
 
void text (PR00FsUltimateRenderingEngine &pure, const std::string &s, int x, int y) const
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 
static GameModecreateGameMode (GameModeType gm, const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 Similar to singleton design pattern, there is always maximum one instance.
 
static GameModegetGameMode ()
 
static bool isTeamBasedGame (GameModeType gm)
 
static bool isRoundBased (GameModeType gm)
 
static const char * getGameModeTypeName (GameModeType gm)
 
static GameModeType getGameModeTypeFromConfig (PGEcfgProfiles &cfgProfiles)
 
static const char * getRank (const PlayersTableRow &row)
 

Static Public Attributes

static constexpr char * szCvarSvGamemode = "sv_gamemode"
 
static constexpr char * szCvarSvGmTimeLimit = "sv_gm_timelimit_secs"
 
static constexpr char * szCvarSvDmFragLimit = "sv_dm_fraglimit"
 
static constexpr char * szCvarSvRgmRoundWinLimit = "sv_rgm_roundwinlimit"
 
static constexpr int nSvGmTimeLimitSecsDef = 0
 
static constexpr int nSvGmTimeLimitSecsMin = 0
 
static constexpr int nSvGmTimeLimitSecsMax = 60 * 60 * 24
 
static constexpr int nSvDmFragLimitDef = 10
 
static constexpr int nSvDmFragLimitMin = 0
 
static constexpr int nSvDmFragLimitMax = 999
 
static constexpr int nSvRgmRoundWinLimitDef = 5
 
static constexpr int nSvRgmRoundWinLimitMin = 1
 
static constexpr int nSvRgmRoundWinLimitMax = 999
 

Protected Member Functions

 GameMode (GameModeType gm, const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 
 GameMode (const GameMode &)=delete
 
GameModeoperator= (const GameMode &)=delete
 
 GameMode (GameMode &&)=delete
 
GameMode && operator= (GameMode &&)=delete
 
virtual bool serverSendGameSessionStateToClient (pge_network::PgeINetwork &network, const pge_network::PgeNetworkConnectionHandle &connHandle)
 
virtual bool serverSendGameSessionStateToClients (pge_network::PgeINetwork &network, const proofps_dd::GameRestartType_KeepPlayers &eRestartType)
 
void handleEventGameWon (pge_network::PgeINetwork &network)
 

Protected Attributes

std::chrono::time_point< std::chrono::steady_clock > m_timeWin
 
std::list< PlayersTableRowm_players
 
const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & m_mapPlayersExternal
 
bool m_bWon { false }
 
bool m_bWonPrevious { false }
 
GameModeType m_gameModeType
 

Private Attributes

std::chrono::time_point< std::chrono::steady_clock > m_timeReset
 
unsigned int m_nTimeLimitSecs {}
 

Static Private Attributes

static std::unique_ptr< GameModem_gamemode {}
 

Constructor & Destructor Documentation

◆ ~GameMode()

proofps_dd::GameMode::~GameMode ( )
virtual

Definition at line 192 of file GameMode.cpp.

◆ GameMode() [1/3]

proofps_dd::GameMode::GameMode ( proofps_dd::GameModeType gm,
const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & mapPlayers )
protected

Definition at line 450 of file GameMode.cpp.

◆ GameMode() [2/3]

proofps_dd::GameMode::GameMode ( const GameMode & )
protecteddelete

◆ GameMode() [3/3]

proofps_dd::GameMode::GameMode ( GameMode && )
protecteddelete

Member Function Documentation

◆ addPlayer()

virtual bool proofps_dd::GameMode::addPlayer ( const Player & player,
pge_network::PgeINetwork & network )
pure virtual

Adds the specified player.

In case of server instance, if the added player is a client, it SHALL immediately send game win condition to this client using serverSendGameSessionStateToClient(). In case of server instance, it SHALL automatically evaluate winning condition using serverCheckAndUpdateWinningConditions() after adding the player. Note that once a game is won, it stays won even if players are updated to fail the winning conditions, until explicit call to restart().

Note that GameMode does not ensure that a spectating player cannot win a game. The game shall ensure that the player does not gain any frags while in spectator mode! Therefore, if the added player already has enough frags to flip game won state, the game will go into won state, regardless of the player's spectating state!

Fails if a player with same name is already added.

Returns
True if added the new player, false otherwise.

Implemented in proofps_dd::DeathMatchMode, proofps_dd::TeamDeathMatchMode, proofps_dd::TeamRoundGameMode, and SpecialGameMode.

◆ clientReceiveAndUpdateWinningConditions()

void proofps_dd::GameMode::clientReceiveAndUpdateWinningConditions ( pge_network::PgeINetwork & network,
bool bGameSessionWon )

Handles server's update about current game session goal, e.g.

game is won. Server sends out such notification occasionally only, when something relevant has changed about the current game session.

This function is for client instance only.

Parameters
bGameSessionWonTrue if the current game session goal has been just reached, false otherwise.

Definition at line 322 of file GameMode.cpp.

◆ clientTickUpdateWinningConditions()

void proofps_dd::GameMode::clientTickUpdateWinningConditions ( pge_network::PgeINetwork & network)
virtual

Shall be invoked regularly (per tick or per frame) at the end of client tick or frame loop so hasJustBeenWonThisTick() and further functionalities in derived classes can work properly.

This function is for client instance only.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 350 of file GameMode.cpp.

◆ clientUpdateTimeRemainingMillisecs()

void proofps_dd::GameMode::clientUpdateTimeRemainingMillisecs ( const unsigned int & nRemMillisecs,
pge_network::PgeINetwork & network )

Updates the remaining time on client side, based on the remaining time received from server.

Basically it corrects the game restart time on client side so client will have the roughly same game restart time as the server.

Parameters
nRemMillisecsRemaining time in milliseconds, from server.
networkPGE network instance to be used to know if we are server or client.

Definition at line 247 of file GameMode.cpp.

◆ createGameMode()

proofps_dd::GameMode * proofps_dd::GameMode::createGameMode ( proofps_dd::GameModeType gm,
const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & mapPlayers )
static

Similar to singleton design pattern, there is always maximum one instance.

However, if there is an already existing instance, it automatically gets destroyed before the new one is created. This makes sure we always get a fresh object built up from scratch, and we can forget about the previous one. This is exactly the mechanism we need for GameMode, from the application's perspective.

Parameters
gmType of game to create.
mapPlayersPlayers container, sometimes might be needed to fetch some attributes of players (e.g. HP).
Returns
Raw pointer to the created GameMode instance. Shall not be stored by anyone but always queried using getGameMode().

Definition at line 56 of file GameMode.cpp.

◆ fetchConfig()

void proofps_dd::GameMode::fetchConfig ( PGEcfgProfiles & cfgProfiles,
pge_network::PgeINetwork & network )
virtual

Fetches configuration from the given PGEcfgProfiles instance.

Derived class shall extend this function by overriding and calling this parent implementation from the specialized implementation.

For now it does not do validation, as all validations are currently implemented in the Config class. TODO: on the long run, validation should be also done, by proper planning and implementing an IConfigHandler interface, as described in the comment above.

Parameters
cfgProfilesThe current user config profile from where we can fetch value of GameMode-specific CVARs.
networkPGE network instance to be used to know if we are server or client.

Reimplemented in proofps_dd::DeathMatchMode, and proofps_dd::TeamRoundGameMode.

Definition at line 196 of file GameMode.cpp.

◆ getConsole()

CConsole & proofps_dd::GameMode::getConsole ( ) const

Definition at line 187 of file GameMode.cpp.

◆ getExternalPlayersContainer()

const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & proofps_dd::GameMode::getExternalPlayersContainer ( ) const
Returns
The external container storing connected players, that was passed in createGameMode() / ctor.

Definition at line 381 of file GameMode.cpp.

◆ getGameMode()

proofps_dd::GameMode * proofps_dd::GameMode::getGameMode ( )
static
Returns
The last created GameMode instance created by createGameMode(). nullptr if no instance created yet.

Definition at line 82 of file GameMode.cpp.

◆ getGameModeType()

proofps_dd::GameModeType proofps_dd::GameMode::getGameModeType ( ) const

Definition at line 203 of file GameMode.cpp.

◆ getGameModeTypeFromConfig()

proofps_dd::GameModeType proofps_dd::GameMode::getGameModeTypeFromConfig ( PGEcfgProfiles & cfgProfiles)
static

Definition at line 126 of file GameMode.cpp.

◆ getGameModeTypeName() [1/2]

const char * proofps_dd::GameMode::getGameModeTypeName ( ) const

Definition at line 208 of file GameMode.cpp.

◆ getGameModeTypeName() [2/2]

const char * proofps_dd::GameMode::getGameModeTypeName ( proofps_dd::GameModeType gm)
static

Definition at line 111 of file GameMode.cpp.

◆ getLoggerModuleName()

const char * proofps_dd::GameMode::getLoggerModuleName ( )
static

Definition at line 51 of file GameMode.cpp.

◆ getPlayersTable()

const std::list< proofps_dd::PlayersTableRow > & proofps_dd::GameMode::getPlayersTable ( ) const
Returns
Player table, which is basically the frag table in specific game modes, but here at this abstract level it has a more general name.

Definition at line 376 of file GameMode.cpp.

◆ getRank()

const char * proofps_dd::GameMode::getRank ( const PlayersTableRow & row)
static

Definition at line 142 of file GameMode.cpp.

◆ getResetTime()

const std::chrono::time_point< std::chrono::steady_clock > & proofps_dd::GameMode::getResetTime ( ) const

Definition at line 213 of file GameMode.cpp.

◆ getSpectatorModePlayersCount()

unsigned int proofps_dd::GameMode::getSpectatorModePlayersCount ( ) const
Returns
Number of players in spectator mode (team id is irrelevant).

Definition at line 428 of file GameMode.cpp.

◆ getTimeLimitSecs()

unsigned int proofps_dd::GameMode::getTimeLimitSecs ( ) const
Returns
Configured time limit previously set by setTimeLimitSecs(). 0 means no time limit.

Definition at line 218 of file GameMode.cpp.

◆ getTimeRemainingMillisecs()

unsigned int proofps_dd::GameMode::getTimeRemainingMillisecs ( ) const
Returns
Milliseconds remaining until time limit is reached, calculated from the current time and last reset time (getResetTime()). 0 if there is no time limit set, or if the game was not yet reset, or if the time limit has been already reached, or the game has been won for any reason.

Definition at line 228 of file GameMode.cpp.

◆ getWinTime()

const std::chrono::time_point< std::chrono::steady_clock > & proofps_dd::GameMode::getWinTime ( ) const
Returns
Timestamp of moment when current game was won by a player. It is Epoch time 0 if the game is not yet won.

Definition at line 371 of file GameMode.cpp.

◆ handleEventGameWon()

void proofps_dd::GameMode::handleEventGameWon ( pge_network::PgeINetwork & network)
protected

Definition at line 494 of file GameMode.cpp.

◆ hasJustBeenWonThisTick()

bool proofps_dd::GameMode::hasJustBeenWonThisTick ( ) const

Returns if the current game session has been just detected as won in this tick i.e.

it was not yet won in the previous tick (wasGameWonAlreadyInPreviousTick() returns false) but now is won in the current tick (isGameWon() returns true).

This function is the recommended way for both server and client instances to check for and handle the change of winning state.

It is true only for a short period of time slice which can be 1 tick or 1 frame, depending on how often your game instance invokes either serverCheckAndUpdateWinningConditions() or clientTickUpdateWinningConditions().

Definition at line 366 of file GameMode.cpp.

◆ isGameWon()

bool proofps_dd::GameMode::isGameWon ( ) const

Returns the current game session win state i.e.

game goal is reached or not.

Note that once a game is won, it stays won even if all players are removed, until explicit call to restart() or restartWithoutRemovingPlayers().

Returns
True if current game session is won (goal reached), false otherwise.

Definition at line 356 of file GameMode.cpp.

◆ isPlayerAllowedForGameplay()

bool proofps_dd::GameMode::isPlayerAllowedForGameplay ( const Player & player) const
virtual

Checks if given player is allowed for gameplay.

For example, in a team-based game mode, server can freeze player actions when no team is assigned to the player. But it also checks for spectator mode.

Can be used by both server and client instances. Must also work properly on client-side, since in player-follow spectating view, this function is used to determine which players can be spectated.

Returns
True if player is ready and active for gameplay in the current game mode, false otherwise.

Reimplemented in proofps_dd::DeathMatchMode, proofps_dd::TeamDeathMatchMode, and SpecialGameMode.

Definition at line 418 of file GameMode.cpp.

◆ isPlayerMovementAllowed()

bool proofps_dd::GameMode::isPlayerMovementAllowed ( ) const
virtual
Returns
True if player movement is allowed, false otherwise.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 423 of file GameMode.cpp.

◆ isRespawnAllowedAfterDie()

virtual bool proofps_dd::GameMode::isRespawnAllowedAfterDie ( ) const
pure virtual

◆ isRoundBased() [1/2]

virtual bool proofps_dd::GameMode::isRoundBased ( ) const
pure virtual

◆ isRoundBased() [2/2]

bool proofps_dd::GameMode::isRoundBased ( GameModeType gm)
static

Definition at line 100 of file GameMode.cpp.

◆ isTeamBasedGame() [1/2]

virtual bool proofps_dd::GameMode::isTeamBasedGame ( ) const
pure virtual

Derived class shall return false if it is non-team-based game, otherwise true.

Implemented in proofps_dd::DeathMatchMode, proofps_dd::TeamDeathMatchMode, and SpecialGameMode.

◆ isTeamBasedGame() [2/2]

bool proofps_dd::GameMode::isTeamBasedGame ( GameModeType gm)
static

Definition at line 87 of file GameMode.cpp.

◆ operator=() [1/2]

GameMode & proofps_dd::GameMode::operator= ( const GameMode & )
protecteddelete

◆ operator=() [2/2]

GameMode && proofps_dd::GameMode::operator= ( GameMode && )
protecteddelete

◆ removePlayer()

virtual bool proofps_dd::GameMode::removePlayer ( const Player & player,
pge_network::PgeINetwork & network )
pure virtual

Removes data for the specified player.

Fails if player with same cannot be found.

Does not evaluate winning conditions, since once a game is won, it stays won even if all players are removed, until explicit call to restart().

Returns
True if removed the existing player, false otherwise.

Implemented in proofps_dd::DeathMatchMode, proofps_dd::TeamRoundGameMode, and SpecialGameMode.

◆ renamePlayer()

bool proofps_dd::GameMode::renamePlayer ( const std::string & sOldName,
const std::string & sNewName )

Renames the player.

All players must have unique name. The function fails if there is already a player having the same name as sNewName, or if there was no such player with name as sOldName.

Parameters
sOldNameThe previous name of the player that we want to change.
sNewNameThe new name of the player we want to change to.
Returns
True if rename was successful, false otherwise.

Definition at line 386 of file GameMode.cpp.

◆ restart()

void proofps_dd::GameMode::restart ( pge_network::PgeINetwork & network)
virtual

Similar to restartWithoutRemovingPlayers() but it also removes all players from this GameMode instance.

Used by both server and clients. A typical situation for clients to invoke this is when they get disconnected from server.

Parameters
networkPGE network instance to be used to send out MsgGameSessionStateFromServer to clients.

Definition at line 263 of file GameMode.cpp.

◆ restartWithoutRemovingPlayers()

void proofps_dd::GameMode::restartWithoutRemovingPlayers ( pge_network::PgeINetwork & network,
const proofps_dd::GameRestartType_KeepPlayers & eRestartType )
virtual

Resets winning time and winning condition, also zeros out relevant members of PlayersTableRow for all players.

It is recommended to first invoke updatePlayer() for all players with zeroed values and then call this.

Used by both server and clients: clients invoke it upon receiving MsgGameSessionStateFromServer.

Parameters
networkPGE network instance to be used to send out MsgGameSessionStateFromServer to clients.
eRestartTypePlayers stats are defaulted depending on restart type. Cannot be GameRestartType_KeepPlayers::None.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 270 of file GameMode.cpp.

◆ serverCheckAndUpdateWinningConditions()

bool proofps_dd::GameMode::serverCheckAndUpdateWinningConditions ( pge_network::PgeINetwork & network)
virtual

Evaluates conditions to see if game is won or not.

Shall be invoked regularly (per tick or per frame) at the beginning of server tick or frame loop so hasJustBeenWonThisTick() can work properly.

This class checks elapsed game session time against time limit, if any set. Derived class shall extend this function by overriding and calling this parent implementation from the specialized implementation.

A game shall not be won without any players, so at least 1 player needs to be present to win any game. Note that once a game is won, it stays won even if all players are removed, until explicit call to restart() or restartWithoutRemovingPlayers().

This function is for server instance only. It also sends out MsgGameSessionStateFromServer to all clients in case game session state is changed as a result of the call.

Parameters
networkPGE network instance to be used to send out MsgGameSessionStateFromServer if needed.
Returns
True if game is won, false otherwise.

Reimplemented in proofps_dd::DeathMatchMode, proofps_dd::TeamDeathMatchMode, and proofps_dd::TeamRoundGameMode.

Definition at line 299 of file GameMode.cpp.

◆ serverSendGameSessionStateToClient()

bool proofps_dd::GameMode::serverSendGameSessionStateToClient ( pge_network::PgeINetwork & network,
const pge_network::PgeNetworkConnectionHandle & connHandle )
protectedvirtual

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 458 of file GameMode.cpp.

◆ serverSendGameSessionStateToClients()

bool proofps_dd::GameMode::serverSendGameSessionStateToClients ( pge_network::PgeINetwork & network,
const proofps_dd::GameRestartType_KeepPlayers & eRestartType )
protectedvirtual

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 476 of file GameMode.cpp.

◆ serverTickUpdateWinningConditions()

void proofps_dd::GameMode::serverTickUpdateWinningConditions ( pge_network::PgeINetwork & network)
virtual

Shall be invoked regularly (per tick or per frame) at the end of server tick or frame loop so hasJustBeenWonThisTick() and further functionalities in derived classes can work properly.

This function is for server instance only.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 344 of file GameMode.cpp.

◆ setTimeLimitSecs()

void proofps_dd::GameMode::setTimeLimitSecs ( unsigned int secs)

Set the time limit for the game.

If time limit expires, the winner is the player with most frags, even if frag limit is not set or not reached. Note: behavior is unspecified if this value is changed on-the-fly during a game. For now, please also call restart() explicitly.

Parameters
secsThe time limit in seconds. If 0, there is no time limit.

Definition at line 223 of file GameMode.cpp.

◆ text()

void proofps_dd::GameMode::text ( PR00FsUltimateRenderingEngine & pure,
const std::string & s,
int x,
int y ) const

Definition at line 441 of file GameMode.cpp.

◆ updatePlayer()

virtual bool proofps_dd::GameMode::updatePlayer ( const Player & player,
pge_network::PgeINetwork & network )
pure virtual

Updates data for the specified player.

In case of server instance, it SHALL automatically evaluate winning condition using serverCheckAndUpdateWinningConditions() after updating the player. Note that once a game is won, it stays won even if players are updated to fail the winning conditions, until explicit call to restart().

Note that GameMode does not ensure that a spectating player cannot win a game. The game shall ensure that the player does not gain any frags while in spectator mode! Therefore, if the added player already has enough frags to flip game won state, the game will go into won state, regardless of the player's spectating state!

Fails if player with same cannot be found.

Returns
True if updated the existing player, false otherwise.

Implemented in proofps_dd::DeathMatchMode, proofps_dd::TeamDeathMatchMode, and SpecialGameMode.

◆ wasGameWonAlreadyInPreviousTick()

bool proofps_dd::GameMode::wasGameWonAlreadyInPreviousTick ( ) const

Returns if the current game session was already won in the previous tick.

The idea is the following:

Returns
True if current game session was won (goal reached) in the previous tick, false otherwise.

Definition at line 361 of file GameMode.cpp.

Member Data Documentation

◆ m_bWon

bool proofps_dd::GameMode::m_bWon { false }
protected

Definition at line 438 of file GameMode.h.

◆ m_bWonPrevious

bool proofps_dd::GameMode::m_bWonPrevious { false }
protected

Definition at line 439 of file GameMode.h.

◆ m_gamemode

std::unique_ptr< proofps_dd::GameMode > proofps_dd::GameMode::m_gamemode {}
staticprivate

Definition at line 506 of file GameMode.h.

◆ m_gameModeType

GameModeType proofps_dd::GameMode::m_gameModeType
protected

Definition at line 440 of file GameMode.h.

◆ m_mapPlayersExternal

const std::map<pge_network::PgeNetworkConnectionHandle, proofps_dd::Player>& proofps_dd::GameMode::m_mapPlayersExternal
protected

Definition at line 437 of file GameMode.h.

◆ m_nTimeLimitSecs

unsigned int proofps_dd::GameMode::m_nTimeLimitSecs {}
private

Definition at line 462 of file GameMode.h.

◆ m_players

std::list<PlayersTableRow> proofps_dd::GameMode::m_players
protected

Definition at line 436 of file GameMode.h.

◆ m_timeReset

std::chrono::time_point<std::chrono::steady_clock> proofps_dd::GameMode::m_timeReset
private

Definition at line 461 of file GameMode.h.

◆ m_timeWin

std::chrono::time_point<std::chrono::steady_clock> proofps_dd::GameMode::m_timeWin
protected

Definition at line 435 of file GameMode.h.

◆ nSvDmFragLimitDef

int proofps_dd::GameMode::nSvDmFragLimitDef = 10
staticconstexpr

Definition at line 110 of file GameMode.h.

◆ nSvDmFragLimitMax

int proofps_dd::GameMode::nSvDmFragLimitMax = 999
staticconstexpr

Definition at line 112 of file GameMode.h.

◆ nSvDmFragLimitMin

int proofps_dd::GameMode::nSvDmFragLimitMin = 0
staticconstexpr

Definition at line 111 of file GameMode.h.

◆ nSvGmTimeLimitSecsDef

int proofps_dd::GameMode::nSvGmTimeLimitSecsDef = 0
staticconstexpr

Definition at line 103 of file GameMode.h.

◆ nSvGmTimeLimitSecsMax

int proofps_dd::GameMode::nSvGmTimeLimitSecsMax = 60 * 60 * 24
staticconstexpr

Definition at line 105 of file GameMode.h.

◆ nSvGmTimeLimitSecsMin

int proofps_dd::GameMode::nSvGmTimeLimitSecsMin = 0
staticconstexpr

Definition at line 104 of file GameMode.h.

◆ nSvRgmRoundWinLimitDef

int proofps_dd::GameMode::nSvRgmRoundWinLimitDef = 5
staticconstexpr

Definition at line 117 of file GameMode.h.

◆ nSvRgmRoundWinLimitMax

int proofps_dd::GameMode::nSvRgmRoundWinLimitMax = 999
staticconstexpr

Definition at line 119 of file GameMode.h.

◆ nSvRgmRoundWinLimitMin

int proofps_dd::GameMode::nSvRgmRoundWinLimitMin = 1
staticconstexpr

Definition at line 118 of file GameMode.h.

◆ szCvarSvDmFragLimit

char* proofps_dd::GameMode::szCvarSvDmFragLimit = "sv_dm_fraglimit"
staticconstexpr

Definition at line 100 of file GameMode.h.

◆ szCvarSvGamemode

char* proofps_dd::GameMode::szCvarSvGamemode = "sv_gamemode"
staticconstexpr

Definition at line 96 of file GameMode.h.

◆ szCvarSvGmTimeLimit

char* proofps_dd::GameMode::szCvarSvGmTimeLimit = "sv_gm_timelimit_secs"
staticconstexpr

Definition at line 98 of file GameMode.h.

◆ szCvarSvRgmRoundWinLimit

char* proofps_dd::GameMode::szCvarSvRgmRoundWinLimit = "sv_rgm_roundwinlimit"
staticconstexpr

Definition at line 101 of file GameMode.h.


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