another fix for human choices

This commit is contained in:
Dorian
2026-03-11 00:13:31 +00:00
parent 112bcde515
commit bbe656929c
7 changed files with 42 additions and 22 deletions
+9 -1
View File
@@ -123,9 +123,15 @@ function handleKeyboard(e: KeyboardEvent) {
}
}
let pollBackoff = 0
function startPolling() {
pollBackoff = 0
pollForChallenge()
pollHandle = setInterval(pollForChallenge, 600)
pollHandle = setInterval(() => {
if (pollBackoff > 0) { pollBackoff--; return }
pollForChallenge()
}, 800)
}
function stopPolling() {
@@ -172,7 +178,9 @@ async function pollForChallenge() {
try {
const res = await fetch(`/api/fights/${fightId.value}/challenge/${myBotId.value}`)
if (res.status === 429) { pollBackoff = Math.min(pollBackoff + 2, 8); return }
if (!res.ok) return
pollBackoff = Math.max(0, pollBackoff - 1)
const data = await res.json()
// Reset error tracking on success