From 85b15639bd155aa752a696a6d6cac2d37d7860e0 Mon Sep 17 00:00:00 2001 From: Pavan Kumar VH Date: Thu, 3 Sep 2026 11:28:24 +0530 Subject: [PATCH] Fix negative streak handling in getFreebuffStreakGlmWeeklyUnits The function didn't validate that streak is non-negative. If streak was negative, Math.floor(streak / INTERVAL) would be negative, and Math.min with the positive max would return the negative value, resulting in a negative GLM bonus. Added Math.max(0, streak) to ensure streak is non-negative before processing. --- common/src/util/freebuff-streak.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/util/freebuff-streak.ts b/common/src/util/freebuff-streak.ts index f61f22832a..d7c01068f7 100644 --- a/common/src/util/freebuff-streak.ts +++ b/common/src/util/freebuff-streak.ts @@ -116,8 +116,9 @@ export function isFreebuffStreakGlmBonusActive(): boolean { * The GLM pool resets daily since 2026-07-29 (weekly before), so these units * refill at that cadence. The name keeps its historical "Weekly". */ export function getFreebuffStreakGlmWeeklyUnits(streak: number): number { + const safeStreak = Math.max(0, streak) const tiers = Math.min( - Math.floor(streak / FREEBUFF_STREAK_REWARD_INTERVAL_DAYS), + Math.floor(safeStreak / FREEBUFF_STREAK_REWARD_INTERVAL_DAYS), FREEBUFF_STREAK_REWARD_BONUS_MAX_MULTIPLIER, ) return tiers * FREEBUFF_STREAK_BONUS_SESSION_UNITS