QtCraft API C++ classes QML types Handbook

QcTradeParser Namespace

Parses the offers of a profession (trades/<name>.json) and the trading settings of a villager species, villagers/<name>.json (decision E-414). More...

Header: #include <common/content/villages/QcTradeParser.h>

Functions

QcResult<QcTradeSet> parseTradeSet(const QJsonObject &json, const QString &packNamespace)
QcTradingSettings readTradingSettings(QcJsonFieldReader &reader)

Detailed Description

All input is untrusted; item names are checked when the server builds its trade catalog (QcTradeCatalog), where all packs are loaded.

Function Documentation

QcResult<QcTradeSet> QcTradeParser::parseTradeSet(const QJsonObject &json, const QString &packNamespace)

Returns the set of offers defined by json (a file in trades), names qualified with packNamespace, or the first error.

QcTradingSettings QcTradeParser::readTradingSettings(QcJsonFieldReader &reader)

Returns the settings at "trading" of the object of reader; the defaults without the key. Errors go to reader.