Fix: Stats - #242
Conversation
WalkthroughThe changes introduce enhancements to item creation and statistics handling in the game. Key modifications include the addition of a Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
Outside diff range and nitpick comments (1)
Maple2.Server.Game/Util/ItemStatsCalculator.cs (1)
116-116: Define a constant for the maximum index value to enhance maintainabilityUsing the literal
17directly in multiple places can lead to errors and makes future updates more difficult. Consider defining a constant (e.g.,MaxIndex = 17) for the maximum index value. This will improve code readability and simplify future maintenance.Apply this diff to introduce the constant:
+const int MaxIndex = 17; ... - int index = rollMax ? 17 : Random.Shared.Next(2, 18); + int index = rollMax ? MaxIndex : Random.Shared.Next(2, MaxIndex + 1);Also applies to: 126-126
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- Maple2.File.Ingest/MapperExtensions.cs (1 hunks)
- Maple2.Model/Game/Item/ItemStats.cs (1 hunks)
- Maple2.Server.Game/Commands/ItemCommand.cs (1 hunks)
- Maple2.Server.Game/Manager/Items/ItemDropManager.cs (2 hunks)
- Maple2.Server.Game/Util/ItemStatsCalculator.cs (5 hunks)
Additional comments not posted (11)
Maple2.Server.Game/Commands/ItemCommand.cs (5)
31-31: LGTM!The new
rollMaxoption is correctly defined with a clear name, description, and appropriate default value.
37-37: LGTM!The
rollMaxoption is correctly added to theItemCommandclass using theAddOptionmethod.
38-38: LGTM!The
SetHandlermethod is correctly updated to include the newrollMaxoption, with a consistent method signature change.
41-41: LGTM!The
Handlemethod signature is correctly updated to accept the newrollMaxparameter, with a consistent type and order.
44-44: LGTM!The
rollMaxparameter is correctly passed to theCreateItemmethod using a named argument, improving code readability.Maple2.Model/Game/Item/ItemStats.cs (2)
103-103: LGTM!The addition of the
MultiplyFactorfield is a good change. It is appropriately named, typed, and scoped. This field can be used to store a multiplication factor for the options, which aligns with the PR objective.
107-110: LGTM!The constructor update to accept the
multiplyFactorparameter is a good change. It is backward compatible and provides flexibility in creatingOptionobjects with custom multiplication factors. The default value of1ensures that the multiplication factor is neutral if not explicitly provided. The assignment ofmultiplyFactortoMultiplyFactorfield is correct.Maple2.Server.Game/Manager/Items/ItemDropManager.cs (2)
293-293: LGTM!The addition of the
rollMaxparameter to theCreateItemmethod provides a useful option for generating items with maximum stats when needed, while maintaining backward compatibility through the default value offalse.
307-307: Looks good!Passing the
rollMaxparameter to theGetStatsmethod ensures that the item stats are calculated correctly based on the specified value. This change aligns with the addition of therollMaxparameter to theCreateItemmethod and enables the generation of items with maximum stats when desired.Maple2.File.Ingest/MapperExtensions.cs (1)
435-435: Good catch! This change prevents potential issues with a zeroMultiplyFactor.By defaulting
MultiplyFactorto one whenentry.multiply_factoris zero, you avoid potential divide-by-zero errors or unintended behavior in calculations involvingItemOptioninstances. This ensures the integrity of theItemOptiondata.Maple2.Server.Game/Util/ItemStatsCalculator.cs (1)
Line range hint
21-39: Introduction ofrollMaxparameter enhances item stat controlThe addition of the optional
rollMaxparameter to theGetStatsmethod and its subsequent usage enables the functionality to roll maximum stats when required. The use of a default value ensures existing functionality remains unaffected.
Summary by CodeRabbit
New Features
--roll-max.MultiplyFactorfield to enhance item options, allowing for more dynamic item statistics.Bug Fixes
MultiplyFactordefaults to one instead of zero, improving item creation consistency.Documentation