Skip to content

Add support for fisher_grade condition type and update mastery handling - #561

Merged
AngeloTadeucci merged 1 commit into
MS2Community:masterfrom
Tandashi:feat/#33/fisher_grade_achievements
Aug 25, 2025
Merged

Add support for fisher_grade condition type and update mastery handling#561
AngeloTadeucci merged 1 commit into
MS2Community:masterfrom
Tandashi:feat/#33/fisher_grade_achievements

Conversation

@Tandashi

@Tandashi Tandashi commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Overview

Previously when the fishing mastery had been updated the session had been updated with ConditionType.mastery_grade and the mastery type. However for fishing this needs to be ConditionType.fisher_grade with the fishing level. Furthermore the Condition checks for code and target now support the fisher_grade type.

Refs: #33

Video

2025-08-25_22-42-47.mp4

Summary by CodeRabbit

  • Bug Fixes
    • Corrected fishing mastery grade updates to accurately reflect the current level.
    • Ensured fishing-related conditions properly evaluate fisher grade, improving reliability of checks.
    • Improved consistency for quests, achievements, and events that depend on fishing mastery progression.

…ling

Previously when the fishing mastery had been updated the session had been updated with
`ConditionType.mastery_grade` and the mastery type. However for fishing this needs to be
`ConditionType.fisher_grade` with the fishing level. Furthermore the Condition checks for
code and target now support the `fisher_grade` type.

Refs: MS2Community#33
@coderabbitai

coderabbitai Bot commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds special-case handling for Fishing mastery in MasteryManager’s indexer to update a new fisher_grade condition, and updates ConditionUtil to evaluate fisher_grade in both code and target checks alongside existing fish-related cases.

Changes

Cohort / File(s) Summary
Mastery logic update
Maple2.Server.Game/Manager/MasteryManager.cs
Adds System.Diagnostics using. Modifies indexer setter: when startLevel < currentLevel or startValue == 0, updates ConditionType.fisher_grade with codeLong=currentLevel for Fishing; other types continue using ConditionType.mastery_grade with codeLong=(int)type. Other paths unchanged.
Condition evaluation update
Maple2.Server.Game/Util/ConditionUtil.cs
Adds fisher_grade to CheckCode and CheckTarget switch groups, aligning its evaluation with existing fish/map-related Range/Integers logic.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Player
  participant MasteryManager
  participant ConditionUtil

  Player->>MasteryManager: Gain mastery (type, startLevel, currentLevel, startValue)
  alt type == Fishing and (startLevel < currentLevel or startValue == 0)
    Note right of MasteryManager: New path
    MasteryManager->>ConditionUtil: Update Condition (fisher_grade, codeLong=currentLevel)
  else
    MasteryManager->>ConditionUtil: Update Condition (mastery_grade, codeLong=(int)type)
  end
  Note over ConditionUtil: fisher_grade evaluated via existing Range/Integers logic
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • AngeloTadeucci

Poem

A whisker twitch, a ripple in the lake,
I tally grades with every cast I make.
From mastery’s chart to fisher’s glade,
New checks align, the ledger’s laid.
Hop-hop—conditions set, no flake—
The code now knows each catch I take. 🐇🎣

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 0

🧹 Nitpick comments (4)
Maple2.Server.Game/Util/ConditionUtil.cs (3)

193-200: Range comparisons appear inverted (likely always-false edge cases)

The checks use Min >= value && Max <= value. Typical range checks should be Min <= value && value <= Max. This predates the PR but is a correctness bug hazard.

Apply:

