RandomTable.h header
#include <ew/core/RandomTable.h>
Namespace ew::core
RandomTable class
class ew::core::RandomTable
A weighted random table: a titled list of outcomes that a game master (or any writer chasing an unexpected prompt) can "roll" on to get a random result. It backs the TTRPG random-tables tool – encounter tables, loot drops, rumour mills, weather, wandering-monster charts – but is useful to any author who wants a nudge. A RandomTable is a first-class content object so tables are saved with the project, listed, searched, shared through a library, and undone/redone like anything else. The roll itself lives in ew::app (rollOnTable) so the core stays GUI- and randomness-free and deterministic.
Members
ew::core::RandomTable::RandomTable(ContentId id, QString title)
Creates an empty table with identity id and the given title.
const QString & ew::core::RandomTable::title() const
The table's display name (e.g. "Wilderness Encounters").
void ew::core::RandomTable::setTitle(QString title)
Sets the table's display name.
const std::vector< RandomTableEntry > & ew::core::RandomTable::entries() const
The weighted outcomes, in author order.
void ew::core::RandomTable::setEntries(std::vector< RandomTableEntry > entries)
Sets the weighted outcomes, in author order.
int ew::core::RandomTable::totalWeight() const
The sum of every entry's weight (0 for an empty table) – the effective die size a roll picks within. Weights below 1 are treated as 1 so a malformed entry still counts.
RandomTableEntry struct
struct ew::core::RandomTableEntry
One weighted outcome on a RandomTable.
Members
int ew::core::RandomTableEntry::weight = 1
Relative likelihood of this outcome, at least 1 – an entry with weight 2 is twice as likely to come up as one with weight 1. Equal weights give a uniform (fair-die) table.
QString ew::core::RandomTableEntry::text
The result text produced when this outcome is rolled (an encounter, a loot drop, a rumour, weather, a name – whatever the table is for). Markdown is permitted.
bool ew::core::RandomTableEntry::operator==(const RandomTableEntry &other) const =default
Compares equal when every field matches.