QcAnvil Namespace
The anvil's rules (decision E-866), pure so that tests and the server share them, as in the reference game: the left stack is repaired with its material (each item a quarter of the durability, one level each), combined with a second item of its kind (durability of both plus 12 %, two levels; the right item's enchantments merge in: equal levels rise by one up to the highest, otherwise the higher stays; conflicting or unfitting ones cost a level and stay off) and renamed (one level). More...
| Header: | #include <common/gameplay/QcAnvil.h> |
Classes
| struct | Result |
Variables
| const double | landingWearPerBlock |
| const int | swapLevelItems |
| const int | tooExpensive |
| const double | wearChance |
Functions
| int | costPerLevel(const QcEnchantmentDefinition &enchantment) |
| QString | nameFrom(const QString &text) |
| int | penaltyOf(int uses) |
| QcAnvil::Result | result(const QcContentRegistry &content, const QcItemStack &left, const QcItemStack &right, const QString &name) |
| int | swapLevels(int count) |
Detailed Description
Every use adds the prior-work penalty 2^n − 1 of both stacks and raises the result's count of uses by one (a rename alone does not). From tooExpensive levels on the anvil refuses, except a rename alone, which costs at most tooExpensive − 1. An anvil swap (decision E-870, QcItemDefinition::anvilSwap) turns a whole stack into its other item, paid with one with in the right slot and one level per started swapLevelItems items; it adds the prior-work penalty but keeps the stack's prior work. An enchanted book in the right slot (decision E-873) gives its enchantments to the left item, a book included, at half the cost per level (at least 1) and without repairing.
Variable Documentation
const double QcAnvil::landingWearPerBlock
Chance per block fallen (rounded up) that a falling anvil wears on a landing that hurts.
const int QcAnvil::swapLevelItems
Items per level of an anvil swap: a full stack of 64 costs 4 levels.
const int QcAnvil::tooExpensive
From this cost on the anvil refuses (outside creative mode), as in the reference.
const double QcAnvil::wearChance
The chance that an anvil wears one step on each use.
Function Documentation
int QcAnvil::costPerLevel(const QcEnchantmentDefinition &enchantment)
Returns the levels each level of enchantment costs when merged, from its weight as the reference's rarity: 1 (weight 10 or more), 2 (5 or more), 4 (2 or more), else 8.
QString QcAnvil::nameFrom(const QString &text)
Returns text as a custom name (QcNameText::clean: without control and format characters, trimmed), cut between graphemes to at most QcItemData::maxNameLength UTF-16 units.
int QcAnvil::penaltyOf(int uses)
Returns the levels the prior-work count uses adds: 2^uses − 1.
QcAnvil::Result QcAnvil::result(const QcContentRegistry &content, const QcItemStack &left, const QcItemStack &right, const QString &name)
Returns the result for left and right with name in the name field, with the items and enchantments of content: the left stack's custom name leaves it unchanged, other text renames it, blank text takes a custom name off (and changes nothing on a stack without one).
int QcAnvil::swapLevels(int count)
Returns the levels an anvil swap of count items costs: one per started swapLevelItems, at least one.