stmm-games-doc  0.32.0
Public Member Functions | Public Attributes | List of all members
stmg::GameConstraints Class Reference

The game constraints. More...

Inheritance diagram for stmg::GameConstraints:
Inheritance graph
[legend]

Public Member Functions

void initFromAppConstraints (const AppConstraints &oAppConstraints) noexcept
 Initialize this instance values so that it is compatible with the given app constraints. More...
 
bool isValid () const noexcept
 Whether the instance is valid (consistent). More...
 
int32_t getMinTeams () const noexcept
 The minimum number of teams that can play. More...
 
int32_t getMaxTeams () const noexcept
 The maximum number of teams that can play. More...
 
int32_t getMinPlayers () const noexcept
 The minimum number of players that can play. More...
 
int32_t getMaxPlayers () const noexcept
 The maximum number of players that can play. More...
 
std::pair< bool, std::string > isSelectedBy (const AppPreferences &oAppPreferences) const noexcept
 Whether this constraints are compatible with preferences. More...
 
std::pair< bool, std::string > isCompatibleWith (const AppConstraints &oAppConstraints) const noexcept
 Whether the game constraints are compatible with application constraints. More...
 
bool isAllTeamsInOneLevel () const noexcept
 Whether this game's constraints allow more teams to play in the same level. More...
 
- Public Member Functions inherited from stmg::AppConstraints
bool isValid () const noexcept
 
int32_t getMaxTeams () const noexcept
 The real max number of teams. More...
 
int32_t getMaxTeammates () const noexcept
 The real max number of teammates. More...
 
int32_t getMaxPlayers () const noexcept
 The real max number of players. More...
 
bool allowsAI () const noexcept
 Whether AI players are allowed. More...
 

Public Attributes

int32_t m_nLevelsMin = 1
 Must be positive. More...
 
int32_t m_nLevelsMax = 1
 Cannot be smaller than m_nLevelsMin. More...
 
int32_t m_nTeamsPerLevelMin = 1
 Must be positive. More...
 
int32_t m_nTeamsPerLevelMax = 4
 Cannot be smaller than m_nTeamsPerLevelMin. More...
 
int32_t m_nMatesPerTeamMin = 1
 Must be positive. More...
 
int32_t m_nPlayersMin = 1
 Must be positive. More...
 
int32_t m_nAITeamsMin = 0
 Cannot be negative. More...
 
int32_t m_nAITeamsMax = 0
 Cannot be smaller than m_nAITeamsMin. More...
 
shared_ptr< PrefSelectorm_refPrefSelector
 Additional constraints. More...
 
- Public Attributes inherited from stmg::AppConstraints
int32_t m_nTeamsMin = 1
 Must be positive. More...
 
int32_t m_nTeamsMax = 4
 Default is 4. More...
 
int32_t m_nMatesPerTeamMax = 3
 Must be positive. More...
 
int32_t m_nPlayersMax = 12
 Must be positive. More...
 
int32_t m_nAIMatesPerTeamMax = 1
 Cannot be negative. More...
 
bool m_bAllowMixedAIHumanTeam = false
 Default is false. More...
 

Detailed Description

The game constraints.

This class can be used to define the conditions for which a game can be played. This allows game loaders to choose the games that are compatible with the current preferences. For example a game might work only for exactly 2 non AI teams in one level, so a single player (chosen in the preferences) should be prevented from playing the game.

GameConstraints is valid only if either all teams play in one level or each team plays in a separate level. Therefore defining a game with constraints (m_nLevelsMax > 1) and (m_nTeamsPerLevelMax > 1) is invalid.

Member Function Documentation

◆ getMaxPlayers()

int32_t stmg::GameConstraints::getMaxPlayers ( ) const
inlinenoexcept

The maximum number of players that can play.

This can be more restrictive than just AppConstraints::getMaxPlayers().

Returns
The maximum number of players.

◆ getMaxTeams()

int32_t stmg::GameConstraints::getMaxTeams ( ) const
inlinenoexcept

The maximum number of teams that can play.

This can be more restrictive than just AppConstraints::getMaxTeams().

Returns
The maximum number of teams.

◆ getMinPlayers()

int32_t stmg::GameConstraints::getMinPlayers ( ) const
inlinenoexcept

The minimum number of players that can play.

This can be more restrictive than just m_nPlayersMin.

Returns
The minimum number of players.

◆ getMinTeams()

int32_t stmg::GameConstraints::getMinTeams ( ) const
inlinenoexcept

The minimum number of teams that can play.

This can be more restrictive than just m_nTeamsMin.

Returns
The minimum number of teams.

◆ initFromAppConstraints()

void stmg::GameConstraints::initFromAppConstraints ( const AppConstraints oAppConstraints)
noexcept

Initialize this instance values so that it is compatible with the given app constraints.

The app constraints must be valid.

Parameters
oAppConstraintsThe app constraints.

◆ isAllTeamsInOneLevel()

bool stmg::GameConstraints::isAllTeamsInOneLevel ( ) const
inlinenoexcept

Whether this game's constraints allow more teams to play in the same level.

If the maximum number of levels and of teams per level is both one, this function returns true.

Returns
Whether game of type "all teams in one level".

◆ isCompatibleWith()

std::pair<bool, std::string> stmg::GameConstraints::isCompatibleWith ( const AppConstraints oAppConstraints) const
noexcept

Whether the game constraints are compatible with application constraints.

Parameters
oAppConstraintsThe app constraints.
Returns
Whether compatible and if not the error string.

◆ isSelectedBy()

std::pair<bool, std::string> stmg::GameConstraints::isSelectedBy ( const AppPreferences oAppPreferences) const
noexcept

Whether this constraints are compatible with preferences.

Parameters
oAppPreferencesThe preferences.
Returns
Whether compatible and if not the error string.

◆ isValid()

bool stmg::GameConstraints::isValid ( ) const
noexcept

Whether the instance is valid (consistent).

Returns
Whether valid.

Member Data Documentation

◆ m_nAITeamsMax

int32_t stmg::GameConstraints::m_nAITeamsMax = 0

Cannot be smaller than m_nAITeamsMin.

Default is 0.

◆ m_nAITeamsMin

int32_t stmg::GameConstraints::m_nAITeamsMin = 0

Cannot be negative.

Default is 0.

◆ m_nLevelsMax

int32_t stmg::GameConstraints::m_nLevelsMax = 1

Cannot be smaller than m_nLevelsMin.

Default is 1.

◆ m_nLevelsMin

int32_t stmg::GameConstraints::m_nLevelsMin = 1

Must be positive.

Default is 1.

◆ m_nMatesPerTeamMin

int32_t stmg::GameConstraints::m_nMatesPerTeamMin = 1

Must be positive.

Default is 1.

◆ m_nPlayersMin

int32_t stmg::GameConstraints::m_nPlayersMin = 1

Must be positive.

Default is 1.

◆ m_nTeamsPerLevelMax

int32_t stmg::GameConstraints::m_nTeamsPerLevelMax = 4

Cannot be smaller than m_nTeamsPerLevelMin.

Default is 4.

◆ m_nTeamsPerLevelMin

int32_t stmg::GameConstraints::m_nTeamsPerLevelMin = 1

Must be positive.

Default is 1.

◆ m_refPrefSelector

shared_ptr<PrefSelector> stmg::GameConstraints::m_refPrefSelector

Additional constraints.

Can be null.