diff --git a/server/routes/game.js b/server/routes/game.js index ced709a..3db681a 100644 --- a/server/routes/game.js +++ b/server/routes/game.js @@ -31,11 +31,14 @@ router.get("/config", async (req, res) => { let teamCooldownRemaining = 0; const team = typeof req.query.team === "string" ? req.query.team : undefined; if (team === "blue" || team === "red") { + const bonus = await getElementBonus(worldSeed); + const teamBonus = bonus[team] ?? 0; + const effectiveCooldown = cfg.clickCooldownSeconds / (1 + teamBonus / 100); const row = await getTeamCooldown(worldSeed, team); if (row) { const secondsSince = (Date.now() - new Date(row.last_reveal).getTime()) / 1000; - if (secondsSince < cfg.clickCooldownSeconds) { - teamCooldownRemaining = Math.ceil(cfg.clickCooldownSeconds - secondsSince); + if (secondsSince < effectiveCooldown) { + teamCooldownRemaining = Math.ceil(effectiveCooldown - secondsSince); } } } @@ -102,15 +105,18 @@ router.post("/cell/reveal", async (req, res) => { const cfg = getConfig(); if (cfg.clickCooldownSeconds > 0) { + const bonus = await getElementBonus(worldSeed); + const teamBonus = bonus[team] ?? 0; + const effectiveCooldown = cfg.clickCooldownSeconds / (1 + teamBonus / 100); const cooldownRow = await getTeamCooldown(worldSeed, team); if (cooldownRow) { const secondsSince = (Date.now() - new Date(cooldownRow.last_reveal).getTime()) / 1000; - if (secondsSince < cfg.clickCooldownSeconds) { + if (secondsSince < effectiveCooldown) { return res.status(429).json({ error: "cooldown_active", team, - remainingSeconds: Math.ceil(cfg.clickCooldownSeconds - secondsSince), - cooldownSeconds: cfg.clickCooldownSeconds, + remainingSeconds: Math.ceil(effectiveCooldown - secondsSince), + cooldownSeconds: effectiveCooldown, }); } }