QtCraft API C++ classes QML types Handbook

QcStatusEffects Class

The status effects of a player or a creature (decision E-450): at most one of each kind. More...

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

Public Functions

const QList<QcStatusEffect> &all() const
bool clear()
const QcStatusEffect *find(const QString &name) const
bool give(const QcStatusEffect &effect)
bool isEmpty() const
bool remove(const QString &name)
void restore(const QList<QcStatusEffect> &effects)
double speedFactor(const QcContentRegistry &content) const
bool tick()

Static Public Members

QString levelName(int level)
const int maxEffects
const int maxTicks
bool plausible(const QcStatusEffect &effect, int maxLevel)
std::optional<QList<QcStatusEffect>> read(QDataStream &stream)
double speedFactor(const QcContentRegistry &content, const QList<QcStatusEffect> &effects)
void write(QDataStream &stream, const QList<QcStatusEffect> &effects)

Detailed Description

They count down with the server's ticks; the server applies what they do (QcServerEffects) and tells the player of his own with his health.

Member Function Documentation

const QList<QcStatusEffect> &QcStatusEffects::all() const

Returns every effect.

bool QcStatusEffects::clear()

Takes all away. Returns false when there were none.

const QcStatusEffect *QcStatusEffects::find(const QString &name) const

Returns the effect of kind name; null when the body has none.

bool QcStatusEffects::give(const QcStatusEffect &effect)

Gives effect like the reference: a higher level replaces the one of its kind, the same level lasts the longer of both, a lower one does nothing. Returns whether anything changed.

bool QcStatusEffects::isEmpty() const

Returns whether the body has no effect.

[static] QString QcStatusEffects::levelName(int level)

Returns level as the HUD shows it: Roman numerals from I to X (QcEffectDefinition::maxLevel), the number beyond.

[static] bool QcStatusEffects::plausible(const QcStatusEffect &effect, int maxLevel)

Returns whether a read effect is within the bounds: a name, a level from 1 to maxLevel and 1 to maxTicks ticks left.

[static] std::optional<QList<QcStatusEffect>> QcStatusEffects::read(QDataStream &stream)

Returns the effects read from stream in the form of write(); std::nullopt for damaged data (too many, out of bounds).

bool QcStatusEffects::remove(const QString &name)

Takes the effect of kind name away. Returns false when there was none.

void QcStatusEffects::restore(const QList<QcStatusEffect> &effects)

Replaces the list with effects as read back (saved effects): of duplicate kinds the first stays, and at most maxEffects are kept (read() checked the bounds).

double QcStatusEffects::speedFactor(const QcContentRegistry &content) const

Returns the factor on the speed of the body that has them (slowness, decision E-838): the product of their kinds' QcEffectDefinition::speedFactorAt in content; 1 without any, kinds no pack has do nothing.

[static] double QcStatusEffects::speedFactor(const QcContentRegistry &content, const QList<QcStatusEffect> &effects)

Returns the speed factor of a body with effects, as the member speedFactor() does with the kinds of content.

bool QcStatusEffects::tick()

Counts every effect down by one tick and drops the ended ones. Returns true when one ended.

[static] void QcStatusEffects::write(QDataStream &stream, const QList<QcStatusEffect> &effects)

Writes effects to stream in the saved form (creature components, player files): a count, then name, level and ticks of each.