-                if (target.Range != null && target.Range.Value.Min >= session.Player.Value.Character.MapId &&
-                    target.Range.Value.Max <= session.Player.Value.Character.MapId) {
+                if (target.Range != null &&
+                    session.Player.Value.Character.MapId >= target.Range.Value.Min &&
+                    session.Player.Value.Character.MapId <= target.Range.Value.Max) {
                     return true;
                 }

If you prefer consistency, consider using the existing InRange helper instead:

-                if (target.Range != null && target.Range.Value.Min >= session.Player.Value.Character.MapId &&
-                    target.Range.Value.Max <= session.Player.Value.Character.MapId) {
+                if (target.Range != null &&
+                    InRange(target.Range.Value, session.Player.Value.Character.MapId)) {
                     return true;
                 }

Happy to open a follow-up PR that normalizes all range checks to InRange(...).


206-213: Same inverted range comparison for fish/fish_big/fall_damage block

The comparison should be Min <= longValue && longValue <= Max.

-                if (target.Range != null && target.Range.Value.Min >= longValue &&
-                    target.Range.Value.Max <= longValue) {
+                if (target.Range != null &&
+                    longValue >= target.Range.Value.Min &&
+                    longValue <= target.Range.Value.Max) {
                     return true;
                 }

245-253: Same issue in movement/music/chat block: inverted range comparison

Align with correct semantics or use InRange.

-                if (target.Range != null && target.Range.Value.Min >= longValue &&
-                    target.Range.Value.Max <= longValue) {
+                if (target.Range != null &&
+                    longValue >= target.Range.Value.Min &&
+                    longValue <= target.Range.Value.Max) {
                     return true;
                 }

Alternatively:

-                if (target.Range != null && target.Range.Value.Min >= longValue &&
-                    target.Range.Value.Max <= longValue) {
+                if (target.Range != null && InRange(target.Range.Value, (int) longValue)) {
                     return true;
                 }
Maple2.Server.Game/Manager/MasteryManager.cs (1)

90-95: Consider also emitting fisher_grade on downgrade for symmetry

Today the downgrade path emits set_mastery_grade (type-based) for all masteries. If achievements/quests will listen specifically to fisher_grade, they won’t see downgrades. If that’s intended, ignore; if not, mirror the upgrade path for Fishing.

Proposed minimal change (keep existing set_mastery_grade for backward compatibility):

             if (startLevel > currentLevel) {
                 session.ConditionUpdate(ConditionType.set_mastery_grade, codeLong: (int) type);
-                if (type == MasteryType.Music) {
+                if (type == MasteryType.Fishing) {
+                    session.ConditionUpdate(ConditionType.fisher_grade, codeLong: currentLevel);
+                } else if (type == MasteryType.Music) {
                     session.ConditionUpdate(ConditionType.music_play_grade);
                 }
             }

Please confirm intended event semantics for fishing downgrades (should fisher_grade fire, or only set_mastery_grade?).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between caa3bb3 and 86006f0.

📒 Files selected for processing (2)
  • Maple2.Server.Game/Manager/MasteryManager.cs (2 hunks)
  • Maple2.Server.Game/Util/ConditionUtil.cs (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Maple2.Server.Game/Manager/MasteryManager.cs (1)
Maple2.Server.Game/Session/GameSession.cs (1)
  • ConditionUpdate (551-554)
🔇 Additional comments (3)
Maple2.Server.Game/Util/ConditionUtil.cs (2)

269-269: Target check for fisher_grade intentionally unrestricted

Including ConditionType.fisher_grade in the always-true Target group mirrors other mastery-related conditions (e.g., mastery_grade). Target is ignored; grading is driven by Code only. This is consistent with the intended semantics.


62-62: fisher_grade is now correctly routed via codeLong—no further changes needed

  • In MasteryManager.cs (line 85), the only emission of ConditionType.fisher_grade uses the codeLong: currentLevel parameter, and there are no other call sites for this condition type.
  • In ConditionUtil.cs, ConditionType.fisher_grade is included in both “integer/code” switch‐case groups (around lines 60–64 and 268–271), alongside other codeLong-driven conditions.
  • There are no remaining references treating fishing under mastery_grade, so there’s no mismatch or stale logic.

All verifications pass—approving these changes as is.

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

84-88: Fishing now emits fisher_grade with currentLevel — matches PR intent

On grade-up (or initial unlock), Fishing emits ConditionType.fisher_grade with codeLong: currentLevel, while other masteries keep using mastery_grade with codeLong: (int)type. This exactly implements the requirement to key fishing progression off level instead of type.

@AngeloTadeucci
AngeloTadeucci merged commit aa8dab8 into MS2Community:master Aug 25, 2025
4 checks passed
@Tandashi
Tandashi deleted the feat/#33/fisher_grade_achievements branch August 25, 2025 21:25
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.

3 participants