![]() |
PRooFPS-dd Dev Doc 1.0
PRooFPS-dd Developer Documentation
|
In Team Round Game mode, players are grouped into teams, same way as in Team DeathMatch. More...
In Team Round Game mode, players are grouped into teams, same way as in Team DeathMatch.
However, the game mode features rounds.
Unlike in deathmatch-style game modes, here players cannot respawn immediately after being killed: isRespawnAllowedAfterDie() return false. Instead, they have to wait for the next round to start.
Each round ends when any of the teams loses all its players.
The team reaching the predefined round win limit earlier wins the game, or the team with the most round wins if time limit is reached. The round win limit is configured by the server.
Note that although setFragLimit() functionality is inherited from parent classes, it is not used.
Each round has different states, governed by RoundStateFSM.
Note that when the game is won, RoundStateFSM might stay in Prepare or Play states, for example if game won reason is game time limit reached (getTimeLimitSecs()).
Definition at line 677 of file GameMode.h.
#include <GameMode.h>
Inheritance diagram for proofps_dd::TeamRoundGameMode:Classes | |
| class | RoundStateFSM |
Public Member Functions | |
| virtual | ~TeamRoundGameMode () |
| TeamRoundGameMode (const TeamRoundGameMode &)=delete | |
| TeamRoundGameMode & | operator= (const TeamRoundGameMode &)=delete |
| TeamRoundGameMode (TeamRoundGameMode &&)=delete | |
| TeamRoundGameMode && | operator= (TeamRoundGameMode &&)=delete |
| virtual void | fetchConfig (PGEcfgProfiles &cfgProfiles, pge_network::PgeINetwork &network) override |
| Fetches configuration from the given PGEcfgProfiles instance. | |
| virtual void | restartWithoutRemovingPlayers (pge_network::PgeINetwork &network, const proofps_dd::GameRestartType_KeepPlayers &eRestartType) override |
| Resets winning time and winning condition, also zeros out relevant members of PlayersTableRow for all players. | |
| virtual bool | serverCheckAndUpdateWinningConditions (pge_network::PgeINetwork &network) override |
| Altering parent class implementation by checking won rounds per team, instead of frag limit. | |
| virtual void | serverTickUpdateWinningConditions (pge_network::PgeINetwork &network) override |
| Extending original implementation with focus on RoundStateFSM. | |
| virtual void | clientTickUpdateWinningConditions (pge_network::PgeINetwork &network) override |
| Extending original implementation with focus on RoundStateFSM. | |
| 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 | 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 |
| virtual bool | isPlayerMovementAllowed () const override |
| unsigned int | getRoundWinLimit () const |
| void | setRoundWinLimit (unsigned int limit) |
| Set the round win limit for the game. | |
| unsigned int | getTeamRoundWins (unsigned int iTeamId) const |
| RoundStateFSM & | getFSM () |
| const RoundStateFSM & | getFSM () const |
| bool | hasJustTransitionedTo_RoundPrepareState_InThisTick () const |
| Returns if RoundStateFSM has been just detected as transitioned to Prepare state in this tick i.e. | |
| bool | hasJustTransitionedTo_RoundPlayState_InThisTick () const |
| Returns if RoundStateFSM has been just detected as transitioned to Play state in this tick i.e. | |
| bool | hasJustTransitionedTo_RoundWaitForResetState_InThisTick () const |
| Returns if RoundStateFSM has been just detected as transitioned to WaitForReset state in this tick i.e. | |
| bool | hasCurrentRoundJustBeenWon_InThisTick () const |
| bool | clientHandleGameRoundStateFromServer (pge_network::PgeINetwork &network, const MsgGameRoundStateFromServer &msgRoundState) |
| bool | serverSendRoundStateToClient (pge_network::PgeINetwork &network, const pge_network::PgeNetworkConnectionHandle &connHandle) |
| bool | serverSendRoundStateToClients (pge_network::PgeINetwork &network) |
Public Member Functions inherited from proofps_dd::TeamDeathMatchMode | |
| virtual | ~TeamDeathMatchMode () |
| TeamDeathMatchMode (const TeamDeathMatchMode &)=delete | |
| TeamDeathMatchMode & | operator= (const TeamDeathMatchMode &)=delete |
| TeamDeathMatchMode (TeamDeathMatchMode &&)=delete | |
| TeamDeathMatchMode && | operator= (TeamDeathMatchMode &&)=delete |
| 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 | |
| DeathMatchMode & | operator= (const DeathMatchMode &)=delete |
| DeathMatchMode (DeathMatchMode &&)=delete | |
| DeathMatchMode && | operator= (DeathMatchMode &&)=delete |
| unsigned int | getFragLimit () const |
| void | setFragLimit (unsigned int limit) |
| Set the frag limit for the game. | |
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. | |
| void | clientReceiveAndUpdateWinningConditions (pge_network::PgeINetwork &network, bool bGameSessionWon) |
| Handles server's update about current game session goal, e.g. | |
| 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. | |
| unsigned int | getSpectatorModePlayersCount () const |
| void | text (PR00FsUltimateRenderingEngine &pure, const std::string &s, int x, int y) const |
Static Public Member Functions | |
| static std::unique_ptr< TeamRoundGameMode > | createGameMode (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::TeamDeathMatchMode | |
| static const PureColor & | getTeamColor (unsigned int iTeamId) |
| static std::unique_ptr< TeamDeathMatchMode > | createGameMode (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< DeathMatchMode > | createGameMode (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 GameMode * | createGameMode (GameModeType gm, const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers) |
| Similar to singleton design pattern, there is always maximum one instance. | |
| static GameMode * | getGameMode () |
| 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) |
Protected Member Functions | |
| TeamRoundGameMode (const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > &mapPlayers) | |
| virtual bool | serverSendGameSessionStateToClient (pge_network::PgeINetwork &network, const pge_network::PgeNetworkConnectionHandle &connHandle) override |
| Extends original behavior by also sending out MsgGameRoundStateFromServer to the specific client. | |
| virtual bool | serverSendGameSessionStateToClients (pge_network::PgeINetwork &network, const proofps_dd::GameRestartType_KeepPlayers &eRestartType) override |
| Extends original behavior by also sending out MsgGameRoundStateFromServer to all clients. | |
| void | setTeamRoundWins (unsigned int iTeamId, unsigned int nRoundWins) |
Protected Member Functions inherited from proofps_dd::TeamDeathMatchMode | |
| 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 | |
| GameMode & | operator= (const GameMode &)=delete |
| GameMode (GameMode &&)=delete | |
| GameMode && | operator= (GameMode &&)=delete |
| void | handleEventGameWon (pge_network::PgeINetwork &network) |
Private Attributes | |
| unsigned int | m_nRoundWinLimit { GameMode::nSvRgmRoundWinLimitDef } |
| unsigned int | m_nTeam1RoundWins { 0 } |
| unsigned int | m_nTeam2RoundWins { 0 } |
| RoundStateFSM | m_fsm |
| RoundStateFSM::RoundState | m_oldFsmState { RoundStateFSM::RoundState::Prepare } |
| bool | m_bFsmStateTransitionHasJustHappenedThisTick_Sticky { true } |
| Sticky because it requires explicit clear at the end of a tick. | |
| bool | m_bFirstTick { true } |
| bool | m_bCurrentRoundHasJustBeenWon_Sticky { false } |
| Sticky because it requires explicit clear at the end of a tick. | |
Friends | |
| class | GameModeTest |
Additional Inherited Members | |
Static Public Attributes inherited from proofps_dd::TeamDeathMatchMode | |
| 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 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< PlayersTableRow > | m_players |
| const std::map< pge_network::PgeNetworkConnectionHandle, proofps_dd::Player > & | m_mapPlayersExternal |
| bool | m_bWon { false } |
| bool | m_bWonPrevious { false } |
| GameModeType | m_gameModeType |
|
virtual |
Definition at line 1173 of file GameMode.cpp.
|
delete |
|
delete |
|
protected |
Definition at line 1471 of file GameMode.cpp.
|
overridevirtual |
Extending parent class implementation by rejecting player if team id is not in [0-2] range.
Reimplemented from proofps_dd::TeamDeathMatchMode.
Definition at line 1302 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::clientHandleGameRoundStateFromServer | ( | pge_network::PgeINetwork & | network, |
| const MsgGameRoundStateFromServer & | msgRoundState ) |
Definition at line 1397 of file GameMode.cpp.
|
overridevirtual |
Extending original implementation with focus on RoundStateFSM.
See original GameMode::clientTickUpdateWinningConditions() documentation for details.
This function is for client instance only.
Reimplemented from proofps_dd::GameMode.
Definition at line 1292 of file GameMode.cpp.
|
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.
Definition at line 1166 of file GameMode.cpp.
|
overridevirtual |
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.
| cfgProfiles | The current user config profile from where we can fetch value of GameMode-specific CVARs. |
| network | PGE network instance to be used to know if we are server or client. |
Reimplemented from proofps_dd::DeathMatchMode.
Definition at line 1177 of file GameMode.cpp.
| proofps_dd::TeamRoundGameMode::RoundStateFSM & proofps_dd::TeamRoundGameMode::getFSM | ( | ) |
Definition at line 1367 of file GameMode.cpp.
| const proofps_dd::TeamRoundGameMode::RoundStateFSM & proofps_dd::TeamRoundGameMode::getFSM | ( | ) | const |
Definition at line 1372 of file GameMode.cpp.
| unsigned int proofps_dd::TeamRoundGameMode::getRoundWinLimit | ( | ) | const |
Definition at line 1343 of file GameMode.cpp.
| unsigned int proofps_dd::TeamRoundGameMode::getTeamRoundWins | ( | unsigned int | iTeamId | ) | const |
| iTeamId | Team ID for which team we want to get the total number of won rounds. |
Definition at line 1361 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::hasCurrentRoundJustBeenWon_InThisTick | ( | ) | const |
Definition at line 1392 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::hasJustTransitionedTo_RoundPlayState_InThisTick | ( | ) | const |
Returns if RoundStateFSM has been just detected as transitioned to Play state in this tick i.e.
it was in different state in the previous tick.
This function is the recommended way for both server and client instances to check for and handle the change.
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().
The idea is the following:
Definition at line 1382 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::hasJustTransitionedTo_RoundPrepareState_InThisTick | ( | ) | const |
Returns if RoundStateFSM has been just detected as transitioned to Prepare state in this tick i.e.
it was in different state in the previous tick.
This function is the recommended way for both server and client instances to check for and handle the change to a new round.
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().
The idea is the following:
Definition at line 1377 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::hasJustTransitionedTo_RoundWaitForResetState_InThisTick | ( | ) | const |
Returns if RoundStateFSM has been just detected as transitioned to WaitForReset state in this tick i.e.
it was in different state in the previous tick.
This function is the recommended way for both server and client instances to check for and handle round end.
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().
The idea is the following:
Definition at line 1387 of file GameMode.cpp.
|
overridevirtual |
Reimplemented from proofps_dd::GameMode.
Definition at line 1338 of file GameMode.cpp.
|
overridevirtual |
Reimplemented from proofps_dd::DeathMatchMode.
Definition at line 1333 of file GameMode.cpp.
|
overridevirtual |
Reimplemented from proofps_dd::DeathMatchMode.
Definition at line 1328 of file GameMode.cpp.
|
delete |
|
delete |
|
overridevirtual |
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().
Reimplemented from proofps_dd::DeathMatchMode.
Definition at line 1315 of file GameMode.cpp.
|
overridevirtual |
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.
| network | PGE network instance to be used to send out MsgGameSessionStateFromServer to clients. |
| eRestartType | Players stats are defaulted depending on restart type. Cannot be GameRestartType_KeepPlayers::None. |
Reimplemented from proofps_dd::GameMode.
Definition at line 1185 of file GameMode.cpp.
|
overridevirtual |
Altering parent class implementation by checking won rounds per team, instead of frag limit.
Frag limit is not considered at all. Time limit is still considered.
This also drives RoundStateFSM. Note that when the game is won, RoundStateFSM might stay in Prepare or Play states, for example if game won reason is game time limit reached (getTimeLimitSecs()).
Reimplemented from proofps_dd::TeamDeathMatchMode.
Definition at line 1198 of file GameMode.cpp.
|
overrideprotectedvirtual |
Extends original behavior by also sending out MsgGameRoundStateFromServer to the specific client.
Reimplemented from proofps_dd::GameMode.
Definition at line 1479 of file GameMode.cpp.
|
overrideprotectedvirtual |
Extends original behavior by also sending out MsgGameRoundStateFromServer to all clients.
Reimplemented from proofps_dd::GameMode.
Definition at line 1488 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::serverSendRoundStateToClient | ( | pge_network::PgeINetwork & | network, |
| const pge_network::PgeNetworkConnectionHandle & | connHandle ) |
Definition at line 1427 of file GameMode.cpp.
| bool proofps_dd::TeamRoundGameMode::serverSendRoundStateToClients | ( | pge_network::PgeINetwork & | network | ) |
Definition at line 1447 of file GameMode.cpp.
|
overridevirtual |
Extending original implementation with focus on RoundStateFSM.
See original GameMode::serverTickUpdateWinningConditions() documentation for details.
This function is for server instance only.
Reimplemented from proofps_dd::GameMode.
Definition at line 1285 of file GameMode.cpp.
| void proofps_dd::TeamRoundGameMode::setRoundWinLimit | ( | unsigned int | limit | ) |
Set the round win limit for the game.
If the round win limit is reached, the winner is the team which reached it, even if time limit is not yet reached or there is no time limit set.
Note: behavior is unspecified if this value is changed on-the-fly during a game. For now, please also call restart() explicitly.
| limit | The round win limit. Must be positive value. |
Definition at line 1348 of file GameMode.cpp.
|
protected |
Definition at line 1497 of file GameMode.cpp.
|
friend |
Definition at line 955 of file GameMode.h.
|
private |
Sticky because it requires explicit clear at the end of a tick.
Definition at line 968 of file GameMode.h.
|
private |
Definition at line 967 of file GameMode.h.
|
private |
Sticky because it requires explicit clear at the end of a tick.
Definition at line 966 of file GameMode.h.
|
private |
Definition at line 964 of file GameMode.h.
|
private |
Definition at line 961 of file GameMode.h.
|
private |
Definition at line 962 of file GameMode.h.
|
private |
Definition at line 963 of file GameMode.h.
|
private |
Definition at line 965 of file GameMode.h.