Skip to content

Misc additions#436

Merged
AngeloTadeucci merged 2 commits intomasterfrom
miscfix
Apr 29, 2025
Merged

Misc additions#436
AngeloTadeucci merged 2 commits intomasterfrom
miscfix

Conversation

@Zintixx
Copy link
Collaborator

@Zintixx Zintixx commented Apr 29, 2025

Adds a few more quest/achievement types

More adjustments on HongBao to correctly display the amount/player count on use

Implemented removing region skills via triggers

Implemented ApplyTargetType 5 - this handles some region buffs like certain crazy runner speed/slow pads

Added some additional ItemUse items

Summary by CodeRabbit

  • New Features
    • Added support for new skill trigger management, allowing skills to be added or removed based on trigger IDs.
    • Expanded region buff types for skills, including new healing spot buffs.
    • Introduced item functions for adding additional effects and expanding inventory.
  • Enhancements
    • Improved achievement and condition tracking for various actions such as leveling up, equipping items, sending mail, using taxis, and chatting.
    • Enhanced item claiming and distribution logic for HongBao rewards, including inventory and mail fallback.
    • Added inventory expansion feedback with success and max capacity notifications.
  • Bug Fixes
    • Unified condition updates to ensure consistent progress tracking across multiple player actions.
  • API Changes
    • Updated method signatures and interfaces to support new skill trigger and HongBao handling features.
    • Modified inventory expansion method to return success status and accept variable expansion size.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 29, 2025

