QtCraft API C++ classes QML types Handbook

QcAdvancementProgress Class

The criteria one player has met, per advancement (decision E-923). More...

Header: #include <common/gameplay/QcAdvancementProgress.h>

Public Functions

QStringList advancements() const
QByteArray bytes() const
QSet<QString> criteria(const QString &advancement) const
bool grant(const QString &advancement, const QString &criterion)
bool has(const QString &advancement, const QString &criterion) const
bool isDone(const QcAdvancementDefinition &advancement) const
bool isEmpty() const
bool revoke(const QString &advancement, const QString &criterion)
bool setCriteria(const QString &advancement, const QSet<QString> &criteria)

Static Public Members

std::optional<QcAdvancementProgress> fromBytes(const QByteArray &bytes)
const qsizetype maxAdvancements
const qsizetype maxNameLength

Detailed Description

Advancements and criteria the content does not know (a mod removed, a later version) are kept as they are, so they come back when the content has them again; whether an advancement is reached follows from its requirements (isDone). The server keeps it per player and saves it with the player file; the client keeps the local player's copy from the server's messages.

Member Function Documentation

QStringList QcAdvancementProgress::advancements() const

Returns the advancements with at least one met criterion, sorted.

QByteArray QcAdvancementProgress::bytes() const

Returns the saved form: a format version and the met criteria by advancement, sorted.

QSet<QString> QcAdvancementProgress::criteria(const QString &advancement) const

Returns the met criteria of advancement; empty for none.

See also setCriteria().

[static] std::optional<QcAdvancementProgress> QcAdvancementProgress::fromBytes(const QByteArray &bytes)

Returns the progress saved in bytes; std::nullopt for damaged bytes; fields a later format appends are left out.

bool QcAdvancementProgress::grant(const QString &advancement, const QString &criterion)

Marks criterion of advancement met. Returns false when it was already (or the bounds are full, or a name is too long).

bool QcAdvancementProgress::has(const QString &advancement, const QString &criterion) const

Returns whether criterion of advancement is met.

bool QcAdvancementProgress::isDone(const QcAdvancementDefinition &advancement) const

Returns whether the met criteria fulfil the requirements of advancement.

bool QcAdvancementProgress::isEmpty() const

Returns whether no criterion is met.

bool QcAdvancementProgress::revoke(const QString &advancement, const QString &criterion)

Marks criterion of advancement unmet. Returns false when it was not met.

bool QcAdvancementProgress::setCriteria(const QString &advancement, const QSet<QString> &criteria)

Sets the met criteria of advancement (empty: none). Returns false when the bounds refuse it (a name too long, too many criteria, or no room for another advancement).

See also criteria().

Member Variable Documentation

const qsizetype QcAdvancementProgress::maxAdvancements

The most advancements a progress keeps (saving and reading); the criteria per advancement are bounded by QcAdvancementDefinition::maxCriteria.

const qsizetype QcAdvancementProgress::maxNameLength

The longest name of an advancement or criterion it keeps.