Extension points
tilttek/character-retirementThe package is at 0.x: its extension points are stable only from its 1.0 release. Until then, a minor version may
change them, and its CHANGELOG says how.
| To | Do |
|---|---|
| Keep the endings | Implement Contract\EndingStoreInterface, and pass it to CharacterEndings. |
| Act on what happened | Implement Contract\EndingObserverInterface, and pass it to CharacterEndings. |
| Keep a character out of play | Read CharacterEndings::current() before changing its sheet. |
| Say who may end, write, share or bring back | Check it in the application before calling CharacterEndings. |
The store
Contract\EndingStoreInterface keeps the endings, each at a version, with at most one open ending by sheet:
ending()gives one by its identifier, or null;endingsOf()gives those of a sheet, open or not,openIn()the open ones of a campaign, andendingsOwnedBy()those of the sheets a member keeps, each in the order they were first kept;countIn()says how many a campaign holds, open or not;save()keeps an ending at the next version and returns it. One at version 0 is new: the store has none of its identifier and no open ending of its sheet. Any other is kept only when the store holds it at that version.EndingConflictis raised otherwise, nothing kept;delete()erases an ending when the store holds it at its version, and raisesEndingConflictotherwise, nothing erased.
Two requests end the same character at once: the first save() keeps its ending, and the second is refused with
EndingConflict. A database store holds a unique key on the sheet of the open endings for this — a partial index
where the return is null.
Store\InMemoryEndingStore keeps them in memory, as long as the object lasts: it is for tests. An application keeps
them in its database: an ending holds strings, two enumerations, two moments, an integer version, and its frozen sheet
as the JSON of FrozenSheet::toArray(), read back by FrozenSheet::fromArray(). openIn() is read at each page of
the memorial: a database store indexes the endings by campaign and return.
The observer and its events
Contract\EndingObserverInterface::notify() is told each fact once it is kept, by identifiers only:
| Event | When | Carries |
|---|---|---|
Event\CharacterEnded | A character's story ended. | the ending, the sheet, the campaign, the Fate |
Event\EndingChanged | Its cause, its epitaph or its visibility changed. | the ending, the sheet, the Change |
Event\CharacterReturned | The character came back. | the ending, the sheet |
Event\EndingRemoved | An ending was erased. | the ending, the sheet |
Every event implements Event\EndingEventInterface. A change that changes nothing keeps nothing and tells nothing. No
event carries a cause, an epitaph or a name: an application sends a message with the identifiers alone — to tell the
table, to add the ending to a session's summary —, and the handler reads the rest from the store.
Who may do what
CharacterEndings does not know who calls it. The application checks before each call that the member may: the owner
of the sheet or the game master of the campaign ends a character and sets its cause; the owner writes its epitaph and
shares it; the game master brings it back when the story allows; the owner removes an ending.