QtCraft API C++ classes QML types Handbook

QcServerExperience Class

Experience in the server tick (decision E-398): orbs move, merge and despawn (QcExperienceOrbManager), players collect them with a sound, a level gained plays the level-up sound, and every player whose experience changed gets it (QcMsg::PlayerExperience) at the end of the step. More...

Header: #include <server/items/QcServerExperience.h>

Public Functions

void givePoints(QcServerClient &client, qint64 points)
void sendChanges()
void tick()

Static Public Members

void drop(QcServerState &state, int points, const QcVec3 &position)
int roll(QcServerState &state, QcExperienceDrop range)
int takeWhole(QcServerState &state, double experience)

Detailed Description

The sources drop orbs through drop(): mined ores and killed creatures (QcExperienceDrop of their definition), furnaces when a player takes their output, bred animals, a dying player. Later spenders and givers (trading, enchanting, the anvil) change QcServerClient::experience directly (QcExperience::spendLevels, addLevels) or call givePoints(); the change reaches the client by itself.

Member Function Documentation

[static] void QcServerExperience::drop(QcServerState &state, int points, const QcVec3 &position)

Drops points as orbs at position in the world of state (no orbs for 0 or less).

void QcServerExperience::givePoints(QcServerClient &client, qint64 points)

Adds points to client (a collected orb, a trade); a gained level plays the level-up sound.

[static] int QcServerExperience::roll(QcServerState &state, QcExperienceDrop range)

Returns the points of the experience drop range, chosen evenly between its bounds with the random of state.

void QcServerExperience::sendChanges()

Sends the experience of every playing player whose experience changed since he last got it.

[static] int QcServerExperience::takeWhole(QcServerState &state, double experience)

Returns whole points of gathered experience (a furnace's): the fraction becomes one more point with its own chance (the random of state), as in the reference.

void QcServerExperience::tick()

One step: orbs and collecting, then the changed experience to the players.