miaoda-game-deck-phaser
v0.3.3
Published
Phaser-friendly observable owner for miaoda-game-deck-core.
Readme
miaoda-game-deck-phaser
Use this Phaser 4 Scene Plugin when a Scene should own deck subscriptions across
shutdown and restart. It exposes deck state and operations but deliberately
registers no frame update because card operations happen on turns, commands, or
player actions. Use miaoda-game-deck-core directly when you do not need Scene
lifecycle ownership.
Install and use
pnpm add miaoda-game-deck-core miaoda-game-deck-phaserimport { DeckPlugin } from 'miaoda-game-deck-phaser';
// Register DeckPlugin in the Phaser Scene Plugin configuration, mapped as `deck`.
const controller = this.deck.create({
seed: 1234,
zones: [{ id: 'draw', cards }, { id: 'hand', limit: 10 }, { id: 'discard' }],
});
controller.onChange((event) => queueAnimation(event));
controller.shuffle();
controller.draw(5);
const hand = controller.cardsIn('hand');Controllers created by DeckPlugin are destroyed automatically on Scene
shutdown, including restart. A controller exposes cardsIn, count, find,
zoneOf, normal and strict move/remove operations, change subscriptions, and
toJSON/loadJSON; consumers do not need to reach through its core property.
Call adopt() only between onChange notification batches; schedule replacements after the current callback returns.
This package does not create cards, hand layouts, or input handlers. Build those
with Phaser or RexUI from cardsIn('hand'), and keep each rendered object's exact
card instance ID for production input.
The complete snapshot includes hidden cards and RNG state. Multiplayer hosts must project a player-safe view before sending it.
