miaoda-game-adventure-interaction-core
v0.2.0
Published
Engine-agnostic deterministic interaction rules for point-and-click adventures and detective AVG games.
Maintainers
Readme
miaoda-game-adventure-interaction-core
Deterministic, engine-neutral interaction rules for point-and-click adventures and detective games. Use it when rooms, inventory, evidence, and verb/target actions need one authoritative state machine; it does not render rooms or dialogue.
pnpm add miaoda-game-adventure-interaction-coreimport {AdventureInteractionEngine, type AdventureContent} from 'miaoda-game-adventure-interaction-core';
const content: AdventureContent = {
registries: {verbs: ['use'], rooms: ['dock'], targets: ['gate'], items: ['key'], topics: [], evidence: [], dialogues: [], flags: ['open'], facts: []},
rules: [{id: 'open-gate', room: 'dock', verb: 'use', target: 'gate', with: {kind: 'item', id: 'key'}, effects: [{kind: 'setFlag', id: 'open'}], result: {code: 'gate-opened'}}],
initialState: {room: 'dock', flags: {}, inventory: ['key'], knownEvidence: [], unlockedTopics: [], facts: []},
};
const game = new AdventureInteractionEngine(content);
const actions = game.queryAvailableActions({target: 'gate'});
const result = game.dispatch({verb: 'use', target: 'gate', with: {kind: 'item', id: 'key'}});Content is validated before play. Queries and dispatch use the same conditions, including current room and available inventory/evidence/topics. ActionRequest.room is an expected-room guard, never a teleport.
queryAvailableRecipes() and combine(a, b) support deterministic item combinations. snapshot() and load() are JSON-safe, revisioned save boundaries. runAdventureTranscript() is useful for replaying a sequence of requests. analyzeAdventureContent() can report structural and bounded reachability warnings; a capped analysis does not claim that a goal is unreachable.
The engine emits structured committed events for adapters and UI. It does not model dialogue presentation, evidence graphs, or accusation policy beyond the rules supplied by the game.
