Skip to content

Extension points

tilttek/dice-skins

The 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.

PointWhat an application givesShipped
Contract\SkinCatalogThe skins the site offers: from a file, a back office, a databaseStore\FixedSkinCatalog
Contract\SkinChoiceStoreThe storage of the members' choicesStore\InMemorySkinChoiceStore
Contract\OwnedDiceThe dice a member owns, and the one they chose for a number of sidesCollections\ShelfOwnedDice, Store\NoOwnedDice
The default skinThe key of the skin a member who chose nothing getsBaseSkins::DEFAULT, ivory

Every point is passed to the constructor of DiceSkins, which keeps nothing between two calls.

The library also fills an extension point of another package: DiceBundle\DiceSkinsAppearance implements the DiceAppearance port of tilttek/dice-bundle, as Rolling with tilttek/dice-bundle explains.

Storing the choices

A SkinChoiceStore keeps one choice per member for all their dice — $sides null — and one per member and number of sides:

  • save() replaces the member's choice for the same number of sides, or for all their dice;
  • find() gives it, or null;
  • remove() returns whether there was one;
  • ofMember() lists the choice for all the dice first, then the others by number of sides;
  • eraseMember() removes every choice of the member and returns how many, for the erasure of a member.

SkinChoice::toArray() gives the row to keep: the member as kind:identifier, the skin key and the number of sides.

Owned dice from another source

An application whose members own dice elsewhere implements Contract\OwnedDice: ownedBy() lists OwnedDies — the item, its name, its number of sides, its colour, its material as free text and the member's copy —, and chosen() gives the die the member rolls for a number of sides, or null.