25 lines
1.7 KiB
TypeScript
25 lines
1.7 KiB
TypeScript
import { resolveCheck } from '@dng/game-engine'
|
|
import { CharacterSchema, moderate13Plus } from '@dng/shared'
|
|
|
|
export default defineEventHandler(async event => {
|
|
const body = await readBody(event)
|
|
const action = String(body?.action ?? '')
|
|
if (!action.trim()) throw createError({ statusCode: 400, statusMessage: 'An action is required.' })
|
|
if (!moderate13Plus(action).allowed) throw createError({ statusCode: 422, statusMessage: 'The action falls outside the 13+ boundary.' })
|
|
|
|
const actor = CharacterSchema.parse({
|
|
id: 'char_mara', name: 'Mara Vale', concept: 'Salvage pilot', controller: 'human', userId: 'demo',
|
|
abilities: { str: 10, dex: 16, con: 13, int: 12, wis: 14, cha: 11 }, hp: 11, maxHp: 11,
|
|
defense: 14, proficiency: 2, inventory: ['Pulse cutter', 'Vacuum cloak'], statuses: [],
|
|
})
|
|
const check = resolveCheck({ actorId: actor.id, kind: 'ability', ability: 'int', difficulty: 13, mode: 'normal', reason: action }, actor)
|
|
const success = check.success === true
|
|
return {
|
|
roll: `Intelligence check · ${check.formula} = ${check.total}`,
|
|
outcome: `${success ? 'SUCCESS' : 'COMPLICATION'} · DC ${check.difficulty}`,
|
|
narration: success
|
|
? 'The transmission separates into two layers. Beneath your future voice is a maintenance handshake signed by Moth—dated eighty-seven years ago. Rook-7 turns toward the sealed archive as its door unlocks one deliberate centimeter. “That,” the machine says, “was not me.”'
|
|
: 'The signal fractures when you isolate it. For one breath every screen shows a different version of the archive—open, burning, empty. Rook-7 catches one surviving packet before the rest vanish: a map leading below the station, marked in your own handwriting.',
|
|
}
|
|
})
|