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:
co-authored by
Claude Opus 4.6
parent
4d8b18a58a
commit
e49735002c
@@ -380,7 +380,7 @@ export async function runMockFight(botAId: string, botBId: string): Promise<stri
|
||||
botAHp: hpA,
|
||||
botBHp: hpB,
|
||||
totalRounds: round,
|
||||
}).where(eq(schema.fights.id, fightId))
|
||||
}).where(eq(schema.fights.id, fightId)).run()
|
||||
|
||||
if (hpA <= 0 || hpB <= 0) {
|
||||
winnerId = hpA <= 0 ? botB.id : botA.id
|
||||
@@ -398,7 +398,7 @@ export async function runMockFight(botAId: string, botBId: string): Promise<stri
|
||||
status: 'finished',
|
||||
winnerId,
|
||||
endedAt: new Date().toISOString(),
|
||||
}).where(eq(schema.fights.id, fightId))
|
||||
}).where(eq(schema.fights.id, fightId)).run()
|
||||
|
||||
if (winnerId) {
|
||||
const loserId = winnerId === botA.id ? botB.id : botA.id
|
||||
@@ -415,7 +415,7 @@ export async function runMockFight(botAId: string, botBId: string): Promise<stri
|
||||
bestStreak: sql`MAX(${schema.bots.bestStreak}, ${newWinStreak})`,
|
||||
tier: calculateTier(newWinnerElo, winner.wins + 1),
|
||||
lastFightAt: new Date().toISOString(),
|
||||
}).where(eq(schema.bots.id, winnerId))
|
||||
}).where(eq(schema.bots.id, winnerId)).run()
|
||||
|
||||
db.update(schema.bots).set({
|
||||
losses: sql`${schema.bots.losses} + 1`,
|
||||
@@ -423,7 +423,7 @@ export async function runMockFight(botAId: string, botBId: string): Promise<stri
|
||||
winStreak: 0,
|
||||
tier: calculateTier(newLoserElo, loser.wins),
|
||||
lastFightAt: new Date().toISOString(),
|
||||
}).where(eq(schema.bots.id, loserId))
|
||||
}).where(eq(schema.bots.id, loserId)).run()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user