New bug fixes
Pull Request
- Don't allow users to sleep in wartorn sector
- When users lose money from wartorn, don't let it put them below 0 money
I had a few other fixes in here, but you took care of them yourself right before I put the completed tag here. I removed those changes, so I wasn't overwriting you.
License
By making this pull request, I confirm that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the Studie-Tech ApS organization has the copyright to use and modify my contribution for perpetuity.
Summary by CodeRabbit
-
Bug Fixes
- Money loss in war-torn combat is now capped to your current balance, preventing balances from dropping below zero.
-
New Features
- Players can no longer sleep while in the war-torn battleground sector.
- The Users page Staff link now opens the in-app staff manual instead of the previous staff route.
✏️ Tip: You can customize this high-level summary in your review settings.
The latest updates on your projects. Learn more about Vercel for GitHub.
Walkthrough
Clamps money deducted from battle losers to their available balance; prevents sleeping in the war-torn battleground; updates Staff link to /manual/staff; adds and propagates originalLevel through combat and quest checks; adjusts daily-quest selection bounds and daily reset behavior.
Changes
| Cohort / File(s) | Summary |
|---|---|
Combat — money clamp app/src/libs/combat/util.ts |
In calcBattleResult, compute currentMoney (default 0), set moneyToLose = Math.min(loserMoneyGain, currentMoney), and assign result.money = -moneyToLose to avoid negative balances. |
Combat — originalLevel propagation & ranked handling app/src/libs/combat/types.ts, app/src/server/api/routers/combat.ts |
Add originalLevel: number to BattleUserState; set/preserve originalLevel in initiateBattle and processUsersForBattle; skip level recalculation for ranked modes so original level is retained during scaling. |
Quest logic — prefer originalLevel & daily completion check app/src/libs/quest.ts |
For "user_level" trackers and availability checks, derive userLevel by preferring numeric originalLevel else user.level or 1; add daily-completed handling so daily quests respect completion/reset state in availability checks. |
Home Router — sleep guard app/src/server/api/routers/home.ts |
Import MAP_WAR_TORN_BATTLEGROUND_SECTOR and reject toggleSleep when newStatus === "ASLEEP" and user.sector === MAP_WAR_TORN_BATTLEGROUND_SECTOR returning error "You cannot sleep in the war-torn battleground". |
Users Page — navigation app/src/app/users/page.tsx |
Update Staff link target from /staff to /manual/staff; no other UI/logic changes. |
Daily quests — reset & selection app/src/app/api/daily-quest/route.ts |
Remove maxLevel local usage; use minLevel as primary bound and keep q.maxLevel >= minLevel; add comment and ensure daily quest histories end/reset (endAt = new Date()). |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
- Verify
calcBattleResulthandles undefined/zero balances and thatresult.moneyserialization matches callers. - Ensure
originalLevelis consistently initialized, persisted, and used (combat flow, serialization, quest checks). - Confirm quest daily-completion logic and level-bound changes behave correctly across edge cases.
- Validate
toggleSleepguard uses the correct constant and returns the expected error shape.
Possibly related PRs
- studie-tech/TheNinjaRPG#426 — Modifies
calcBattleResult; likely overlaps money/result logic. - studie-tech/TheNinjaRPG#618 — Changes to combat leveling/processUsersForBattle; related to
originalLevelhandling. - studie-tech/TheNinjaRPG#766 — Related war-torn battleground and combat/money behavior changes.
Suggested labels
bug
Suggested reviewers
- MathiasGruber
- theeneon
Poem
🐇 I hopped through code with careful paws and cheer,
I kept your coins from tumbling far and near.
No sleepy beds where battlegrounds alight,
I tucked your level safe, then nudged quests right.
Hop on, small fixes — swift, kind, and bright!
Pre-merge checks and finishing touches
❌ Failed checks (1 warning, 2 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
| Title check | ❓ Inconclusive | The title 'New bug fixes' is vague and generic, using non-descriptive terminology that fails to convey meaningful information about the specific changes in the changeset. | Replace with a specific summary of the main change, such as 'Fix war-torn combat money deduction and level-based quest logic' or similar. |
| Description check | ❓ Inconclusive | The PR description lists the key changes but lacks implementation details, reasoning, or examples of the bugs being fixed. | Add more context explaining why these fixes were needed, what specific bugs they address, or provide examples of the problems they solve. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
new-bug-fixes
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
📦 Next.js Bundle Analysis for tnr
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌
📦 Next.js Bundle Analysis for tnr
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌
📦 Next.js Bundle Analysis for tnr
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌
📦 Next.js Bundle Analysis for tnr
This analysis was generated by the Next.js Bundle Analysis action. 🤖
This PR introduced no changes to the JavaScript bundle! 🙌
I made adjustments to account for the quests that allow multiple completions. I adjusted one of the events to have multiple allowed completions and I was able to properly complete it the set number of times.
While making the adjustment, I noticed that I ran into an issue with not getting dailies again on dev. I set up some logging and found that it wasn't properly limiting you to dailies within your level and it was causing missions to not be assigned if you were outside the required levels. I've tested it and confirmed that it now only assigns missions within your level range.
Great work, thanks! :D