QtCraft API C++ classes QML types Handbook

QcGameRules Namespace

The game rules of a world (QcWorldInfo, world.json "gameRules") as /gamerule and the admin channel's settings see them (decision E-848): a switch or a number from 0 to highest, each with its group, its default and what it does. More...

Header: #include <server/commands/QcGameRules.h>

Classes

struct Rule

Variables

const char[12] context

Functions

std::span<const QcGameRules::Rule> all()
const QcGameRules::Rule *find(QStringView name)
qint64 value(const QcGameRules::Rule &rule, const QcWorldInfo &info)

Detailed Description

group and description are English texts marked with QT_TRANSLATE_NOOP("QcGameRules", ...). New rules are one line in all().

Classes

class Rule

One game rule. More...

Variable Documentation

const char[12] QcGameRules::context

The translation context of the rules' texts.

Function Documentation

std::span<const QcGameRules::Rule> QcGameRules::all()

Returns every rule.

const QcGameRules::Rule *QcGameRules::find(QStringView name)

Returns the rule named name, case sensitive as /gamerule takes it; nullptr when there is none.

qint64 QcGameRules::value(const QcGameRules::Rule &rule, const QcWorldInfo &info)

Returns the value of rule in info (a switch as 0 or 1).