Skip to content

Flash Talisman: ANY_KAMI shape for self-use#2353

Open
kanyaveral wants to merge 3 commits intomainfrom
urco.flash-talisman
Open

Flash Talisman: ANY_KAMI shape for self-use#2353
kanyaveral wants to merge 3 commits intomainfrom
urco.flash-talisman

Conversation

@kanyaveral
Copy link
Contributor

@kanyaveral kanyaveral commented Feb 10, 2026

Summary

Adds ANY_KAMI for-shape so Flash Talisman can be used on your own Kami (self-buff) in addition to enemy casting. Currently players work around this by casting from an alt account.

  • LibItem.sol: New verifyForShapeOr() helper that accepts two valid shapes
  • KamiCastItemSystem: Accepts ENEMY_KAMI or ANY_KAMI
  • KamiUseItemSystem: Accepts KAMI or ANY_KAMI
  • CastItemButton / UseItemButton: Include ANY_KAMI items in inventory filters

Deployment requirements

Before or alongside merging:

  1. Notion CSV: Update Flash Talisman (11412) — Enemy_KamiAny_Kami, add BYPASS_BONUS_RESET flag
  2. Contract push: Run reviseItems for index 11412 to update ForComponent + flags on-chain

Summary by CodeRabbit

Release Notes

  • New Features

    • Items can now be used on additional Kami types, expanding usage flexibility.
    • Added authorization checks when casting items on other players' Kami.
  • Bug Fixes

    • Improved item selection logic to properly aggregate compatible Kami types for casting and usage.

Introduce ANY_KAMI for-shape so Flash Talisman (11412) works through
both KamiUseItemSystem (self-buff) and KamiCastItemSystem (enemy cast).

- items.csv: Enemy_Kami → Any_Kami, add BYPASS_BONUS_RESET flag
- LibItem.sol: add verifyForShapeOr() helper
- KamiCastItemSystem: accept ENEMY_KAMI or ANY_KAMI
- KamiUseItemSystem: accept KAMI or ANY_KAMI
- CastItemButton/UseItemButton: include ANY_KAMI in inventory filters
@vercel
Copy link

vercel bot commented Feb 10, 2026

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

Project Deployment Actions Updated (UTC)
kamigotchi-client Ready Ready Preview, Comment Mar 3, 2026 9:06pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Walkthrough

The changes extend the item casting and usage system to support both ENEMY_KAMI and ANY_KAMI item shapes. Client-side buttons now aggregate and reorder items by type, while contract systems introduce dual-shape verification and enforce authorization-based state checks for item casting.

Changes

Cohort / File(s) Summary
Client Item Buttons
packages/client/src/app/components/library/buttons/actions/CastItemButton.tsx, packages/client/src/app/components/library/buttons/actions/UseItemButton.tsx
Modified getOptions to filter and aggregate both ENEMY_KAMI and ANY_KAMI items, ordering them (enemy items first, then any items) before applying subsequent filtering.
Contract Shape Verification
packages/contracts/src/libraries/LibItem.sol
Added new public view function verifyForShapeOr to verify item for-shape against two accepted shape options, extending single-shape verification without modifying existing verifyForShape behavior.
Kami Item Systems
packages/contracts/src/systems/KamiCastItemSystem.sol, packages/contracts/src/systems/KamiUseItemSystem.sol
Updated item shape verification to use verifyForShapeOr accepting either standard or ANY_KAMI shapes; added authorization check in KamiCastItemSystem to enforce HARVESTING state when caster lacks target account authorization.

Sequence Diagram(s)

sequenceDiagram
    participant Button as CastItemButton/<br/>UseItemButton
    participant System as KamiCastItemSystem/<br/>KamiUseItemSystem
    participant LibItem as LibItem Library
    
    Button->>Button: Filter & aggregate<br/>ENEMY_KAMI + ANY_KAMI items
    Button->>System: Call with item selection
    
    alt Unauthorized Caster (KamiCastItemSystem)
        System->>System: Check authorization
        System->>System: Enforce HARVESTING state
    end
    
    System->>LibItem: verifyForShapeOr(...<br/>"ENEMY_KAMI"/"ANY_KAMI")
    LibItem->>LibItem: Retrieve item shape<br/>via LibFor.get
    LibItem->>LibItem: Compare shape<br/>against both options
    LibItem-->>System: Shape verified ✓
    System->>System: Continue with remaining<br/>validations & execution
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • KamiUseEnemyItemSystem #2038: Modifies Kami cast/use flow for enemy/any-kami items by adding KamiCastItemSystem and adjusting shape checks to accept ENEMY_KAMI or ANY_KAMI.
  • emit cast events #2065: Modifies KamiCastItemSystem.sol to add event emission; shares system-level changes with this PR.
  • cast item button #2062: Updates CastItemButton and UseItemButton client logic to include ENEMY_KAMI and ANY_KAMI items, directly paralleling this PR's button component changes.

Suggested reviewers

  • chlwys
  • JirAcheron
  • deeterbleater

Poem

🐰 A cast to the many, a use for them all,
ENEMY_KAMI and ANY answer the call,
Shape verification true with two paths to take,
Authorization guards what we choose to awake!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Flash Talisman: ANY_KAMI shape for self-use' clearly and concisely summarizes the main change: enabling the Flash Talisman item to be used on the player's own Kami via a new ANY_KAMI shape, addressing the self-buff use case mentioned throughout the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch urco.flash-talisman

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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
Contributor

