feat: v2 — queue matchmaking, procedural audio, sprite archetypes, auth
- Add queue-based matchmaking with Elo-proximity and 10s timeout - Procedural sound engine (SFX, voice announcer, 4-track music) - Sprite system refactored into 6 archetypes (standard, lobster, sheep, cyborg, blob, tank) - 42+ fight choreographies with themed/generic/wild card selection - 4 KO finish styles, super-speed mode, hyperdetail close-ups - Auth routes, JoinBout page, bot profile with stats - 7-tier ranking system (Baby through Legend) - Arena and challenge system expansions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
335c148866
commit
47d20fbe66
@@ -0,0 +1,43 @@
|
||||
import { Hono } from 'hono'
|
||||
import { db, schema } from '../db/index.js'
|
||||
import { eq } from 'drizzle-orm'
|
||||
import { joinQueue, leaveQueue, getQueueSize, getQueueSnapshot } from '../engine/queue.js'
|
||||
|
||||
export const queueRouter = new Hono()
|
||||
|
||||
// Get queue status
|
||||
queueRouter.get('/status', (c) => {
|
||||
return c.json({
|
||||
waiting: getQueueSize(),
|
||||
queue: getQueueSnapshot(),
|
||||
})
|
||||
})
|
||||
|
||||
// Join the queue — blocks until matched, then returns fightId
|
||||
queueRouter.post('/join/:botId', async (c) => {
|
||||
const botId = c.req.param('botId')
|
||||
|
||||
const botRows = await db.select({ id: schema.bots.id, name: schema.bots.name })
|
||||
.from(schema.bots)
|
||||
.where(eq(schema.bots.id, botId))
|
||||
.limit(1)
|
||||
|
||||
if (botRows.length === 0) {
|
||||
return c.json({ error: 'Bot not found.' }, 404)
|
||||
}
|
||||
|
||||
try {
|
||||
const fightId = await joinQueue(botId)
|
||||
return c.json({ fightId, message: 'Matched! Fight starting.' })
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : 'Queue error'
|
||||
return c.json({ error: message }, 500)
|
||||
}
|
||||
})
|
||||
|
||||
// Leave the queue
|
||||
queueRouter.post('/leave/:botId', (c) => {
|
||||
const botId = c.req.param('botId')
|
||||
const left = leaveQueue(botId)
|
||||
return c.json({ left })
|
||||
})
|
||||
Reference in New Issue
Block a user