QcGameModes Namespace
The rules of each game mode, and its names; the mode itself is QcGameMode (registered for QML as GameMode, with GameMode.Mode.Creative and so on). More...
| Header: | #include <common/gameplay/QcGameMode.h> |
Classes
| struct | Rules |
Types
| enum class | Mode { Survival, Creative, Adventure, Spectator } |
Variables
| const int | count |
| const int | inventorySetCount |
Functions
| std::optional<QcGameMode> | fromValue(quint8 value) |
| int | inventorySet(QcGameMode mode) |
| QLatin1StringView | name(QcGameMode mode) |
| std::optional<QcGameMode> | parse(QStringView text) |
| QcGameModes::Rules | rules(QcGameMode mode) |
Detailed Description
Type Documentation
enum class QcGameModes::Mode
The game mode of a player (decision E-282), a server state per player that the client mirrors.
The values are stable: they are saved in player files and sent in the protocol.
| Constant | Value | Description |
|---|---|---|
QcGameModes::Mode::Survival | 0 | The normal rules: health, hunger, mining and building with what one has. |
QcGameModes::Mode::Creative | 1 | Flying, instant breaking, unlimited items from the catalogue, no damage and no hunger. |
QcGameModes::Mode::Adventure | 2 | Survival without breaking and placing except where the world's allow-lists permit it (decision E-735, QcAdventureRules). |
QcGameModes::Mode::Spectator | 3 | Flies through blocks, unseen and without touching anything (decision E-730). |
Variable Documentation
const int QcGameModes::count
The number of modes; their values are 0 to count - 1.
const int QcGameModes::inventorySetCount
Players of modes with the same inventory set share their inventory; changing to a mode of another set keeps the current inventory aside and brings back the one of that set (decision E-283). Survival and adventure are set 0, creative set 1; spectator keeps the survival set (it uses none).
Function Documentation
std::optional<QcGameMode> QcGameModes::fromValue(quint8 value)
Returns the mode of value, read from a file or the network; nullopt for unknown values.
int QcGameModes::inventorySet(QcGameMode mode)
Returns the inventory set of mode (see inventorySetCount).
QLatin1StringView QcGameModes::name(QcGameMode mode)
Returns the name of mode: "survival", "creative", "adventure", "spectator", the names of commands, settings files and world.json.
std::optional<QcGameMode> QcGameModes::parse(QStringView text)
Returns the mode text names: the name, a short form ("s", "c", "a", "sp") or the number ("0", "1", "2", "3"), in any case; nullopt otherwise.
QcGameModes::Rules QcGameModes::rules(QcGameMode mode)
Returns the rules of mode.