"""

Walkthrough

This update introduces several enhancements and adjustments across multiple modules. The ApplyTargetType enum is revised with new and redefined entries. The AddSkill method in field management now supports a triggerId parameter, with corresponding updates to interfaces and entity models, and includes logic for removing skills by trigger ID. The HongBao item claim and distribution flow is reworked, splitting claim logic and inventory/mail handling. Numerous game event handlers now invoke ConditionUpdate for various player actions, and condition evaluation logic is extended to support new condition types. Packet structures and trigger context handling are also updated to align with these changes.

Changes

File(s) Change Summary
Maple2.Model/Enum/Skill.cs Modified ApplyTargetType enum: removed Player2, shifted and documented RegionBuff, added RegionBuff2.
Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs
Maple2.Server.Game/Manager/Field/FieldManager/IField.cs
Maple2.Server.Game/Model/Field/Entity/FieldSkill.cs
Added triggerId parameter to AddSkill and interface; added TriggerId property to FieldSkill; implemented skill removal by triggerId.
Maple2.Server.Game/Model/Field/HongBao.cs
Maple2.Server.Game/PacketHandlers/PlayerHostHandler.cs
Maple2.Server.Game/Packets/PlayerHostPacket.cs
Refactored HongBao claim logic: changed return type, removed serialization, updated claim handling and packet structure to include item amount.
Maple2.Server.Game/Manager/AchievementManager.cs
Maple2.Server.Game/Manager/Items/EquipManager.cs
Maple2.Server.Game/PacketHandlers/MailHandler.cs
Maple2.Server.Game/PacketHandlers/PlayerHostHandler.cs
Maple2.Server.Game/PacketHandlers/TaxiHandler.cs
Maple2.Server.Game/PacketHandlers/UserChatHandler.cs
Maple2.Server.Game/Commands/PlayerCommand.cs
Added calls to ConditionUpdate for various player actions (achievement, equip, mail, item claim, taxi, chat, level up).
Maple2.Server.Game/Trigger/TriggerContext.Field.cs Updated skill trigger logic: now adds or removes skills by triggerId based on enable flag.
Maple2.Server.Game/Util/ConditionUtil.cs Extended condition evaluation logic to support new condition types and update checks.
Maple2.Server.Game/PacketHandlers/ItemUseHandler.cs
Maple2.Server.Game/Manager/Items/InventoryManager.cs
Maple2.Model.Metadata.ItemMetadata.cs
Maple2.File.Ingest.Mapper.ItemMapper.cs
Maple2.Server.Game/Packets/ItemUsePacket.cs
Maple2.Server.Game/PacketHandlers/SkillHandler.cs
Added new item functions (additional effect, inventory expansion), updated inventory expansion method to return success status, extended item metadata with Shadow World flag, added new item use packets, and added new skill target types in skill handler.

Sequence Diagram(s)

sequenceDiagram
    participant Player
    participant Session
    participant FieldManager
    participant HongBao

    Player->>Session: Perform action (e.g., level up, equip, chat, claim HongBao)
    Session->>Session: ConditionUpdate(type, params)
    alt Claim HongBao
        Session->>FieldManager: Get HongBao
        FieldManager->>HongBao: Claim(player)
        HongBao-->>Session: Item? (null or item)
        alt Item is not null
            Session->>Player: Send GiftHongBao packet (with amount)
            Session->>Player: Try add item to inventory
            alt Inventory full
                Session->>Player: Mail item instead
            end
        end
    end
Loading

Possibly related PRs

  • AngeloTadeucci/Maple2#427: Also involves changes to the ApplyTargetType enum, focusing on adding new enums and refining skill target types.

Suggested labels

Skill / Buff

Suggested reviewers

  • AngeloTadeucci

Poem

In fields of code where skills now bloom,
With triggers set and HongBao’s boon,
Achievements cheer, and chat flows free,
Condition updates—one, two, three!
Enum lines shift, the packets sing,
A rabbit hops—let changes spring!
🐇✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04b3a73 and 89d60a2.

📒 Files selected for processing (15)
  • Maple2.Model/Enum/Skill.cs (1 hunks)
  • Maple2.Server.Game/Commands/PlayerCommand.cs (1 hunks)
  • Maple2.Server.Game/Manager/AchievementManager.cs (1 hunks)
  • Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs (4 hunks)
  • Maple2.Server.Game/Manager/Field/FieldManager/IField.cs (1 hunks)
  • Maple2.Server.Game/Manager/Items/EquipManager.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Entity/FieldSkill.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/HongBao.cs (2 hunks)
  • Maple2.Server.Game/PacketHandlers/MailHandler.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/PlayerHostHandler.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/TaxiHandler.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/UserChatHandler.cs (1 hunks)
  • Maple2.Server.Game/Packets/PlayerHostPacket.cs (1 hunks)
  • Maple2.Server.Game/Trigger/TriggerContext.Field.cs (1 hunks)
  • Maple2.Server.Game/Util/ConditionUtil.cs (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
Maple2.Server.Game/PacketHandlers/TaxiHandler.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (536-539)
Maple2.Server.Game/Manager/Items/EquipManager.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (536-539)
Maple2.Server.Game/PacketHandlers/MailHandler.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (536-539)
Maple2.Server.Game/Manager/AchievementManager.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (536-539)
Maple2.Server.Game/PacketHandlers/UserChatHandler.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (536-539)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (22)
Maple2.Server.Game/PacketHandlers/TaxiHandler.cs (1)

91-92: Good improvement to track taxi usage metrics!

These condition updates for taxi usage and taxi fees are well-placed after confirming the player has sufficient mesos. This will enable tracking player taxi usage patterns and associated costs, which can be leveraged for achievements or quests related to transportation.

Maple2.Server.Game/Manager/AchievementManager.cs (1)

131-133: Good enhancement for tracking achievement progression!

These condition updates properly track different achievement grade changes by passing both the achievement ID (codeLong) and current grade (targetLong). This implementation allows for more granular quest and achievement conditions based on player progression.

Maple2.Server.Game/PacketHandlers/MailHandler.cs (1)

93-93: Good addition for tracking mail activity!

This condition update for mail sending is appropriately placed after successfully creating and validating the mail object but before sending the notification. This allows for quests and achievements that track player communication activities.

Maple2.Server.Game/Manager/Items/EquipManager.cs (1)

134-136: Good implementation for tracking UGC equipment changes!

The condition is correctly checking if the equipped item has a template before triggering the change_ugc_equip condition update. This enables tracking when players equip user-generated content items, which can be used for related achievements or quests.

Maple2.Server.Game/PacketHandlers/UserChatHandler.cs (2)

46-72: Improved flow control by replacing returns with breaks in switch cases

The change from return to break statements in all switch cases allows the method to continue execution after the switch block, enabling consistent condition updates for all chat types.


73-74: Added chat condition update for quest and achievement tracking

This new line adds a condition update for chat actions, tracking the current map ID where the chat occurred. This enhancement supports the expanded quest and achievement system mentioned in the PR objectives.

Maple2.Server.Game/Commands/PlayerCommand.cs (1)

55-55: Added level-up condition tracking with job-specific context

This enhancement adds support for tracking level-up events with job-specific context, enabling more targeted quest and achievement triggers based on both character job and level. The implementation correctly captures both the job code and the new level value.

Maple2.Server.Game/Util/ConditionUtil.cs (4)

117-119: Added support for new achievement grade condition types

Extended the condition utility to handle achievement-related grade conditions, supporting the expanded achievement system mentioned in the PR objectives.


169-173: Added support for new gameplay action condition types

Added support for tracking various gameplay actions such as using taxis, chat, sending mail, and changing equipment, which enables more diverse quest and achievement triggers.


232-234: Extended target check logic for achievement and chat conditions

Updated the target checking logic to properly evaluate achievement grade and chat conditions, ensuring they work correctly with the range and integer containment logic.


310-314: Completed condition type support in target check method

Added the remaining condition types to ensure consistent handling across both code and target check methods, creating a complete implementation for the new condition types.

Maple2.Server.Game/Model/Field/Entity/FieldSkill.cs (1)

19-19: Good addition for trigger-based skill management

The new TriggerId property enables associating skills with specific triggers, which supports the PR objective of implementing the ability to remove region skills through triggers. The property is correctly implemented as init-only since the association shouldn't change after creation.

Maple2.Server.Game/Packets/PlayerHostPacket.cs (1)

21-29: Good refactoring of HongBao packet handling

The changes to the UseHongBao method properly separate concerns by moving serialization logic from the model class to the packet class. The explicit field writing makes the packet structure clearer, and the addition of the amount parameter enables the HongBao feature to correctly display amounts as mentioned in the PR objectives.

The calculation hongBao.MaxUserCount - 1 for player count ensures the display properly reflects the remaining slots for users.

Maple2.Server.Game/Manager/Field/FieldManager/IField.cs (1)

62-62:

Details

✅ Verification successful

Good interface extension for trigger-based skill management

The addition of the optional triggerId parameter with a default value of 0 aligns well with the new TriggerId property in the FieldSkill class. This maintains backward compatibility while enabling the new functionality to remove region skills through triggers as mentioned in the PR objectives.


🏁 Script executed:

#!/bin/bash
# Verify that the implementation of AddSkill in FieldManager properly sets the TriggerId

echo "Searching for AddSkill implementation in FieldManager..."
rg "public void AddSkill.*triggerId" -A 10 --type cs

echo "\nVerifying if there's a corresponding RemoveSkillByTriggerId method..."
rg "RemoveSkillByTriggerId" --type cs

Length of output: 3214


AddSkill implementation correctly propagates triggerId

The AddSkill override in FieldManager.State now sets the TriggerId on the created FieldSkill, and a corresponding RemoveSkillByTriggerId(int triggerId) method exists both in the manager and is invoked from TriggerContext.Field. This fully aligns with the new trigger-based skill removal workflow and maintains backward compatibility via the default value.

Maple2.Server.Game/PacketHandlers/PlayerHostHandler.cs (1)

35-43: Improved HongBao claim handling design

The code now properly separates concerns by having HongBao.Claim return the item instead of directly handling inventory operations. This is a good design improvement that enhances modularity.

Maple2.Server.Game/Trigger/TriggerContext.Field.cs (1)

328-343: Good implementation of region skill removal feature

The implementation now correctly supports both enabling and removing skills by trigger ID. When enabled, it looks up the skill by trigger ID, validates it exists and has valid metadata, then adds it with a fixed delay. When disabled, it properly removes skills by trigger ID.

One minor consideration: the fixed delay of 150ms is hardcoded. Consider extracting this value to a constant or configuration setting for better maintainability.

Maple2.Server.Game/Model/Field/HongBao.cs (2)

7-7: Removed unnecessary interface implementation

The IByteSerializable interface was properly removed as the serialization responsibility has been moved elsewhere.


58-75: Improved separation of concerns in HongBao claim logic

The Claim method now returns an Item? instead of handling inventory operations and packet sending directly. This is a good design improvement that makes the class more focused and testable.

Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs (4)

413-418: Good implementation of trigger ID support for field skills

The AddSkill method now properly accepts and assigns a triggerId parameter, enabling skills to be tracked and later removed by their trigger ID.


502-503: Support for new ApplyTargetType.RegionBuff2

The implementation correctly handles the new RegionBuff2 type by treating it identically to RegionBuff, maintaining consistent behavior for similar target types.


516-521: Well-implemented RemoveSkillByTriggerId method

The new method correctly removes all skills matching a given triggerId from the fieldSkills dictionary and broadcasts removal packets for each one.


585-593: Properly updated HongBao item handling

The method now correctly captures and processes the item returned by hongBao.Claim, adding it to inventory or mailing it as needed. The broadcast packet also includes the item amount now.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89d60a2 and f4a0ef4.

📒 Files selected for processing (6)
  • Maple2.File.Ingest/Mapper/ItemMapper.cs (1 hunks)
  • Maple2.Model/Metadata/ItemMetadata.cs (1 hunks)
  • Maple2.Server.Game/Manager/Items/InventoryManager.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/ItemUseHandler.cs (3 hunks)
  • Maple2.Server.Game/PacketHandlers/SkillHandler.cs (1 hunks)
  • Maple2.Server.Game/Packets/ItemUsePacket.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (15)
Maple2.File.Ingest/Mapper/ItemMapper.cs (1)

114-115: LGTM: Parameters and OnlyShadowWorld property properly added.

The new OnlyShadowWorld property is correctly initialized based on data.function.onlyShadowContinent value, maintaining consistency with the updated ItemMetadataFunction record structure. This change aligns with the PR objective to support region-specific features.

Maple2.Server.Game/Packets/ItemUsePacket.cs (2)

16-23: LGTM: Correctly implemented inventory expansion notification.

Packet construction follows the established pattern in the class, using the appropriate command enum value to indicate inventory expansion success.


25-32: LGTM: Correctly implemented maximum inventory notification.

Packet construction follows the established pattern, creating a response to inform the client that the inventory cannot be expanded further.

Maple2.Server.Game/Manager/Items/InventoryManager.cs (7)

517-522: Improved method signature and input validation.

The Expand method now returns a boolean result indicating success and accepts a configurable row count parameter. The divisibility check ensures that inventory expansions maintain proper grid alignment.


525-527: LGTM: Consistent error handling approach.

Error conditions now return false instead of void, allowing callers to handle expansion failures appropriately.


529-534: LGTM: Dynamic expansion size calculation.

The expansion calculation now uses the passed parameter instead of a fixed constant, providing flexibility while still enforcing maximum expansion limits.


536-539: LGTM: Consistent error handling for currency checks.

Currency validation matches the pattern of other error conditions, appropriately returning false when expansion requirements aren't met.


541-543: LGTM: Proper expansion failure handling.

Failed expansions are now properly indicated to callers through the return value.


546-550: LGTM: Updated expansion tracking logic.

The player's unlock dictionary is correctly updated with either the new expanded value or initialized with the expandRowCount parameter if not present.


552-555: LGTM: Appropriate success notification and return value.

The method correctly sends the expansion notification packets and returns true to indicate success, completing the operation.

Maple2.Model/Metadata/ItemMetadata.cs (1)

84-85: LGTM: Added OnlyShadowWorld property to ItemMetadataFunction.

The addition of the OnlyShadowWorld boolean property to the ItemMetadataFunction record supports the PR objective to implement region-specific functionality. This property allows the system to restrict certain item functions to the Shadow World continent.

Maple2.Server.Game/PacketHandlers/ItemUseHandler.cs (3)

42-44: ShadowWorld continent restriction check is properly implemented.

This new check properly implements the restriction for items that should only be usable in the Shadow World continent, helping enforce region-specific behavior.


117-122: New item function cases are properly integrated into the switch statement.

The new AddAdditionalEffect and ExpandInven item functions are correctly added to the existing switch statement, following the established pattern in the codebase.


586-618: ExpandInventory handler is well-implemented with proper validation.

The inventory expansion logic is correctly implemented with comprehensive mapping between string representations and inventory types, proper validation, and appropriate user feedback for both success and failure cases.

Maple2.Server.Game/PacketHandlers/SkillHandler.cs (1)

258-259:

Details

❌ Incorrect review comment

New ApplyTargetType cases should be properly handled.

I see that two new ApplyTargetType cases have been added (RegionBuff and RegionBuff2), but they currently fall through to the default case which only logs an "Unhandled Target-SkillEntity" message without any actual handling logic.

Based on the PR objectives mentioning the implementation of "ApplyTargetType 5" for managing region buffs like speed or slow effects, these cases should have specific handling logic rather than falling through to the default case.


🏁 Script executed:

#!/bin/bash
# Check how RegionBuff and RegionBuff2 are handled in other files

# First, find how these enum values are defined
echo "Checking ApplyTargetType enum definition:"
rg -A 10 "enum ApplyTargetType" --type cs

# Then check how they're handled in FieldManager.State.cs which is mentioned in the AI summary
echo "Checking GetTargets implementation in FieldManager.State.cs:"
rg -A 5 -B 5 "GetTargets.*RegionBuff2" --type cs

Length of output: 910


🏁 Script executed:

#!/bin/bash
# Show the switch block handling ApplyTargetType in SkillHandler.cs around the new cases
sed -n '230,310p' Maple2.Server.Game/PacketHandlers/SkillHandler.cs

# Locate all GetTargets definitions and calls to inspect region buff handling
rg -n "GetTargets" --type cs

# Search for any RegionBuff usage across the codebase
rg -n "RegionBuff" --type cs

Length of output: 5168


RegionBuff cases are handled in the Splash path, not the Attack path
The new ApplyTargetType.RegionBuff/RegionBuff2 values are only used for area‐of‐effect buffs and are routed through HandleSplash (via session.Field.AddSkill) rather than HandleAttack. They correctly fall through in the attack‐target switch and do not require handling in SkillHandler.HandleAttack.
Please ignore the original suggestion.

Likely an incorrect or invalid review comment.

@AngeloTadeucci AngeloTadeucci merged commit d7acbb0 into master Apr 29, 2025
4 checks passed
@AngeloTadeucci AngeloTadeucci deleted the miscfix branch April 29, 2025 11:57
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

Comments