Fix enchant scroll applying single-level stats instead of cumulative#674
Fix enchant scroll applying single-level stats instead of cumulative#674
Conversation
EnchantScrollHandler.HandleEnchant only called GetEnchant for the target level, giving e.g. only level 11's bonus instead of the sum of levels 1 through 11. HandlePreview also computed deltas from current enchant level instead of absolute cumulative values, showing wrong stats when using a scroll on an already-enchanted item. Both now use GetCumulativeEnchant which sums per-level rates from 1 through the target level, matching manual Ophelia/Peachy enchanting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughPreview and apply logic for enchant scrolls changed to compute cumulative Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~35 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Maple2.Server.Game/PacketHandlers/EnchantScrollHandler.cs`:
- Line 110: The current assignment item.Enchant = GetCumulativeEnchant(session,
item, enchantLevel) replaces the existing ItemEnchant object and wipes persisted
fields (EnchantExp, EnchantCharges, Charges, Tradeable) — instead, update the
existing Item.Enchant in-place: call GetCumulativeEnchant to obtain the computed
BasicOptions/Enchants and then copy only those specific properties onto the
existing item.Enchant instance (or create it if null) so EnchantExp,
EnchantCharges, Charges and Tradeable remain unchanged; apply the same in-place
merge fix for the other similar block referenced around lines 138-151.
- Around line 67-69: The preview for Random scrolls uses metadata.Enchants.Min()
directly which can show a lower floor than the item's current enchant; change
the min preview calculation in the EnchantScrollType.Random branch of
HandleEnchant to clamp the minimum roll to the item's current enchant (e.g.,
compute minRoll = Math.Max(metadata.Enchants.Min(), currentEnchant) or
equivalent using the item's current enchant level) before calling
GetCumulativeEnchant(session, item, ...). Leave the max preview as
metadata.Enchants.Max() but ensure both calls use the clamped value for the
lower bound so minOptions reflects the true non-decreasing floor.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 17ba1ebe-0ea3-451f-b707-165b486f42de
📒 Files selected for processing (1)
Maple2.Server.Game/PacketHandlers/EnchantScrollHandler.cs
Clamp preview minimum to item's current enchant level (Math.Max) since enchant scrolls never decrease enchant level. Update enchant properties in-place instead of replacing the ItemEnchant object to preserve persisted fields (EnchantExp, EnchantCharges, Charges, Tradeable). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EnchantScrollHandler.HandleEnchant only called GetEnchant for the target level, giving e.g. only level 11's bonus instead of the sum of levels 1 through 11. HandlePreview also computed deltas from current enchant level instead of absolute cumulative values, showing wrong stats when using a scroll on an already-enchanted item.
Both now use GetCumulativeEnchant which sums per-level rates from 1 through the target level, matching manual Ophelia/Peachy enchanting.
Summary by CodeRabbit