TheNinjaRPG icon indicating copy to clipboard operation
TheNinjaRPG copied to clipboard

Repair rework

Open Phrosfire opened this issue 1 month ago • 6 comments

Pull Request

  • Allow only crafters to repair gear using money
  • Add repair all button on occupation screen for crafters
  • Add repair tag that can be placed on an item to be used as a repair kit (Durability repaired = power)
  • Adjusted repair display on items screen. Allow users to select a specific repair kit when repairing an item.
  • Added a repair all button on the items page to repair everything. Displays what kits and how many are being used for the repair.

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

  • New Features

    • Bulk "Repair All" with automatic kit selection and kits-used summary.
    • Per-item Repair modal to choose specific repair kits.
  • Changes

    • Repair actions unified into modal-driven flow across Backpack, Character, Item Details, and Crafting screens.
    • Repair operations now require the Crafting occupation.
  • UI

    • Shows total durability needed, kit breakdown, per-item costs, affordability checks, confirmations, and contextual edit-screen field filtering for "repair" tags.

✏️ Tip: You can customize this high-level summary in your review settings.

Phrosfire avatar Nov 26 '25 01:11 Phrosfire

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
tnr Ignored Ignored Preview Nov 26, 2025 5:02am

vercel[bot] avatar Nov 26 '25 01:11 vercel[bot]

[!WARNING]

Rate limit exceeded

@Phrosfire has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5bcaa9e747870e11e9920017b971924beb599815 and 2fb3a703b7da9b224891fe00bb87d0c074e77f3c.

📒 Files selected for processing (7)
  • app/src/app/items/page.tsx (12 hunks)
  • app/src/layout/EditContent.tsx (1 hunks)
  • app/src/layout/OccupationCrafting.tsx (4 hunks)
  • app/src/libs/combat/types.ts (2 hunks)
  • app/src/libs/item.ts (1 hunks)
  • app/src/libs/repair.ts (1 hunks)
  • app/src/server/api/routers/item.ts (2 hunks)

Walkthrough

Adds single-item and bulk repair flows: new server mutations (repairAll, useRepairItem, useRepairAll), client modal-driven repair UI, repair kit utilities, a Repair tag, non-combat repair consumable handling, and a small form filter for repair-type tags.

Changes

Cohort / File(s) Summary
Server API & Mutations
app/src/server/api/routers/item.ts
Added repairAll, useRepairItem, useRepairAll mutations; tightened repair access to user.occupation === "CRAFTING"; implemented atomic fund checks, durability updates, kit selection/consumption, and kitsUsed reporting.
Client Items UI & Hooks
app/src/app/items/page.tsx
Added RepairItemSelectionModal, RepairModalWrapper, types (RepairItemModalProps, SetIsOpenType), computed kit/repairAll info, and wired useRepairAll/useRepairItem mutations to modal-driven repair flows.
Crafting Interface
app/src/layout/OccupationCrafting.tsx
Inserted "Repair Items" UI block with per-item Repair buttons, "Repair All" section, and Confirm dialog; wired to repair/repairAll mutations and success handlers.
Repair Utilities
app/src/libs/repair.ts
New utilities: RepairKit, RepairKitCalculationResult, getRepairKits, calculateKitsToUse to compute kits-to-use, total durability needed, and canRepairAll using ascending-power allocation.
Item Handling Logic
app/src/libs/item.ts
Treated items with effect.type === "repair" as non-combat consumables in nonCombatConsume.
Combat Types / Tags
app/src/libs/combat/types.ts
Added RepairTag Zod schema and exported RepairTagType; included RepairTag in AllTags defaults.
Form Field Filtering
app/src/layout/EditContent.tsx
Filtered out animation/asset and other fields when a tag's type is "repair".
Manifest / Package
manifest_file, package.json
Updated manifest/package entries (metadata and/or deps) included in the diff.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Client UI
    participant Modal as RepairItemSelectionModal
    participant API as itemRouter
    participant DB as Database

    rect rgba(60,179,113,0.08)
    Note right of UI: Single-item repair (modal-driven)
    User->>UI: Click "Repair" on item
    UI->>Modal: open with available repair kits
    User->>Modal: select repair kit
    Modal->>API: useRepairItem(repairItemId, targetItemId)
    API->>DB: validate ownership/effect, consume kit, apply durability
    DB-->>API: repair result
    API-->>UI: response (durability repaired) + invalidate caches
    UI-->>User: show repair result
    end

    rect rgba(65,105,225,0.06)
    Note right of UI: Bulk repair (kit allocation)
    User->>UI: Click "Repair All"
    UI->>API: useRepairAll()
    API->>DB: aggregate items needing repair & available kits
    API->>DB: choose kits (ascending power), consume kits, repair items
    DB-->>API: kitsUsed summary
    API-->>UI: return kitsUsed & invalidate caches
    UI-->>User: show bulk repair summary
    end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • app/src/server/api/routers/item.ts: atomic money updates, kit consumption logic, occupation guard, and returned kitsUsed shape.
    • app/src/libs/repair.ts: allocation algorithm, edge-case handling for stacks and partial fills.
    • Client wiring in app/src/app/items/page.tsx and app/src/layout/OccupationCrafting.tsx: modal state, mutation use, and cache invalidation.

Possibly related PRs

  • studie-tech/TheNinjaRPG#653 — touches item repair/durability logic and item router; likely related to foundational repair calculations and prior repair implementations.

Suggested labels

Completed

Suggested reviewers

  • MathiasGruber
  • theeneon

Poem

🐰 I hop through kits both small and tall,
I count the power and mend what's all.
Open the modal, choose with care,
Stacks shrink down, gear gleams fair.
Repaired by rabbit — light as air! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 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 'Repair rework' is vague and generic, using non-descriptive language that doesn't convey the specific scope or main focus of the substantial changes implemented. Use a more descriptive title that captures the primary change, such as 'Add repair kit system and restrict repairs to crafters' or 'Implement repair tag system with occupation-based access control.'
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description covers all major features implemented (crafting-only repairs, repair tags, repair-all buttons, kit selection UI) and follows the template structure with required license statement, though implementation details are brief.

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.

coderabbitai[bot] avatar Nov 26 '25 01:11 coderabbitai[bot]

📦 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! 🙌

github-actions[bot] avatar Nov 26 '25 01:11 github-actions[bot]

📦 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! 🙌

github-actions[bot] avatar Nov 26 '25 01:11 github-actions[bot]

📦 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! 🙌

github-actions[bot] avatar Nov 26 '25 04:11 github-actions[bot]

The more I look at this, the more I think I made the new repair logic more complicated than I need to. If you think I need to make things less complicated, please let me know and I'll make adjustments.

Phrosfire avatar Nov 27 '25 04:11 Phrosfire