Skip to content

tilttek/homebrew-hub

✅ published

House rules shared from one table to another: published in versioned releases under a licence, remixed with credit, endorsed, and adopted by a table that sees what each new release changes.

tilttek/homebrew-hub lets a game master share the house rules of their table — the rules written with tilttek/table-rules — for other tables to find, adopt and build on.

  • Releases. An author publishes a homebrew: a title, a summary, tags, house rules, rule variants of a game system, and a note on what changed. Each publication is a numbered release, never changed afterwards; publishing the latest release again is refused.
  • Licences. The author chooses the licence of each release: a Creative Commons 4.0 licence, the public domain, or all rights reserved. The licence says whether others may remix it, and under which licence.
  • Remixes with credit. A remix starts from a release of another homebrew and keeps the credit of it and of every homebrew it came from, as they were when it was made. A licence that forbids derivatives refuses the remix, a share-alike one asks for the same licence, a non-commercial one for a non-commercial licence; an author remixes their own homebrews freely.
  • Endorsements. A member endorses a homebrew, once, and withdraws the endorsement; there is no score out of five, and an author never endorses their own.
  • Adoption by a table. A table adopts a release into its rules, beside its own and those of other homebrews, and keeps it until it adopts another: a new release never changes a table on its own. The table sees when a later release is out and what it changes, rule by rule and line by line, then adopts it or not; dropping the homebrew takes its rules out. Each adoption asks every player to accept the table's rules again.
  • Finding homebrews. By game system, tag or author, the most endorsed or the most recent first, one page at a time. An author retires a homebrew: it is no longer found, adopted nor remixed, and the tables that follow it keep their release.
  • Content packs. A draft is written to a JSON document and read back, to move a homebrew from one hub to another; the reader refuses any document out of the format and its bounds.

The services read the time from a PSR-20 clock and from nothing else. The facts of the hub — a release published, a homebrew remixed, endorsed, retired, adopted or dropped — go to an observer, each once, by identifiers only.

It is a plain PHP library: two services, a codec, value objects, ports and stores kept in memory for tests.

Status

PartState
Draft, Release, Homebrew, Origin, Licence, Subscription: homebrews, releases, credits and subscriptions, bounded and checkedImplemented and tested
HomebrewHub: publish, remix, endorse, withdraw, retire, search and compare releasesImplemented and tested
Adoption: adopt a release into a table's rules, drop a homebrew, and the table's subscriptions with what changedImplemented and tested
Codec\DraftJson: a draft as a JSON document, written and read backImplemented and tested
Store\InMemoryHomebrewStore, Store\InMemorySubscriptionStore, Store\NoTransactions: the stores of the testsImplemented and tested
A Symfony bundle: the Doctrine stores, Messenger messages and a Stimulus display of a release's changesNot started

Documentation

DocumentWhat it covers
InstallationRequirements, installing and wiring.
Homebrews and adoptionDrafts, releases, licences, remixes, endorsements, retirement, search, adoption, subscriptions and content packs.
Extension pointsThe stores, the transactions, the observer and its events, the clock, and who may do what.
ExceptionsHomebrewException and its exceptions.
TestingThe library's tests, its fuzz target and its benchmarks.
ReferenceEvery type of the library, with its role.

Quick start

use Tilttek\HomebrewHub\Adoption;
use Tilttek\HomebrewHub\Draft;
use Tilttek\HomebrewHub\HomebrewHub;
use Tilttek\HomebrewHub\Licence;
use Tilttek\TableRules\Rule;

$hub = new HomebrewHub($homebrews, $clock, $observer);       // your HomebrewStore, a PSR-20 clock, an observer

$hub->publish('gritty-healing', 'author-7', new Draft(
    'Gritty healing',
    [new Rule('rest', 'Rest', 'A long rest takes a week in a safe place.', 'healing')],
    Licence::AttributionShareAlike,
    variants: ['slow-healing'],
    system: 'srd-5',
    tags: ['grim'],
));
$hub->endorse('gritty-healing', 'member-3');

$adoption = new Adoption($homebrews, $subscriptions, $tableRules, $clock, $transactions);
$adoption->adopt('campaign-7', 'gm-1', 'gritty-healing');    // its rules join the table's, as gritty-healing.rest

foreach ($adoption->subscriptions('campaign-7') as $subscription) {
    $subscription->toArray();                                // up to date, or what the latest release changes
}

Requirements

PHP 8.5 or later, with psr/clock and tilttek/table-rules, which keeps the rules of the tables.

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.