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;
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,
});
}
}