tilttek/player-knowledge
✅ publishedWhat each character learned, kept apart from what its player knows: secrets revealed to one, some or all, dated, shared in play, and kept off every page of those who never learned them.
tilttek/player-knowledge keeps the secrets of a campaign and who knows them. The text of a secret lives elsewhere — a block of the campaign wiki, a secret of a session's preparation, a handout —: the library keeps its title, where it lives, and each revelation.
- Revealed by the game master. A secret is revealed to one character, to several, or to every character of the campaign, those who join later included; each revelation is dated, says who made it, how — told, discovered, given by a handout — and during which session.
- Character and player apart. A player may know what their character does not — a scene watched from across the table, a rule read ahead —: the game master reveals it to the player, out of character. The page of a player says what they know out of character that their character does not, so that they do not act on it in play.
- Shared in play. A character who knows a secret tells it to others; the revelation names the character who told it. A character cannot share what only its player knows.
- Kept off every page. A snapshot of what one perspective knows is read once per page, and asked of every entry it shows — a session summary, a search result, a notification —: an entry that names a secret its reader does not know never shows, its title included.
- Taken back and forgotten. A revelation made by mistake is taken back; every revelation to a member who left, or a character erased, is erased in every campaign.
The facts — a secret recorded, changed, removed, revealed, a revelation taken back, a knower forgotten — go to an observer, each once, by identifiers only.
It is a plain PHP library, without dependencies: one service, value objects, ports and a store kept in memory for tests.
Status
| Part | State |
|---|---|
Knower, Perspective: characters, players, every character, every player, and whose knowledge a page reads | Implemented and tested |
Secret, Origin, Revelation, Means: a secret, where its text lives, and each revelation, dated | Implemented and tested |
Knowledge: record, retitle, remove, reveal, share, retract, forget, who knows, what a perspective learned | Implemented and tested |
KnowledgeSnapshot: what a perspective knows, read once and asked of every entry of a page | Implemented and tested |
Store\InMemoryKnowledgeStore: the store of the tests | Implemented and tested |
| A Symfony bundle with its Doctrine store, its Twig filter and the page of what a character knows | Not started |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, installing and wiring. |
| Knowledge | Secrets, knowers, revelations, sharing, perspectives, snapshots, and erasing. |
| Extension points | The store, the observer and its events, and who may do what. |
| Exceptions | PlayerKnowledgeExceptionInterface and its exceptions. |
| Testing | The library's tests, its fuzz target and its benchmarks. |
| Reference | Every type of the library, with its role. |
Quick start
use Tilttek\PlayerKnowledge\Knower;
use Tilttek\PlayerKnowledge\Knowledge;
use Tilttek\PlayerKnowledge\Means;
use Tilttek\PlayerKnowledge\Origin;
use Tilttek\PlayerKnowledge\Perspective;
$knowledge = new Knowledge($store, $observer);
$knowledge->record('duke-ghoul', 'campaign-7', 'The duke is a ghoul', new Origin('wiki-block', 'block-12'));
$knowledge->reveal('duke-ghoul', [Knower::character('wren')], $now, 'member-gm', Means::Discovered, 'session-4');
$knowledge->share('duke-ghoul', 'wren', ['ash'], $later, 'member-ana');
$snapshot = $knowledge->snapshot('campaign-7', Perspective::inCharacter('bo'));
$shown = $snapshot->filter($summaries, fn ($summary) => $summary->secrets); // Bo never sees the duke's entry
Requirements
PHP 8.5 or later.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Tilttek project. See LICENSE.