feat(engine): wire verb-target-prep — explicit \light X with Y\ and \use\ routing
light X with Y validates the named instrument and reuses handleLight. use X / use X on Y route through the encounter dispatcher; if no encounter consumes it, the dispatcher narrates the fallback. The encounter matcher also rejects transitions whose required item doesn't match the typed instrument, so a mistyped instrument fails cleanly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,23 @@ export function dispatch(state: GameState, command: ParsedCommand, world: World)
|
||||
if (command.verb === 'read') return handleRead(stateWithNoun, command.target.canonical, world)
|
||||
if (command.verb === 'light') return handleLight(stateWithNoun, command.target.canonical, null, world)
|
||||
if (command.verb === 'extinguish') return handleExtinguish(stateWithNoun, command.target.canonical, world)
|
||||
if (command.verb === 'use') return narrate(stateWithNoun, [{ kind: 'narration', text: "You can't think how to use that here." }])
|
||||
return narrate(stateWithNoun, [{ kind: 'narration', text: `You're not sure how to ${command.verb} that.` }])
|
||||
}
|
||||
|
||||
if (command.kind === 'verb-target-prep') {
|
||||
const stateWithNoun: GameState = { ...state, lastNoun: command.target }
|
||||
// Try the encounter first — it may consume verbs like 'cut vines with shears'.
|
||||
const encResult = applyVerbToEncounter(stateWithNoun, command, world)
|
||||
if (encResult?.consumed) {
|
||||
return { state: encResult.state, appended: encResult.lines }
|
||||
}
|
||||
if (command.verb === 'light' && command.preposition === 'with') {
|
||||
return handleLight(stateWithNoun, command.target.canonical, command.indirect.canonical, world)
|
||||
}
|
||||
if (command.verb === 'use') {
|
||||
return narrate(stateWithNoun, [{ kind: 'narration', text: "You can't think how to use that here." }])
|
||||
}
|
||||
return narrate(stateWithNoun, [{ kind: 'narration', text: `You're not sure how to ${command.verb} that.` }])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user