QcWeatherCycle Namespace
The weather's course as a pure function of the world seed (decision E-395): after a clear spell comes rain or a thunderstorm, after them a clear spell again; the kind and length of each spell follow from the seed and the spell's number, so the same world has the same weather whatever happens in it, and /tick steps through it exactly. More...
| Header: | #include <server/weather/QcWeatherCycle.h> |
Classes
| class | Draws |
Variables
| const int | fadeTicks |
| const qint64 | maxSetTicks |
| const int | thunderChance |
Functions
| QcWeatherState | begun(QcWeatherState state, qint64 seed, QcWeatherKind kind, std::optional<qint64> ticks) |
| QcWeatherState | fromJson(const QJsonObject &json) |
| qint64 | lengthOf(qint64 seed, qint64 spell, QcWeatherKind kind) |
| QcWeatherState | next(QcWeatherState state, qint64 seed, bool cycle) |
| QcWeatherKind | nextKind(qint64 seed, qint64 spell, QcWeatherKind previous) |
| QJsonObject | toJson(const QcWeatherState &state) |
Detailed Description
Classes
class Draws
The random draws of one tick for purpose (strikes, snowfall), from the seed and the tick the weather has reached: the same world draws the same in the same tick, whenever the server was started. More...
Variable Documentation
const int QcWeatherCycle::fadeTicks
Ticks a strength takes to fade fully in or out (10 s).
const qint64 QcWeatherCycle::maxSetTicks
Longest spell /weather sets (one million seconds).
const int QcWeatherCycle::thunderChance
Chance in 100 that a spell after a clear one is a thunderstorm instead of rain.
Function Documentation
QcWeatherState QcWeatherCycle::begun(QcWeatherState state, qint64 seed, QcWeatherKind kind, std::optional<qint64> ticks)
Returns the weather of state with a spell of kind begun (/weather) in the world with seed: lasting ticks, or as long as the seed says.
QcWeatherState QcWeatherCycle::fromJson(const QJsonObject &json)
Returns the weather read from world.json's "weather" object json; reading clamps every value into its range, a missing or damaged object reads as a world whose first spell has not begun.
qint64 QcWeatherCycle::lengthOf(qint64 seed, qint64 spell, QcWeatherKind kind)
Returns the length in ticks of spell number spell of kind in the world with seed.
QcWeatherState QcWeatherCycle::next(QcWeatherState state, qint64 seed, bool cycle)
Returns the weather one tick after state in the world with seed: with cycle (game rule weatherCycle) the spell runs down and the next begins when it ends; the strengths fade towards the kind either way.
QcWeatherKind QcWeatherCycle::nextKind(qint64 seed, qint64 spell, QcWeatherKind previous)
Returns the kind of spell number spell that follows a spell of previous in the world with seed.
QJsonObject QcWeatherCycle::toJson(const QcWeatherState &state)
Returns state as world.json's "weather" object.