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

In Team DeathMatch game mode, players are grouped into teams. More...

Detailed Description

In Team DeathMatch game mode, players are grouped into teams.

Teammates work together to kill as many players in the enemy team as they can. The team with most total frags is the winner when either the frag limit or time limit is reached. Note: it is also valid to not to have either frag limit or time limit set, but in such case the game never ends.

Player teamId is used to know which player belongs to which team, so team total frags can be calculated. This also means serverCheckAndUpdateWinningConditions() has different implementation than DeathMatchMode has.

Definition at line 561 of file GameMode.h.

#include <GameMode.h>

+ Inheritance diagram for proofps_dd::TeamDeathMatchMode:

Public Member Functions

virtual ~TeamDeathMatchMode ()
 
 TeamDeathMatchMode (const TeamDeathMatchMode &)=delete
 
TeamDeathMatchModeoperator= (const TeamDeathMatchMode &)=delete
 
 TeamDeathMatchMode (TeamDeathMatchMode &&)=delete
 
TeamDeathMatchMode && operator= (TeamDeathMatchMode &&)=delete
 
virtual bool serverCheckAndUpdateWinningConditions (pge_network::PgeINetwork &network) override
 Altering parent class implementation by checking team total frags (instead of individual player frags) against frag limit, if any is set.
 
virtual bool addPlayer (const Player &player, pge_network::PgeINetwork &network) override
 Extending parent class implementation by rejecting player if team id is not in [0-2] range.
 
virtual bool updatePlayer (const Player &player, pge_network::PgeINetwork &network) override
 Extending parent class implementation by rejecting player if team id is not in [0-2] range.
 
virtual bool isTeamBasedGame () const override
 Derived class shall return false if it is non-team-based game, otherwise true.
 
virtual bool isPlayerAllowedForGameplay (const Player &player) const override
 Extending parent class implementation by rejecting player if team id is 0.
 
int getTeamFrags (unsigned int iTeamId) const
 
unsigned int getTeamPlayersCount (unsigned int iTeamId) const
 
unsigned int getAliveTeamPlayersCount (unsigned int iTeamId) const
 
- Public Member Functions inherited from proofps_dd::DeathMatchMode
virtual ~DeathMatchMode ()
 
 DeathMatchMode (const DeathMatchMode &)=delete
 
DeathMatchModeoperator= (const DeathMatchMode &)=delete
 
 DeathMatchMode (DeathMatchMode &&)=delete
 
DeathMatchMode && operator= (DeathMatchMode &&)=delete
 
virtual void fetchConfig (PGEcfgProfiles &cfgProfiles, pge_network::PgeINetwork &network) override
 Fetches configuration from the given PGEcfgProfiles instance.
 
unsigned int getFragLimit () const
 
void setFragLimit (unsigned int limit)
 Set the frag limit for the game.
 
virtual bool removePlayer (const Player &player, pge_network::PgeINetwork &network) override
 Removes data for the specified player.
 
virtual bool isRoundBased () const override
 
virtual bool isRespawnAllowedAfterDie () const override
 
- Public Member Functions inherited from proofps_dd::GameMode
CConsole & getConsole () const
 
virtual ~GameMode ()
 
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.
 
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
 
bool renamePlayer (const std::string &sOldName, const std::string &sNewName)
 Renames the player.
 
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 PureColor & getTeamColor (unsigned int iTeamId)
 
