Knowledge
tilttek/player-knowledgeSecrets
A Secret belongs to one campaign. It has an identifier, a title of 1 to 150 characters — what the page of a character
shows once it knows it — and, if any, an Origin: where its text lives, such as a block of the campaign wiki
(new Origin('wiki-block', 'block-12')), a secret of a session's preparation or a handout. The library keeps the
reference, never the text: the application reads the text from the origin, and shows it only to those who know.
$knowledge->record('duke-ghoul', 'campaign-7', 'The duke is a ghoul', new Origin('wiki-block', 'block-12'));
$knowledge->retitle('duke-ghoul', 'The duke');
$knowledge->remove('duke-ghoul'); // with every revelation of it
A campaign holds 5 000 secrets at most. Every identifier — a secret, a campaign, a character, a player, a member, a
session — is 1 to 128 letters, digits, _, ., : or -, starting with a letter: an opaque identifier, never a name
nor an address.
Knowers
A Knower is who learns a secret:
| Knower | Who |
|---|---|
Knower::character('wren') | One character, in the fiction. |
Knower::player('ana') | One player, out of character. |
Knower::allCharacters() | Every character of the campaign, those who join later included. |
Knower::allPlayers() | Every player of the campaign, those who join later included. |
Its key — character:wren, player:* — is how the events and the stores name it; Knower::fromKey() reads it back.
Revelations
reveal() reveals a secret to 1 to 500 knowers at once, and returns the revelations it kept. Each Revelation says
when, the member who revealed it, how — Means::Told by the game master, Means::Discovered in play,
Means::Handout — and, if any, the session.
$knowledge->reveal('duke-ghoul', [Knower::character('wren')], $now, 'member-gm', Means::Discovered, 'session-4');
$knowledge->reveal('duke-ghoul', [Knower::allPlayers()], $now, 'member-gm'); // seen out of character
A knower holds at most one revelation of a secret, the first: revealed again, it keeps the first date, and a knower given twice counts once. A call where every knower knew the secret already keeps and tells nothing.
Sharing
share() records that a character told a secret it knows to other characters of its campaign; each revelation is
Means::Shared and names the character who told it.
$knowledge->share('duke-ghoul', 'wren', ['ash', 'bo'], $later, 'member-ana', 'session-5');
The character must know the secret in character — revealed to it, or to every character —: what only its player
knows is not its to share, and KnowledgeRefused says so. A character does not share with itself.
Perspectives
A Perspective says whose knowledge a page reads:
| Perspective | Counts the revelations to |
|---|---|
Perspective::gameMaster() | Everyone: the game master knows every secret of the campaign. |
Perspective::inCharacter('wren') | The character and every character: what it may act on in play. |
Perspective::atTable('wren', 'ana') | The character, every character, the player and every player. |
Perspective::player('ana') | The player and every player: a spectator, a player between characters. |
learned() is the page of what a perspective learned in a campaign: the first revelation of each secret it knows, by
date, the earliest first. whoKnows() is the game master's view of one secret: every revelation of it, by date.
outOfCharacter() lists what a player knows at the table that their character does not, in the order it was first
revealed, for the page to warn about.
Snapshots
A page that shows many entries — the summaries of a campaign journal, search results, notifications — reads one
KnowledgeSnapshot of its reader, and asks it of each entry, without reading the store again:
$snapshot = $knowledge->snapshot('campaign-7', Perspective::inCharacter('bo'));
$snapshot->knows('duke-ghoul'); // false
$snapshot->knowsAll(['duke-ghoul', 'crypt-key']); // true only when both are known
$snapshot->since('duke-ghoul'); // when it was first revealed, or null
$shown = $snapshot->filter($summaries, fn ($summary) => $summary->secrets);
An entry names the secrets it requires — 64 at most —, and shows only when all are known; an entry that requires none always shows. An entry that is hidden is hidden whole, its title included: a secret revealed to one character never shows to another through the title of a summary, a search result or a notification. The snapshot of the game master knows every secret, and lists those of the campaign.
Taking back and forgetting
retract() takes back the revelation of a secret to one knower: made by mistake, or undone by the game master. The
revelations it led to by sharing are kept: what was told in play stays told.
forget() erases every revelation to one character or one player, in every campaign: a member who left, a character
erased. It says how many there were. The revelations to every character or every player go with each secret, and are
erased with it by remove().