2 SPDX-FileCopyrightText: 2007 Nicolas Roffet <[email protected]>
3 SPDX-FileCopyrightText: 2007 Pino Toscano <[email protected]>
17 class QObject;
19 class KXmlGuiWindow;
68 * Note that this class is a singleton. So you can have only one current difficulty level per application.
70 * @author Nicolas Roffet, <[email protected]>
78 * Does the game have to be restarted, when the player changes the difficulty level? In this case and if the game is running, a confirmation dialog is displayed and the player can cancel the change.
81 RestartOnChange, /**< The current game has to be canceled and a new game will be started on change. */
82 NoRestartOnChange /**< The current game can continue on change. */
88 * If they fit the needs of the game, the standard appellations of the difficulty levels should be used.
91 RidiculouslyEasy = 10, /**< Level "Ridiculously easy" */
92 VeryEasy = 20, /**< Level "Very easy" */
93 Easy = 30, /**< Level "Easy" */
94 Medium = 40, /**< Level "Medium" */
95 Hard = 50, /**< Level "Hard" */
96 VeryHard = 60, /**< Level "Very hard" */
97 ExtremelyHard = 70, /**< Level "Extremely hard" */
98 Impossible = 80, /**< Level "Impossible" */
99 Configurable = 90, /**< Level "Custom". This is a special item to let the player configure the difficulty level. The configuration of the user level has to be implemented in each game using it with an adapted dialog. Example: In a minesweeper game like KMines, the player wants to define the number of rows, columns and mines. */
100 Custom = 100, /**< Any custom appellations for levels */
101 NoLevel = 110 /**< No level */
108 virtual ~KGameDifficulty();
117 * @param slotStandard Slot to call when the player changed the difficulty level to a standard one. Slot should have the signature like: SLOT(levelChanged(KGameDifficulty::standardLevel))
118 * @param slotCustom Slot to call when the player changed the difficulty level to a custom one. (Optional). Slot should have the signature like: SLOT(customLevelChanged(int))
120 static void init(KXmlGuiWindow* window, const QObject *recvr, const char* slotStandard, const char* slotCustom = nullptr);
128 static void setRestartOnChange(onChange restart);
133 * You should add all the standard difficulty levels you need after the initialization of the class.
137 static void addStandardLevel(standardLevel level);
144 static void removeStandardLevel(standardLevel level);
149 * If you need custom appellations like "8x8", "Coward", "Courageous", "Tired of life" or whatever, you can define them with this method.
151 * @param key Custom level identifier. (It must be distinct for every different level. Trying to add a new level with an allocated key replace the previous level.).
154 static void addCustomLevel(int key, const QString& appellation);
177 static void setLevel(standardLevel level);
182 * @return The current standard level, or customLevel if a custom level is selected, or noLevel if no difficulty level is selected.
184 static standardLevel level();
188 static QString levelString();
192 static QPair<QByteArray, QString> localizedLevelString();
196 static QMap<QByteArray, QString> localizedLevelStrings();
198 * @return map with the weight order of untranslated standard level names matches value of standardLevel enum
201 static QMap<int, QByteArray> levelWeights();
213 * It does only make sense to get the current custom difficulty level, if the value of the level is "custom".
239 static KGameDifficulty* self();
241 static KGameDifficulty* instance;
KGameDifficuty manages the game difficulty levels in a standard way.
QCA_EXPORT void init()
Standard difficulty levels.