fix: return fightId from ranked queue on duplicate join, fix calculateTier call
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e31d49898b
commit
f9e5c1c329
@@ -536,7 +536,7 @@ describe('fight lifecycle', () => {
|
|||||||
|
|
||||||
// Elo + tier calculation
|
// Elo + tier calculation
|
||||||
calculateElo(eloA, eloB)
|
calculateElo(eloA, eloB)
|
||||||
calculateTier(eloA, f % 50, f % 20)
|
calculateTier(eloA, f % 50)
|
||||||
}
|
}
|
||||||
|
|
||||||
const elapsed = performance.now() - start
|
const elapsed = performance.now() - start
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { logger } from '../lib/logger.js'
|
import { logger } from '../lib/logger.js'
|
||||||
import { db, schema } from '../db/index.js'
|
import { db, schema } from '../db/index.js'
|
||||||
import { eq, sql } from 'drizzle-orm'
|
import { eq, sql } from 'drizzle-orm'
|
||||||
import { runFightAsync, isInFight } from './orchestrator.js'
|
import { runFightAsync, isInFight, getActiveFightId } from './orchestrator.js'
|
||||||
import { checkPaymentStatus, refundEntry, consumePaymentForQueue, linkPaymentsToFight, releasePayment } from './payments.js'
|
import { checkPaymentStatus, refundEntry, consumePaymentForQueue, linkPaymentsToFight, releasePayment } from './payments.js'
|
||||||
|
|
||||||
interface RankedQueueEntry {
|
interface RankedQueueEntry {
|
||||||
@@ -61,10 +61,12 @@ export async function joinRankedQueue(botId: string, paymentId: string): Promise
|
|||||||
throw new Error(`Cooldown active. Wait ${waitSec}s.`)
|
throw new Error(`Cooldown active. Wait ${waitSec}s.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if already in a fight
|
// Check if already in a fight — return fightId so frontend can redirect
|
||||||
if (isInFight(botId)) {
|
if (isInFight(botId)) {
|
||||||
releasePayment(paymentId)
|
releasePayment(paymentId)
|
||||||
throw new Error('Bot is already in a fight.')
|
const err = new Error('Bot is already in a fight.')
|
||||||
|
;(err as any).fightId = getActiveFightId(botId)
|
||||||
|
throw err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load bot
|
// Load bot
|
||||||
|
|||||||
Reference in New Issue
Block a user