@ExistentialEnso ExistentialEnso left a comment

Choose a reason for hiding this comment

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

lgtm! pretty straightforward but an incredibly useful feature.

@kanyaveral kanyaveral changed the base branch from beta to main February 11, 2026 18:29
@kanyaveral kanyaveral dismissed ExistentialEnso’s stale review February 11, 2026 18:29

The base branch was changed.

Xenofluxx
Xenofluxx previously approved these changes Feb 13, 2026
- enemy kamis must be in HARVESTING state to be targeted by cast items
- own kamis (via ANY_KAMI items) can still be targeted while RESTING or HARVESTING
- prevents spirit glue and similar items from being used on resting enemy kamis
Copy link
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

🧹 Nitpick comments (1)
packages/contracts/src/libraries/LibItem.sol (1)

298-304: Improve dual-shape revert message clarity.

Validation is correct, but the revert reason only mentions the first accepted shape. Including both accepted shapes will make debugging/operator support clearer.

Proposed patch
 function verifyForShapeOr(
   IUintComp components, uint32 index, string memory a, string memory b
 ) public view {
   string memory shape = LibFor.get(components, genID(index));
-  if (!shape.eq(a) && !shape.eq(b)) revert(LibString.concat("not for ", a));
+  if (!shape.eq(a) && !shape.eq(b)) {
+    revert(LibString.concat("not for ", LibString.concat(a, LibString.concat(" or ", b))));
+  }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/contracts/src/libraries/LibItem.sol` around lines 298 - 304, The
revert message in verifyForShapeOr currently only mentions the first accepted
shape; update the revert to include both accepted shapes by building a clear
message (e.g., "not for <a> or <b>") before reverting. Locate function
verifyForShapeOr which calls LibFor.get(components, genID(index)) and checks
shape.eq(a) and shape.eq(b); replace the LibString.concat call used in revert
with a concatenation that includes both a and b (using LibString.concat or
existing string utilities) so the revert contains both accepted shapes for
clearer debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/contracts/src/systems/KamiCastItemSystem.sol`:
- Around line 26-29: The log at the own/enemy ownership branch is hardcoded to
"ENEMY_KAMI" and mislabels own-target casts; update the logging logic in
KamiCastItemSystem.sol to choose the label based on
LibKami.checkAccount(components, targetID, accID) (use "ENEMY_KAMI" when that
check is false and a distinct "OWN_KAMI" or equivalent label when true) and
ensure any subsequent behavior that relies on that log string uses the new
conditional value; adjust the place where verifyState("HARVESTING") is called to
remain unchanged but ensure the log selection is conditional around that call.

---

Nitpick comments:
In `@packages/contracts/src/libraries/LibItem.sol`:
- Around line 298-304: The revert message in verifyForShapeOr currently only
mentions the first accepted shape; update the revert to include both accepted
shapes by building a clear message (e.g., "not for <a> or <b>") before
reverting. Locate function verifyForShapeOr which calls LibFor.get(components,
genID(index)) and checks shape.eq(a) and shape.eq(b); replace the
LibString.concat call used in revert with a concatenation that includes both a
and b (using LibString.concat or existing string utilities) so the revert
contains both accepted shapes for clearer debugging.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 164e55f and fce63a8.

📒 Files selected for processing (5)
  • packages/client/src/app/components/library/buttons/actions/CastItemButton.tsx
  • packages/client/src/app/components/library/buttons/actions/UseItemButton.tsx
  • packages/contracts/src/libraries/LibItem.sol
  • packages/contracts/src/systems/KamiCastItemSystem.sol
  • packages/contracts/src/systems/KamiUseItemSystem.sol

Comment on lines +26 to +29
// enemy kamis must be harvesting (exposed on node)
if (!LibKami.checkAccount(components, targetID, accID)) {
LibKami.verifyState(components, targetID, "HARVESTING");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fix target-shape logging after introducing own-target cast path.

The new ownership branch allows non-enemy targets, but Line 46 still logs "ENEMY_KAMI" unconditionally. This misclassifies own-target casts.

Proposed patch
-    // enemy kamis must be harvesting (exposed on node)
-    if (!LibKami.checkAccount(components, targetID, accID)) {
+    bool isOwnTarget = LibKami.checkAccount(components, targetID, accID);
+
+    // enemy kamis must be harvesting (exposed on node)
+    if (!isOwnTarget) {
       LibKami.verifyState(components, targetID, "HARVESTING");
     }
@@
-    LibItem.logUse(components, accID, itemIndex, 1, "ENEMY_KAMI");
+    LibItem.logUse(components, accID, itemIndex, 1, isOwnTarget ? "KAMI" : "ENEMY_KAMI");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/contracts/src/systems/KamiCastItemSystem.sol` around lines 26 - 29,
The log at the own/enemy ownership branch is hardcoded to "ENEMY_KAMI" and
mislabels own-target casts; update the logging logic in KamiCastItemSystem.sol
to choose the label based on LibKami.checkAccount(components, targetID, accID)
(use "ENEMY_KAMI" when that check is false and a distinct "OWN_KAMI" or
equivalent label when true) and ensure any subsequent behavior that relies on
that log string uses the new conditional value; adjust the place where
verifyState("HARVESTING") is called to remain unchanged but ensure the log
selection is conditional around that call.

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.

3 participants