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
+19 -6
View File
@@ -1,4 +1,4 @@
import { TEMPLATES, type ChallengeTemplate, type PromptEntry, type PromptTheme } from './challenge-data.js'
import { TEMPLATES, type ChallengeTemplate, type PromptEntry, type PromptTheme, type PromptDifficulty } from './challenge-data.js'
import { EXTRA_PROMPTS } from './challenges-extra.js'
import { pick } from '../lib/utils.js'
@@ -14,7 +14,7 @@ export interface Challenge {
displayPrompt?: string
}
export type { ChallengeTemplate, PromptEntry, PromptTheme }
export type { ChallengeTemplate, PromptEntry, PromptTheme, PromptDifficulty }
// Merge extra prompts into templates
@@ -54,7 +54,14 @@ function pickTheme(): PromptTheme | undefined {
return undefined
}
export function pickChallenge(usedTypes: Set<string>, _arenaModifier: string | null, themeBias?: PromptTheme): Challenge {
/** Map round number to target difficulty: Round 1-2 easy, 3-4 medium, 5+ hard */
export function roundToDifficulty(round: number): PromptDifficulty {
if (round <= 2) return 'easy'
if (round <= 4) return 'medium'
return 'hard'
}
export function pickChallenge(usedTypes: Set<string>, _arenaModifier: string | null, themeBias?: PromptTheme, roundNumber?: number): Challenge {
let available = TEMPLATES.filter(t => !usedTypes.has(t.type))
if (available.length === 0) available = TEMPLATES
@@ -71,7 +78,8 @@ export function pickChallenge(usedTypes: Set<string>, _arenaModifier: string | n
const template = pick(pool)
const targetTheme = themeBias || pickTheme()
return templateToChallenge(template, targetTheme)
const targetDifficulty = roundNumber ? roundToDifficulty(roundNumber) : undefined
return templateToChallenge(template, targetTheme, targetDifficulty)
}
/** Ranked challenge: no multiple choice, only harder creative/open-ended prompts */
@@ -102,13 +110,18 @@ export function pickRankedChallenge(usedTypes: Set<string>): Challenge {
}
}
function templateToChallenge(template: ChallengeTemplate, targetTheme?: PromptTheme): Challenge {
function templateToChallenge(template: ChallengeTemplate, targetTheme?: PromptTheme, targetDifficulty?: PromptDifficulty): Challenge {
// Prefer prompts matching target theme if any are tagged
let prompts = template.prompts
if (targetTheme) {
const themed = template.prompts.filter(p => p.theme === targetTheme)
const themed = prompts.filter(p => p.theme === targetTheme)
if (themed.length > 0) prompts = themed
}
// Prefer prompts matching target difficulty if any are tagged
if (targetDifficulty) {
const byDifficulty = prompts.filter(p => p.difficulty === targetDifficulty)
if (byDifficulty.length > 0) prompts = byDifficulty
}
const entry = pick(prompts)
// Determine choices