|
stmm-games-doc
0.32.0
|
Classes | |
| struct | Discriminator |
| Separates highscores according to preference values. More... | |
| struct | Eligibility |
| All constraints must be satisfied for a team to be added to the highscore. More... | |
| struct | HighscoreConstraint |
| All constraints must be satisfied for a highscore to be created. More... | |
| struct | ScoreElement |
| Element of a score for a team. More... | |
Public Member Functions | |
| HighscoresDefinition (const shared_ptr< AppConfig > &refAppConfig, const std::vector< HighscoreConstraint > &aHighscoreConstraints, const std::vector< Discriminator > &aDiscriminators, const std::vector< Eligibility > &aEligibilitys, const std::vector< ScoreElement > &aScoreElements, int32_t nMaxScores) noexcept | |
| Constructor. More... | |
| const std::vector< Discriminator > & | getDiscriminators () const noexcept |
| const std::vector< Eligibility > & | getEligibilitys () const noexcept |
| const std::vector< ScoreElement > & | getScoreElements () const noexcept |
| int32_t | getMaxScores () const noexcept |
| The maximum number of scores in a highscore. More... | |
| bool | satisfiesPreferences (const AppPreferences &oAppPreferences) const noexcept |
| Whether this instance satisfies the given preferences. More... | |
| std::pair< bool, std::string > | getCodeFromPreferences (const AppPreferences &oAppPreferences) const noexcept |
| Return a code string that can identify a highscore based on the preferences. More... | |
| std::pair< bool, std::string > | getTitleFromPreferences (const AppPreferences &oAppPreferences) const noexcept |
| Return a title string that can identify a highscore based on the preferences. More... | |
| bool | isValidCode (const std::string &sCode) const noexcept |
| Whether a code string is valid. More... | |
| std::string | isCompatibleWithGame (const Game &oGame) const noexcept |
| Check compatibility with a game instance. More... | |
| bool | operator== (const HighscoresDefinition &oHS) const noexcept |
| void | dump () noexcept |
Protected Member Functions | |
| void | reInit (const shared_ptr< AppConfig > &refAppConfig, const std::vector< HighscoreConstraint > &aHighscoreConstraints, const std::vector< Discriminator > &aDiscriminators, const std::vector< Eligibility > &aEligibilitys, const std::vector< ScoreElement > &aScoreElements, int32_t nMaxScores) noexcept |
| See constructor. More... | |
|
noexcept |
Constructor.
If more than one ScoreElement is passed the one at index 0 (in the vector) is the most significant. Note: the variables are expected to be correct, this class doesn't check whether the Game really has them.
Since a highscore (file) might be created for each combination of Discriminators the total number should be kept low. So options that can take a huge amount of values shouldn't be used as discriminator. Example: an IntOption "Initial lives" that can take any positive number used as discriminator would create a highscore file for each value set in the preferences.
| refAppConfig | The config. Cannot be null. |
| aHighscoreConstraints | The game type conditions for this definition to apply. All must be true. Can be empty. |
| aDiscriminators | The discriminators. Can be empty. |
| aEligibilitys | Constraints for on a team to be eligible to a highscore. All must apply. If empty teams always eligible. |
| aScoreElements | The elements of a score. From the most significant to the least significant. Cannot be empty. |
| nMaxScores | The number of highscore entries. |
|
noexcept |
|
inlinenoexcept |
Return a code string that can identify a highscore based on the preferences.
This string can be used along with the game name (and the app name) to uniquely identify a highscore. It can be used to build the name of a highscore file or build the path of a key in a settings hierarchy like gconf.
Example: if HighscoresDefinition was initialized with one discriminator of type EnumOption (localized to french) with the name "Difficulty" and values (1,"Easy","Facile"), (2,"Medium","Moyen") and (3,"Hard","Difficile") this function would return "Medium" if the current value in the preferences for this option is 2. This string can then be used to define the highscore file name: for example "Jointris-Medium.sco".
If more discriminators are defined the values are separated with an "_" (underscore).
If one of the discriminator options is a not enabled slave option {false, ""} is returned.
| oAppPreferences | The preferences. |
{true, ""} is returned.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
The maximum number of scores in a highscore.
|
inlinenoexcept |
|
inlinenoexcept |
Return a title string that can identify a highscore based on the preferences.
This string can be used along with the game name (and the app name) as title of a highscore.
Example: if HighscoresDefinition was initialized with one discriminator of type EnumOption (localized to french) with the name "Difficulty", description "Difficulté" and values (1,"Easy","Facile"), (2,"Medium","Moyen") and (3,"Hard","Difficile") this function would return "Difficulté: Moyen" if the current value in the preferences for this option is 2. This string can then be used to define the title of a highscore dialog: for example "Jointris scores - Difficulté: Moyen".
If more discriminators are defined the values are separated with an ", ".
If one of the discriminator options is a not enabled slave option {false, ""} is returned.
| oAppPreferences | The preferences. |
{true, ""} is returned.
|
noexcept |
Check compatibility with a game instance.
Checks whether all the variable names in Eligibility and ScoreElement are defined.
| oGame | The game. |
|
noexcept |
Whether a code string is valid.
| sCode | The code string. Can be empty. |
|
noexcept |
|
protectednoexcept |
See constructor.
|
inlinenoexcept |
Whether this instance satisfies the given preferences.
The preferences must satisfy the constraints and all the discriminators by option must be either master or enabled slave option.
| oAppPreferences | The preferences. |
1.8.13