static std::unique_ptr< TeamDeathMatchModecreateGameMode (const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 Used by GameMode::createGameMode(), this way we don't need to be friend with GameMode.
 
- Static Public Member Functions inherited from proofps_dd::DeathMatchMode
static std::unique_ptr< DeathMatchModecreateGameMode (const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 Used by GameMode::createGameMode(), this way we don't need to be friend with GameMode.
 
- Static Public Member Functions inherited from proofps_dd::GameMode
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 * szCvarSvTdmFriendlyFire = "sv_tdm_friendlyfire"
 
- Static Public Attributes inherited from proofps_dd::GameMode
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

 TeamDeathMatchMode (const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 
- Protected Member Functions inherited from proofps_dd::DeathMatchMode
 DeathMatchMode (const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers)
 
- Protected Member Functions inherited from proofps_dd::GameMode
 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)
 

Additional Inherited Members

- Protected Attributes inherited from proofps_dd::DeathMatchMode
unsigned int m_nFragLimit {}
 
- Protected Attributes inherited from proofps_dd::GameMode
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
 

Constructor & Destructor Documentation

◆ ~TeamDeathMatchMode()

proofps_dd::TeamDeathMatchMode::~TeamDeathMatchMode ( )
virtual

Definition at line 782 of file GameMode.cpp.

◆ TeamDeathMatchMode() [1/3]

proofps_dd::TeamDeathMatchMode::TeamDeathMatchMode ( const TeamDeathMatchMode & )
delete

◆ TeamDeathMatchMode() [2/3]

proofps_dd::TeamDeathMatchMode::TeamDeathMatchMode ( TeamDeathMatchMode && )
delete

◆ TeamDeathMatchMode() [3/3]

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

Definition at line 906 of file GameMode.cpp.

Member Function Documentation

◆ addPlayer()

bool proofps_dd::TeamDeathMatchMode::addPlayer ( const Player & player,
pge_network::PgeINetwork & network )
overridevirtual

Extending parent class implementation by rejecting player if team id is not in [0-2] range.

Reimplemented from proofps_dd::DeathMatchMode.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 808 of file GameMode.cpp.

◆ createGameMode()

std::unique_ptr< proofps_dd::TeamDeathMatchMode > proofps_dd::TeamDeathMatchMode::createGameMode ( const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & mapPlayers)
static

Used by GameMode::createGameMode(), this way we don't need to be friend with GameMode.

The previous GameMode instance is destroyed automatically. See GameMode::createGameMode() for more details.

Returns
Smart pointer to the created TeamRoundGameMode instance.

Definition at line 775 of file GameMode.cpp.

◆ getAliveTeamPlayersCount()

unsigned int proofps_dd::TeamDeathMatchMode::getAliveTeamPlayersCount ( unsigned int iTeamId) const
Parameters
iTeamIdTeam ID for which team we want to get the count of alive players.
Returns
Number of assigned (not in spectator mode) AND alive players in the specified team. Basically: getTeamPlayersCount(iTeamId) - number of dead players in iTeamId. Always 0 when iTeamId is 0, so for counting spectators use getSpectatorModePlayersCount() instead!

Definition at line 875 of file GameMode.cpp.

◆ getTeamColor()

const PureColor & proofps_dd::TeamDeathMatchMode::getTeamColor ( unsigned int iTeamId)
static

Definition at line 768 of file GameMode.cpp.

◆ getTeamFrags()

int proofps_dd::TeamDeathMatchMode::getTeamFrags ( unsigned int iTeamId) const
Parameters
iTeamIdTeam ID for which team we want to get the sum of frags.
Returns
Sum of assigned player frags in the specified team. A dead player who is currently forced-spectating in a round-based game mode is also considered since force-spectating is NOT spectator mode, the player still has assigned team. Always 0 when iTeamId is 0.

Definition at line 839 of file GameMode.cpp.

◆ getTeamPlayersCount()

unsigned int proofps_dd::TeamDeathMatchMode::getTeamPlayersCount ( unsigned int iTeamId) const
Parameters
iTeamIdTeam ID for which team we want to get the count of players.
Returns
Number of assigned players (not in spectator mode) in the specified team. A dead player who is currently forced-spectating in a round-based game mode is also considered since force-spectating is NOT spectator mode, the player still has assigned team. Always 0 when iTeamId is 0, so for counting spectators use getSpectatorModePlayersCount() instead!

Definition at line 857 of file GameMode.cpp.

◆ isPlayerAllowedForGameplay()

bool proofps_dd::TeamDeathMatchMode::isPlayerAllowedForGameplay ( const Player & player) const
overridevirtual

Extending parent class implementation by rejecting player if team id is 0.

Reimplemented from proofps_dd::DeathMatchMode.

Definition at line 833 of file GameMode.cpp.

◆ isTeamBasedGame()

bool proofps_dd::TeamDeathMatchMode::isTeamBasedGame ( ) const
overridevirtual

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

Reimplemented from proofps_dd::DeathMatchMode.

Definition at line 828 of file GameMode.cpp.

◆ operator=() [1/2]

TeamDeathMatchMode & proofps_dd::TeamDeathMatchMode::operator= ( const TeamDeathMatchMode & )
delete

◆ operator=() [2/2]

TeamDeathMatchMode && proofps_dd::TeamDeathMatchMode::operator= ( TeamDeathMatchMode && )
delete

◆ serverCheckAndUpdateWinningConditions()

bool proofps_dd::TeamDeathMatchMode::serverCheckAndUpdateWinningConditions ( pge_network::PgeINetwork & network)
overridevirtual

Altering parent class implementation by checking team total frags (instead of individual player frags) against frag limit, if any is set.

Reimplemented from proofps_dd::DeathMatchMode.

Reimplemented in proofps_dd::TeamRoundGameMode.

Definition at line 786 of file GameMode.cpp.

◆ updatePlayer()

bool proofps_dd::TeamDeathMatchMode::updatePlayer ( const Player & player,
pge_network::PgeINetwork & network )
overridevirtual

Extending parent class implementation by rejecting player if team id is not in [0-2] range.

Reimplemented from proofps_dd::DeathMatchMode.

Definition at line 818 of file GameMode.cpp.

Member Data Documentation

◆ szCvarSvTdmFriendlyFire

char* proofps_dd::TeamDeathMatchMode::szCvarSvTdmFriendlyFire = "sv_tdm_friendlyfire"
staticconstexpr

Definition at line 565 of file GameMode.h.


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