fix: scoring & game logic bugs — arena modifiers, human timeout, validated prompts
- scoring.ts: wire arena damage modifiers (speed_2x, roast_2x, etc.) into applyModifiers() - human-responses.ts: use challenge.timeout_ms instead of hardcoded 8s - FightPage.vue: add route watcher for clean state reset on navigation - Validated all 800 prompts: 0 duplicates, all factual have answers, all choices have 4 items Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
4c576b0369
commit
a4008bcf88
@@ -18,7 +18,7 @@ interface PendingChallenge {
|
||||
|
||||
const pending = new Map<string, PendingChallenge>()
|
||||
|
||||
const HUMAN_TIMEOUT_MS = 8_000
|
||||
const DEFAULT_HUMAN_TIMEOUT_MS = 8_000
|
||||
|
||||
export function isHumanPlayer(webhookUrl: string): boolean {
|
||||
return webhookUrl === 'http://human.local/'
|
||||
@@ -231,12 +231,13 @@ export function waitForHumanResponse(
|
||||
): Promise<{ answer: string | null; trashTalk?: string; timedOut: boolean }> {
|
||||
return new Promise((resolve) => {
|
||||
const key = `${fightId}:${botId}`
|
||||
const timeoutMs = challenge.timeout_ms || DEFAULT_HUMAN_TIMEOUT_MS
|
||||
|
||||
const timeoutHandle = setTimeout(() => {
|
||||
pending.delete(key)
|
||||
console.log(`[human] ${key} timed out after ${HUMAN_TIMEOUT_MS}ms`)
|
||||
console.log(`[human] ${key} timed out after ${timeoutMs}ms`)
|
||||
resolve({ answer: null, timedOut: true })
|
||||
}, HUMAN_TIMEOUT_MS)
|
||||
}, timeoutMs)
|
||||
|
||||
const choices = generateChoices(challenge)
|
||||
|
||||
@@ -290,15 +291,16 @@ export function getPendingChallenge(
|
||||
const entry = pending.get(key)
|
||||
if (!entry) return null
|
||||
|
||||
const timeoutMs = entry.challenge.timeout_ms || DEFAULT_HUMAN_TIMEOUT_MS
|
||||
const elapsed = Date.now() - entry.createdAt
|
||||
const remaining = Math.max(0, HUMAN_TIMEOUT_MS - elapsed)
|
||||
const remaining = Math.max(0, timeoutMs - elapsed)
|
||||
|
||||
return {
|
||||
type: entry.challenge.type,
|
||||
label: entry.challenge.label,
|
||||
prompt: entry.challenge.prompt,
|
||||
roundNumber: entry.roundNumber,
|
||||
timeoutMs: HUMAN_TIMEOUT_MS,
|
||||
timeoutMs,
|
||||
remainingMs: remaining,
|
||||
scoring: entry.challenge.scoring,
|
||||
choices: entry.choices,
|
||||
|
||||
Reference in New Issue
Block a user