miaoda-game-objective-core
v0.2.0
Published
Engine-agnostic count, set, sequence, and timed gameplay objectives.
Downloads
590
Maintainers
Readme
miaoda-game-objective-core
Use this package for lightweight gameplay goals: counters, unordered collections, ordered sequences, tutorial steps, achievements, pinball modes, and timed challenges. It tracks progress and completion but does not provide a restorable quest save format.
Install and use
pnpm add miaoda-game-objective-coreimport { ObjectiveSet } from 'miaoda-game-objective-core';
const objectives = new ObjectiveSet([
{ id: 'bumpers', type: 'count', event: 'bumper-hit', target: 10 },
{ id: 'lanes', type: 'set', events: ['lane-l', 'lane-i', 'lane-t'] },
{ id: 'combo', type: 'sequence', events: ['left', 'orbit', 'right'], timeout: 5 },
], { completion: 'all' });
objectives.emit('bumper-hit');
objectives.tick(dtSeconds);count accumulates an amount, set completes after every listed input in any order, and sequence requires inputs in order. A timeout resets incomplete progress after the configured seconds. The set can complete when all or any objectives complete.
Use onChange for progress/completion/reset events and state() for a JSON-safe UI snapshot. Snapshots intentionally omit exact set membership and cannot be loaded. Use quest-core when progress must be restored across saves or coordinated through stages and rewards.
