characters invisible on human vs bot fight entrance fix

This commit is contained in:
Dorian
2026-03-11 09:17:20 +00:00
parent bcbcd17fce
commit 974566778e
3 changed files with 39 additions and 7 deletions
+6
View File
@@ -49,6 +49,7 @@ const {
roundCooldown, pendingChallengeData,
applyChallenge, submitChoice, startHumanPolling, stopHumanPolling,
startCooldown, clearChallenge, resetState: resetChallengeState, handleSSEChallenge,
setEntrancePlaying,
} = challenge
// Live scene state
@@ -155,6 +156,10 @@ async function initLiveScene() {
await ensureAudioContext()
liveScene.startMusic()
}
// Let Kaplay register game objects before entrance (prevents invisible fighters)
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)))
// Block challenges during entrance so the animation plays fully
setEntrancePlaying(true)
announceDeepIntro()
try {
await liveScene.playEntrance()
@@ -163,6 +168,7 @@ async function initLiveScene() {
}
// Safety: ensure fighters are visible after entrance (prevents invisible characters on mobile)
liveScene._resetPositions()
setEntrancePlaying(false)
}
liveLogItems.value.push(
+7 -1
View File
@@ -30,6 +30,10 @@ const trashTalk = ref('')
const remainingSeconds = ref(45)
const showTrashTalk = ref(false)
// Buffer to ensure client timer finishes BEFORE server timer
// (accounts for polling delivery delay + network latency)
const CLIENT_TIMER_BUFFER_MS = 1500
// Feedback state
const feedback = ref<'correct' | 'wrong' | null>(null)
const feedbackTimer = ref<ReturnType<typeof setTimeout> | null>(null)
@@ -197,7 +201,9 @@ async function pollForChallenge() {
feedback.value = null
phase.value = 'challenge'
// Cap timer for multiple choice — just tapping a button, not typing
const timerMs = (data.choices?.length > 0) ? Math.min(data.remainingMs, 10000) : data.remainingMs
// Subtract buffer so client always submits before server times out
const rawMs = (data.choices?.length > 0) ? Math.min(data.remainingMs, 10000) : data.remainingMs
const timerMs = Math.max(1000, rawMs - CLIENT_TIMER_BUFFER_MS)
startTimer(timerMs)
await nextTick()
if (!hasChoices.value) answerInput.value?.focus()