Private
Public Access
1
0

fix: The cooldown bonus is effective team-wide

This commit is contained in:
gauvainboiche
2026-03-31 09:45:35 +02:00
parent 5871427514
commit e38997f154

View File

@@ -31,11 +31,14 @@ router.get("/config", async (req, res) => {
let teamCooldownRemaining = 0; let teamCooldownRemaining = 0;
const team = typeof req.query.team === "string" ? req.query.team : undefined; const team = typeof req.query.team === "string" ? req.query.team : undefined;
if (team === "blue" || team === "red") { 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); const row = await getTeamCooldown(worldSeed, team);
if (row) { if (row) {
const secondsSince = (Date.now() - new Date(row.last_reveal).getTime()) / 1000; const secondsSince = (Date.now() - new Date(row.last_reveal).getTime()) / 1000;
if (secondsSince < cfg.clickCooldownSeconds) { if (secondsSince < effectiveCooldown) {
teamCooldownRemaining = Math.ceil(cfg.clickCooldownSeconds - secondsSince); teamCooldownRemaining = Math.ceil(effectiveCooldown - secondsSince);
} }
} }
} }
@@ -102,15 +105,18 @@ router.post("/cell/reveal", async (req, res) => {
const cfg = getConfig(); const cfg = getConfig();
if (cfg.clickCooldownSeconds > 0) { 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); const cooldownRow = await getTeamCooldown(worldSeed, team);
if (cooldownRow) { if (cooldownRow) {
const secondsSince = (Date.now() - new Date(cooldownRow.last_reveal).getTime()) / 1000; const secondsSince = (Date.now() - new Date(cooldownRow.last_reveal).getTime()) / 1000;
if (secondsSince < cfg.clickCooldownSeconds) { if (secondsSince < effectiveCooldown) {
return res.status(429).json({ return res.status(429).json({
error: "cooldown_active", error: "cooldown_active",
team, team,
remainingSeconds: Math.ceil(cfg.clickCooldownSeconds - secondsSince), remainingSeconds: Math.ceil(effectiveCooldown - secondsSince),
cooldownSeconds: cfg.clickCooldownSeconds, cooldownSeconds: effectiveCooldown,
}); });
} }
} }