Skip to content

AI Parsing Fix#63

Merged
AngeloTadeucci merged 1 commit intoMS2Community:masterfrom
Zintixx:ai-fix
May 1, 2026
Merged

AI Parsing Fix#63
AngeloTadeucci merged 1 commit intoMS2Community:masterfrom
Zintixx:ai-fix

Conversation

@Zintixx
Copy link
Copy Markdown

@Zintixx Zintixx commented May 1, 2026

Summary by CodeRabbit

Release Notes - Version 2.4.6

  • Improvements

    • Restructured NPC AI battle data with enhanced type safety for battle attributes (startAni, endAni, isBattle) and battle-end conditions (onlyDead).
    • Improved data organization for better battle configuration management.
  • Chores

    • Updated package version to 2.4.6.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

This PR refactors the AI parser to convert untyped List<Entry> collections for battle and battle-end sections into strongly-typed container objects with explicit attribute fields. Parser logic and tests are updated to work with the new nested Entries collections, and the package version is bumped to 2.4.6.

Changes

Cohort / File(s) Summary
Data Model Restructuring
Maple2.File.Parser/Xml/AI/NpcAi.cs
Introduces new Battle class with startAni, endAni, isBattle fields and Entries collection, and new BattleEnd class with onlyDead boolean and Entries collection. Replaces previous untyped List<Entry> fields.
Parser Logic Updates
Maple2.File.Parser/AiParser.cs
Extracts startAni, endAni, isBattle attributes from npcAi/battle section and onlyDead from npcAi/battleEnd section; redirects comment/child-node handling to new Entries collections.
Test Synchronization
Maple2.File.Tests/AiParserTest.cs
Updates test assertions and iteration logic to access battle and battle-end entries via data.Battle.Entries and data.BattleEnd.Entries instead of direct container access.
Version Bump
Maple2.File.Parser/Maple2.File.Parser.csproj
Updates NuGet package version from 2.4.5 to 2.4.6.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • AngeloTadeucci

Poem

🐰 The battle structure now stands tall,
With startAni answering the call,
Each Entry nested, clean and tight,
The parser hops to get it right!
Version up, refactoring's done,
🎉 AI parsing—so much fun!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using non-descriptive language ('Fix') that doesn't convey meaningful information about the specific changes made to AI parsing logic. Revise the title to be more specific about the changes, such as 'Refactor Battle and BattleEnd parsing to use structured types' or 'Extract AI battle attributes into strongly-typed containers'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
Maple2.File.Tests/AiParserTest.cs (1)

64-65: ⚡ Quick win

Assert the new section-level fields too.

This update only verifies Entries, so a regression in startAni, endAni, isBattle, or onlyDead would still pass. It also treats attribute-only <battle> / <battleEnd> sections as absent because hasBattle and hasBattleEnd depend solely on Entries.Count. Please add at least one fixture-specific assertion for the new container fields.

Also applies to: 84-90

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Maple2.File.Tests/AiParserTest.cs` around lines 64 - 65, The test currently
only checks Entries.Count via hasBattle/hasBattleEnd so add assertions that the
section objects exist even when Entries is empty and that their container-level
fields (startAni, endAni, isBattle, onlyDead) have expected fixture values;
specifically, for data.Battle and data.BattleEnd assert the section itself is
not null (to handle attribute-only sections) and assert each of the fields
startAni, endAni, isBattle, onlyDead match the fixture values used in the test;
apply the same additional assertions in the other test block referenced around
the 84-90 region.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Maple2.File.Parser/Maple2.File.Parser.csproj`:
- Line 16: The package version update is too small for the breaking change:
either restore the previous public types for NpcAi.Battle and NpcAi.BattleEnd
(keep List<Entry> shape and add the new container types as new APIs or provide
adapter properties/methods) OR, if you intend to keep the breaking change, bump
the PackageVersion to a new major (e.g., X.0.0) in the project file so the
release is semantically major; modify Maple2.File.Parser.csproj PackageVersion
accordingly and ensure NpcAi.Battle and NpcAi.BattleEnd are updated consistently
with your chosen approach.

---

Nitpick comments:
In `@Maple2.File.Tests/AiParserTest.cs`:
- Around line 64-65: The test currently only checks Entries.Count via
hasBattle/hasBattleEnd so add assertions that the section objects exist even
when Entries is empty and that their container-level fields (startAni, endAni,
isBattle, onlyDead) have expected fixture values; specifically, for data.Battle
and data.BattleEnd assert the section itself is not null (to handle
attribute-only sections) and assert each of the fields startAni, endAni,
isBattle, onlyDead match the fixture values used in the test; apply the same
additional assertions in the other test block referenced around the 84-90
region.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aedf3b81-cbd5-453f-a514-d5c92d36b118

📥 Commits

Reviewing files that changed from the base of the PR and between 5040bf2 and a3a640c.

📒 Files selected for processing (4)
  • Maple2.File.Parser/AiParser.cs
  • Maple2.File.Parser/Maple2.File.Parser.csproj
  • Maple2.File.Parser/Xml/AI/NpcAi.cs
  • Maple2.File.Tests/AiParserTest.cs

<!-- Use following lines to write the generated files to disk. -->
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
<PackageVersion>2.4.5</PackageVersion>
<PackageVersion>2.4.6</PackageVersion>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Patch bump is too small for this public API break.

NpcAi.Battle and NpcAi.BattleEnd no longer expose List<Entry>; they now expose new public container types. That is a breaking change for downstream callers, so publishing it as 2.4.6 hides incompatible API changes behind a patch update. Please either ship this as a major version or preserve the old shape for a deprecation cycle.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Maple2.File.Parser/Maple2.File.Parser.csproj` at line 16, The package version
update is too small for the breaking change: either restore the previous public
types for NpcAi.Battle and NpcAi.BattleEnd (keep List<Entry> shape and add the
new container types as new APIs or provide adapter properties/methods) OR, if
you intend to keep the breaking change, bump the PackageVersion to a new major
(e.g., X.0.0) in the project file so the release is semantically major; modify
Maple2.File.Parser.csproj PackageVersion accordingly and ensure NpcAi.Battle and
NpcAi.BattleEnd are updated consistently with your chosen approach.

@AngeloTadeucci AngeloTadeucci merged commit 6257646 into MS2Community:master May 1, 2026
3 checks passed
@Zintixx Zintixx deleted the ai-fix branch May 5, 2026 03:33
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