Important Fixes, New mechanics, and many more
Some checks failed
CI / validate (push) Failing after 9m21s

This commit is contained in:
2026-08-15 17:37:57 +05:00
parent 1774496cf9
commit 438e5af0ad
56 changed files with 5090 additions and 119 deletions

View File

@@ -20,6 +20,7 @@ describe('game engine', () => {
expect(roll.rolls).toEqual([12])
expect(roll.total).toBe(17)
expect(roll.success).toBe(true)
expect(roll.id).toMatch(/^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i)
})
it('labels disadvantage rolls correctly', () => {

View File

@@ -1,6 +1,5 @@
import { randomInt } from 'node:crypto'
import { randomInt, randomUUID } from 'node:crypto'
import type { AbilityKey, Character, CheckRequest, DiceRoll, ProposedEvent } from '@dng/shared'
import { makeId } from '@dng/shared'
export interface RandomSource {
integer(min: number, max: number): number
@@ -62,7 +61,9 @@ export function resolveCheck(request: CheckRequest, actor: Character, random: Ra
if (request.kind === 'damage' || request.kind === 'healing') {
const rolled = rollDice(request.dice ?? '1d6', random)
return {
id: makeId('roll'),
// dice_rolls.id is a native PostgreSQL uuid. Keep persistence IDs free
// of the human-readable prefixes used for logs and worker identities.
id: randomUUID(),
checkKind: request.kind,
formula: request.dice ?? '1d6',
rolls: rolled.rolls,
@@ -85,7 +86,7 @@ export function resolveCheck(request: CheckRequest, actor: Character, random: Ra
const total = keptValue + modifier
const difficulty = request.difficulty ?? null
return {
id: makeId('roll'),
id: randomUUID(),
checkKind: request.kind,
formula: request.mode === 'normal'
? `1d20${modifier >= 0 ? '+' : ''}${modifier}`