Skip to content

Fix negative streak handling in getFreebuffStreakGlmWeeklyUnits - #1233

Open
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/streak-glm-negative-validation
Open

Fix negative streak handling in getFreebuffStreakGlmWeeklyUnits#1233
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/streak-glm-negative-validation

Conversation

@pavankumar-vh

Copy link
Copy Markdown

Overview

Fix negative streak handling in the getFreebuffStreakGlmWeeklyUnits function in common/src/util/freebuff-streak.ts.

Bug Description

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.

Fix

Added Math.max(0, streak) to ensure streak is non-negative before processing.

Testing

All existing tests pass (14/14).

Files Changed

  • common/src/util/freebuff-streak.ts - Added negative streak validation

Scope

This change only touches common/ which is an approved contribution area per the Contributing Guide.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant