Skip to content

feature: split guaranteed and chance drop groups respecting NumberOfMaximumItemDrops#753

Open
eduardosmaniotto wants to merge 4 commits intoMUnique:masterfrom
eduardosmaniotto:feature/drop-generator
Open

feature: split guaranteed and chance drop groups respecting NumberOfMaximumItemDrops#753
eduardosmaniotto wants to merge 4 commits intoMUnique:masterfrom
eduardosmaniotto:feature/drop-generator

Conversation

@eduardosmaniotto
Copy link
Copy Markdown
Contributor

Updated guaranteed drop groups not being processed. Groups with Chance >= 1.0 are now always dropped without going through random selection. Previously only the single highest chance group was considered via MaxBy.

Split _dropGroups into _guaranteedDropGroups and _chanceDropGroups. Removes the need for runtime partitioning, filtering and sorting on every drop call. Guaranteed and chance-based groups are separated at collection time via PartitionDropGroups, which also inlines the relevance check eliminating the RemoveAll pass.

Replace magic numbers with named constants.

Fix droppedItems initial capacity, changed from new List(1) to new List(monster.NumberOfMaximumItemDrops) to avoid unnecessary list resizing.

@eduardosmaniotto eduardosmaniotto marked this pull request as ready for review April 12, 2026 03:26
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the drop generation logic to improve performance and clarity. By partitioning drop groups into guaranteed and chance-based categories during collection, the system avoids redundant sorting and filtering operations. Additionally, it ensures that guaranteed drops are handled efficiently without random selection, and includes minor optimizations for memory management and code readability.

Highlights

  • Drop Group Partitioning: Split drop groups into guaranteed and chance-based collections at the time of gathering, eliminating the need for runtime filtering and sorting.
  • Guaranteed Drop Processing: Groups with a chance of 1.0 or higher are now processed as guaranteed drops, bypassing random selection logic.
  • Performance Improvements: Optimized memory allocation for the dropped items list by setting initial capacity based on the maximum allowed drops, preventing unnecessary resizing.
  • Code Maintainability: Replaced various magic numbers with named constants to improve readability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the DefaultDropGenerator to separate guaranteed and chance-based item drops into distinct collections, improving the logic for multiple item drops. It also introduces constants for magic numbers and refactors the drop group partitioning into a dedicated method. Key feedback includes a missing monster argument in a PartitionDropGroups call which causes a regression in relevance filtering, a potential NullReferenceException when handling quest item groups, and a suggested optimization to skip the chance-based drop loop if the total chance is zero.

Comment thread src/GameLogic/DefaultDropGenerator.cs
Comment thread src/GameLogic/DefaultDropGenerator.cs Outdated
Comment thread src/GameLogic/DefaultDropGenerator.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.

1 participant