Skip to content

Show bonus amount on currency packs#3907

Merged
evanpelle merged 1 commit into
v31from
discount
May 12, 2026
Merged

Show bonus amount on currency packs#3907
evanpelle merged 1 commit into
v31from
discount

Conversation

@evanpelle
Copy link
Copy Markdown
Collaborator

@evanpelle evanpelle commented May 12, 2026

Description:

Show bonus amount on currency packs

  • Add bonusAmount field to PackSchema (non-negative int)
  • Render a rotated green corner ribbon (+X FREE!) on pack tiles when bonusAmount > 0
  • Add cosmetics.free translation key with numFree param
Screenshot 2026-05-12 at 7 40 12 AM

Describe the PR.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

evan

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Review Change Stack

Walkthrough

Pack entries now include a non-negative bonusAmount. The pack preview container is positioned relative and conditionally shows an overlay badge when bonusAmount > 0, using the new cosmetics.free translation string.

Changes

Cosmetic pack bonus display

Layer / File(s) Summary
Pack schema contract
src/core/CosmeticSchemas.ts
PackSchema adds bonusAmount validated as a non-negative integer.
Bonus badge rendering
src/client/components/CosmeticButton.ts
Pack preview container gains relative positioning; an absolutely-positioned badge conditionally renders when pack.bonusAmount > 0, using translateText("cosmetics.free", { numFree: ... }).
Free bonus localization
resources/lang/en.json
Translation key cosmetics.free added with value "+{numFree} BONUS!".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A tiny badge upon the pack,
Schema counts the bonus stack,
Relative frame holds its light,
Translated text shows BONUS bright,
Small change, cheerful in sight. 🎁

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Show bonus amount on currency packs' directly and clearly describes the main change—displaying bonus amounts on currency pack tiles.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly details the changes: adding bonusAmount field to PackSchema, rendering a bonus badge on pack tiles, and adding translation keys.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/core/CosmeticSchemas.ts (1)

82-87: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add tests for the PackSchema changes.

This change modifies a core schema but includes no tests. Per coding guidelines: "All changes to src/core/ must include tests."

Add validation tests covering:

  • Pack with bonusAmount: 0 (valid)
  • Pack with bonusAmount: 100 (valid)
  • Pack with bonusAmount: -1 (should fail — negative)
  • Pack with bonusAmount: 1.5 (should fail — not an integer)
  • Pack without bonusAmount (should fail — required field)

Follow the pattern used in existing schema tests like tests/client/clan/ClanApiSchemas.test.ts, using .safeParse() and checking result.success.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/core/CosmeticSchemas.ts` around lines 82 - 87, Add unit tests for
PackSchema in the test suite mirroring existing schema tests (e.g.,
tests/client/clan/ClanApiSchemas.test.ts): import PackSchema from
CosmeticSchemas and use PackSchema.safeParse() to assert success for
bonusAmount: 0 and bonusAmount: 100, and assert failure for bonusAmount: -1
(negative), bonusAmount: 1.5 (non-integer), and when bonusAmount is omitted
(required). Name the new test file under the same tests directory, use clear
test cases for each scenario, and assert result.success accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/CosmeticSchemas.ts`:
- Line 86: The schema currently defines bonusAmount as a required field
(bonusAmount: z.number().int().nonnegative()) which contradicts the PR and
breaks validation for existing packs without it; change the Zod schema for
bonusAmount in CosmeticSchemas.ts to be optional or provide a default
(recommended) so existing data passes validation—either make bonusAmount
optional (e.g., bonusAmount: z.number().int().nonnegative().optional()) or
supply a default value via z.default(...) so callers/UI don’t need extra null
checks.

---

Outside diff comments:
In `@src/core/CosmeticSchemas.ts`:
- Around line 82-87: Add unit tests for PackSchema in the test suite mirroring
existing schema tests (e.g., tests/client/clan/ClanApiSchemas.test.ts): import
PackSchema from CosmeticSchemas and use PackSchema.safeParse() to assert success
for bonusAmount: 0 and bonusAmount: 100, and assert failure for bonusAmount: -1
(negative), bonusAmount: 1.5 (non-integer), and when bonusAmount is omitted
(required). Name the new test file under the same tests directory, use clear
test cases for each scenario, and assert result.success accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 01d995ca-d340-40d9-b7bb-bb06848515a5

📥 Commits

Reviewing files that changed from the base of the PR and between a597262 and d83289d.

📒 Files selected for processing (3)
  • resources/lang/en.json
  • src/client/components/CosmeticButton.ts
  • src/core/CosmeticSchemas.ts

Comment thread src/core/CosmeticSchemas.ts
@evanpelle evanpelle changed the title bonus Show bonus amount on currency packs May 12, 2026
@evanpelle evanpelle changed the base branch from main to v31 May 12, 2026 14:43
@evanpelle evanpelle marked this pull request as ready for review May 12, 2026 14:43
@evanpelle evanpelle requested a review from a team as a code owner May 12, 2026 14:44
@evanpelle evanpelle added this to the v31 milestone May 12, 2026
@evanpelle evanpelle merged commit ead2601 into v31 May 12, 2026
16 of 28 checks passed
@evanpelle evanpelle deleted the discount branch May 12, 2026 14:44
@github-project-automation github-project-automation Bot moved this from Development to Complete in OpenFront Release Management May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

1 participant