QtCraft API C++ classes QML types Handbook

QcLootTables Class

The loot tables of the content (decision E-521), replaced by name like other definitions, and what one gives: roll() draws the pools of a table from a seed (the same seed gives the same loot) and scatters the stacks over the free slots of a chest. More...

Header: #include <common/content/recipes/QcLootTables.h>

Public Types

struct ItemInfo
ItemLookup

Public Functions

void add(QcLootTableDefinition table)
const QList<QcLootTableDefinition> &all() const
const QcLootTableDefinition *find(const QString &name) const

Static Public Members

QList<QcItemStack> draw(const QcLootTableDefinition &table, quint64 seed, const QcLootTables::ItemLookup &items)
QList<QcItemStack> scatter(const QList<QcItemStack> &stacks, int slotCount, quint64 seed)

Detailed Description

Server side only.

Member Type Documentation

[alias] QcLootTables::ItemLookup

Resolves an item name to its ItemInfo (std::nullopt: unknown, the draw gives nothing).

Member Function Documentation

void QcLootTables::add(QcLootTableDefinition table)

Adds table, replacing a table of the same name in its place.

const QList<QcLootTableDefinition> &QcLootTables::all() const

Returns all tables in the order they were first added.

[static] QList<QcItemStack> QcLootTables::draw(const QcLootTableDefinition &table, quint64 seed, const QcLootTables::ItemLookup &items)

Returns the stacks table gives for seed, in drawing order, with item names resolved by items (an entry's count beyond its item's stack size is split).

const QcLootTableDefinition *QcLootTables::find(const QString &name) const

Returns the table named name, or nullptr when there is none.

[static] QList<QcItemStack> QcLootTables::scatter(const QList<QcItemStack> &stacks, int slotCount, quint64 seed)

Returns stacks scattered over slotCount slots (empty ones stay empty), each to a random free slot drawn from seed; stacks beyond the slots are left out.