feature: split guaranteed and chance drop groups respecting NumberOfMaximumItemDrops#753
feature: split guaranteed and chance drop groups respecting NumberOfMaximumItemDrops#753eduardosmaniotto wants to merge 4 commits intoMUnique:masterfrom
Conversation
Summary of ChangesHello, 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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
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.