QcServerTrading Class
Trading with villagers (decision E-414), server-authoritative. More...
| Header: | #include <server/villages/QcServerTrading.h> |
Public Functions
| void | close(QcServerClient &client, bool notify) |
| bool | open(QcServerClient &client, quint32 id) |
| void | trade(QcServerClient &client, QcMsg::Trade message) |
| void | update() |
Static Public Members
| const int | maxRepeats |
Detailed Description
A player using a villager with a profession opens its trading screen (QcMsg::TradeState): one trader per villager at a time, who it stands facing while the screen is open. A trade pays the costs at their current price from the inventory and gives the result (what does not fit is thrown, like from the other screens), counts a use, gives the villager experience (a level reached adds offers) and drops the player's experience as orbs. The screen closes when the villager flees (danger, a hit), dies, goes to bed or sleeps, or the player dies, leaves, walks out of reach or opens a block's screen.
Member Function Documentation
void QcServerTrading::close(QcServerClient &client, bool notify)
Ends the trade of the player of client; notify tells the client (the server closed it).
bool QcServerTrading::open(QcServerClient &client, quint32 id)
The player of client used the creature id: a villager with offers opens its trading screen, one without turns to the player and speaks. Returns false when it is no villager in reach (the use goes on).
void QcServerTrading::trade(QcServerClient &client, QcMsg::Trade message)
Carries out the trade message of the player of client with the villager whose screen is open.
void QcServerTrading::update()
Once per tick: closes screens whose villager or player is gone, fled or out of reach, keeps the villagers facing their traders and sends what changed (a restock, a level).
Member Variable Documentation
const int QcServerTrading::maxRepeats
A repeated trade (shift-click) trades at most this often.