Skip to content

Fix: Stats - #242

Merged
AngeloTadeucci merged 2 commits into
masterfrom
stats
Sep 22, 2024
Merged

Fix: Stats#242
AngeloTadeucci merged 2 commits into
masterfrom
stats

Conversation

@AngeloTadeucci

@AngeloTadeucci AngeloTadeucci commented Sep 20, 2024

Copy link
Copy Markdown
Collaborator
  • Added parameter to always max roll stats
  • Implemented MultiplyFactor for stats

Summary by CodeRabbit

  • New Features

    • Introduced an option to roll for maximum stats when creating items via a new command-line parameter --roll-max.
    • Added a MultiplyFactor field to enhance item options, allowing for more dynamic item statistics.
  • Bug Fixes

    • Adjusted logic to ensure that the MultiplyFactor defaults to one instead of zero, improving item creation consistency.
  • Documentation

    • Updated method signatures to reflect the new parameters and options introduced in the item creation process.

@coderabbitai

coderabbitai Bot commented Sep 20, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce enhancements to item creation and statistics handling in the game. Key modifications include the addition of a MultiplyFactor field in the Option class, adjustments to item creation commands to allow rolling for maximum stats, and updates to the methods responsible for calculating item statistics. These changes collectively enable more flexible item generation and better control over item attributes, ensuring that the new mechanics integrate seamlessly with existing functionality.

Changes

Files Change Summary
Maple2.File.Ingest/MapperExtensions.cs, Maple2.Model/Game/Item/ItemStats.cs Updated ItemOption instantiation to default MultiplyFactor to one if zero. Added MultiplyFactor field and updated constructor in Option class to accept this parameter.
Maple2.Server.Game/Commands/ItemCommand.cs Introduced --roll-max command-line option for maximum stat rolling. Updated Handle and SetHandler methods to include a new boolean parameter.
Maple2.Server.Game/Manager/Items/ItemDropManager.cs Modified CreateItem method to include rollMax parameter, allowing item creation to consider maximum stats during calculations.
Maple2.Server.Game/Util/ItemStatsCalculator.cs Enhanced GetStats and RandomizeValues methods with rollMax parameter. Adjusted logic for selecting random values based on this parameter and ensured MultiplyFactor is applied in calculations for item statistics.

Poem

🐇 In the land of Maple, where items gleam,
A new way to roll, a maximum dream!
With factors that multiply, stats now soar,
Command the magic, let treasures galore!
Hop, skip, and jump, for the fun's just begun,
In this vibrant world, every player's a sun! 🌟


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 maintainability

Using the literal 17 directly 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

Commits

Files that changed from the base of the PR and between 60b47f3 and 30cec0b.

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 rollMax option is correctly defined with a clear name, description, and appropriate default value.


37-37: LGTM!

The rollMax option is correctly added to the ItemCommand class using the AddOption method.


38-38: LGTM!

The SetHandler method is correctly updated to include the new rollMax option, with a consistent method signature change.


41-41: LGTM!

The Handle method signature is correctly updated to accept the new rollMax parameter, with a consistent type and order.


44-44: LGTM!

The rollMax parameter is correctly passed to the CreateItem method using a named argument, improving code readability.

Maple2.Model/Game/Item/ItemStats.cs (2)

103-103: LGTM!

The addition of the MultiplyFactor field 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 multiplyFactor parameter is a good change. It is backward compatible and provides flexibility in creating Option objects with custom multiplication factors. The default value of 1 ensures that the multiplication factor is neutral if not explicitly provided. The assignment of multiplyFactor to MultiplyFactor field is correct.

Maple2.Server.Game/Manager/Items/ItemDropManager.cs (2)

293-293: LGTM!

The addition of the rollMax parameter to the CreateItem method provides a useful option for generating items with maximum stats when needed, while maintaining backward compatibility through the default value of false.


307-307: Looks good!

Passing the rollMax parameter to the GetStats method ensures that the item stats are calculated correctly based on the specified value. This change aligns with the addition of the rollMax parameter to the CreateItem method 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 zero MultiplyFactor.

By defaulting MultiplyFactor to one when entry.multiply_factor is zero, you avoid potential divide-by-zero errors or unintended behavior in calculations involving ItemOption instances. This ensures the integrity of the ItemOption data.

Maple2.Server.Game/Util/ItemStatsCalculator.cs (1)

Line range hint 21-39: Introduction of rollMax parameter enhances item stat control

The addition of the optional rollMax parameter to the GetStats method and its subsequent usage enables the functionality to roll maximum stats when required. The use of a default value ensures existing functionality remains unaffected.

Comment thread Maple2.Server.Game/Util/ItemStatsCalculator.cs
Comment thread Maple2.Server.Game/Util/ItemStatsCalculator.cs
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.

2 participants