fix: Drizzle transaction execution, canvas re-init, crowd removal

- Add .run() to all Drizzle queries inside sqlite.transaction() in
  orchestrator.ts and mock.ts — queries were building but never executing,
  leaving fights stuck as 'live' forever
- Remove spectator crowd from drawArenaDecor()
- Rename duplicate spawnProp to spawnWeaponProp (was crashing module load)
- Replace canvas element on re-init to avoid "KAPLAY already initialized"
- Add safeText() to strip brackets from k.text() calls (Kaplay treats
  [ ] as style markup, crashes on unclosed tags)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-07 00:53:15 +00:00
co-authored by Claude Opus 4.6
parent 4d8b18a58a
commit e49735002c
4 changed files with 31 additions and 180 deletions
+9 -3
View File
@@ -90,13 +90,19 @@ onUnmounted(() => {
async function initScene() {
if (!canvasRef.value || !props.fight.botA || !props.fight.botB) return
// Destroy previous scene to avoid "KAPLAY already initialized" warning
// Destroy previous scene fully — replace canvas to avoid "KAPLAY already initialized"
if (scene) { scene.destroy(); scene = null }
const container = canvasRef.value.parentElement
if (container) {
canvasRef.value.width = container.clientWidth
canvasRef.value.height = container.clientHeight
// Replace canvas element so Kaplay gets a fresh context
const oldCanvas = canvasRef.value
const newCanvas = document.createElement('canvas')
newCanvas.className = oldCanvas.className
newCanvas.width = container.clientWidth
newCanvas.height = container.clientHeight
oldCanvas.replaceWith(newCanvas)
canvasRef.value = newCanvas
}
scene = await createFightScene({