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. 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 56 of file GameMode.h.
|
CConsole & | getConsole () const |
|
virtual | ~GameMode () |
|
virtual void | fetchConfig (PGEcfgProfiles &cfgProfiles, pge_network::PgeINetwork &network)=0 |
| Fetches configuration from the given PGEcfgProfiles instance.
|
|
GameModeType | getGameModeType () const |
|
const std::chrono::time_point< std::chrono::steady_clock > & | getResetTime () const |
|
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) |
| Resets winning time and winning condition, also zeros out relevant members of FragTableRow for all players.
|
|
virtual bool | serverCheckAndUpdateWinningConditions (pge_network::PgeINetwork &network)=0 |
| Evaluates conditions to see if game is won or not.
|
|
virtual void | clientReceiveAndUpdateWinningConditions (pge_network::PgeINetwork &network, bool bGameSessionWon)=0 |
| Handles server's update about current game session goal, e.g.
|
|
bool | isGameWon () const |
| Returns the current game session win state i.e.
|
|
const std::chrono::time_point< std::chrono::steady_clock > & | getWinTime () const |
|
const std::list< FragTableRow > & | getFragTable () 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)=0 |
| Removes data for the specified player.
|
|
bool | renamePlayer (const std::string &sOldName, const std::string &sNewName) |
| Renames the player.
|
|
void | text (PR00FsUltimateRenderingEngine &pure, const std::string &s, int x, int y) const |
|
virtual bool proofps_dd::GameMode::addPlayer |
( |
const Player & | player, |
|
|
pge_network::PgeINetwork & | network ) |
|
pure virtual |
Adds the specified player.
In case of server instance, it automatically evaluates winning condition, and in case of winning it also updates winning time and sends out MsgGameSessionStateFromServer to all clients. 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().
Fails if a player with same name is already added.
- Returns
- True if added the new player, false otherwise.
Implemented in proofps_dd::DeathMatchMode.
virtual void proofps_dd::GameMode::clientReceiveAndUpdateWinningConditions |
( |
pge_network::PgeINetwork & | network, |
|
|
bool | bGameSessionWon ) |
|
pure virtual |
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
-
bGameSessionWon | True if the current game session goal has been just reached, false otherwise. |
Implemented in proofps_dd::DeathMatchMode.
virtual void proofps_dd::GameMode::fetchConfig |
( |
PGEcfgProfiles & | cfgProfiles, |
|
|
pge_network::PgeINetwork & | network ) |
|
pure virtual |
Fetches configuration from the given PGEcfgProfiles instance.
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
-
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. |
Implemented in proofps_dd::DeathMatchMode.
virtual bool proofps_dd::GameMode::removePlayer |
( |
const Player & | player | ) |
|
|
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.
virtual bool proofps_dd::GameMode::serverCheckAndUpdateWinningConditions |
( |
pge_network::PgeINetwork & | network | ) |
|
|
pure virtual |
Evaluates conditions to see if game is won or not.
Since conditions depend on game mode, the actual implementation must be in the specific derived game mode class. Note that once a game is won, it stays won even if all players are removed, until explicit call to restart().
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
-
- Returns
- True if game is won, false otherwise.
Implemented in proofps_dd::DeathMatchMode.
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 automatically evaluates winning condition, and in case of winning it also updates winning time and sends out MsgGameSessionStateFromServer to all clients. 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().
Fails if player with same cannot be found.
- Returns
- True if updated the existing player, false otherwise.
Implemented in proofps_dd::DeathMatchMode.