feat: add difficulty field to prompts and wire into fight pacing

Round 1-2 picks easy prompts, 3-4 medium, 5+ hard (when tagged).
Graceful fallback to any prompt when no difficulty-tagged prompts exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-09 08:05:21 +00:00
co-authored by Claude Opus 4.6
parent 8d0eb4b5f9
commit a4b4963c32
4 changed files with 62 additions and 8 deletions
+40 -1
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { pickChallenge, pickRankedChallenge, getAllChallengeTypes, getAnswerPool } from './challenges.js'
import { pickChallenge, pickRankedChallenge, getAllChallengeTypes, getAnswerPool, roundToDifficulty } from './challenges.js'
describe('pickChallenge', () => {
it('returns a valid challenge', () => {
@@ -172,6 +172,45 @@ describe('getAnswerPool', () => {
})
})
describe('roundToDifficulty', () => {
it('rounds 1-2 are easy', () => {
expect(roundToDifficulty(1)).toBe('easy')
expect(roundToDifficulty(2)).toBe('easy')
})
it('rounds 3-4 are medium', () => {
expect(roundToDifficulty(3)).toBe('medium')
expect(roundToDifficulty(4)).toBe('medium')
})
it('rounds 5+ are hard', () => {
expect(roundToDifficulty(5)).toBe('hard')
expect(roundToDifficulty(6)).toBe('hard')
expect(roundToDifficulty(10)).toBe('hard')
})
})
describe('pickChallenge with roundNumber', () => {
it('accepts roundNumber parameter without error', () => {
const c = pickChallenge(new Set(), null, undefined, 1)
expect(c).toBeTruthy()
expect(c.prompt).toBeTruthy()
})
it('works for all round numbers 1-10', () => {
for (let r = 1; r <= 10; r++) {
const c = pickChallenge(new Set(), null, undefined, r)
expect(c.type).toBeTruthy()
expect(c.prompt).toBeTruthy()
}
})
it('still works without roundNumber (backward compatible)', () => {
const c = pickChallenge(new Set(), null)
expect(c).toBeTruthy()
})
})
describe('prompt data integrity', () => {
it('all 800 prompts are accessible via pickChallenge', () => {
// Run enough picks to verify the system works