QtCraft API C++ classes QML types Handbook

QcEnchanting Namespace

What enchantments do (decision E-864), pure so that server and client (mining speed it predicts) share the rules: which items an enchantment applies to, the level of an effect on a stack and the effects' numbers as in the reference game. More...

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

Variables

const int maxProtectionPoints

Functions

bool appliesTo(const QcEnchantmentDefinition &enchantment, const QcItemDefinition &item)
bool conflict(const QcEnchantmentDefinition &a, const QcEnchantmentDefinition &b)
double damageBonus(int level)
bool keepsDurability(int level, double roll, bool armour)
QStringList kindsOf(const QcItemDefinition &item)
int levelOf(const QcContentRegistry &content, const QcItemStack &stack, QcEnchantmentEffect effect)
int protectionPoints(const QcContentRegistry &content, const QcEquipment &equipment, bool fall)
double reducedDamage(double amount, int points)
double speedBonus(int level)

Detailed Description

Enchantments whose name the content does not know do nothing.

Variable Documentation

const int QcEnchanting::maxProtectionPoints

The highest protection points (each takes 4 % off), as in the reference.

Function Documentation

bool QcEnchanting::appliesTo(const QcEnchantmentDefinition &enchantment, const QcItemDefinition &item)

Returns whether enchantment may be on item.

bool QcEnchanting::conflict(const QcEnchantmentDefinition &a, const QcEnchantmentDefinition &b)

Returns whether the enchantments a and b exclude each other (either names the other, or they are the same).

double QcEnchanting::damageBonus(int level)

Returns the melee damage sharpness of level adds: 0.5 × level + 0.5, none at 0.

bool QcEnchanting::keepsDurability(int level, double roll, bool armour)

Returns whether a use leaves the durability (unbreaking of level) with roll in [0, 1): tools keep it with chance level / (level + 1), armour with 0.4 × level / (level + 1).

QStringList QcEnchanting::kindsOf(const QcItemDefinition &item)

Returns the item kinds item belongs to for QcEnchantmentDefinition::items: its tool category and "digger" (pickaxe, axe, shovel, hoe), "weapon" (no digging tool but sword-like damage), "armour" and "armour_<slot>", "launcher" and "durable" (it wears).

int QcEnchanting::levelOf(const QcContentRegistry &content, const QcItemStack &stack, QcEnchantmentEffect effect)

Returns the highest level of an enchantment of content with effect on stack; 0 for none.

int QcEnchanting::protectionPoints(const QcContentRegistry &content, const QcEquipment &equipment, bool fall)

Returns the protection points of the armour worn in equipment against a hit, with the enchantments of content; fall adds feather falling (3 per level). Protection gives its level per piece. At most maxProtectionPoints.

double QcEnchanting::reducedDamage(double amount, int points)

Returns amount after points protection points (4 % each).

double QcEnchanting::speedBonus(int level)

Returns the mining speed the efficiency level adds to a matching tool: level² + 1, none at 0.