Fix deck enchant selection state and confirmation - #8
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for deck enchant selection screens (NDeckEnchantSelectScreen) by introducing reflection helpers to retrieve selection limits and selected card models, and updating the state builder to track these states. A review comment suggests a safer way to dynamically invoke the ConfirmSelection method to prevent a potential TargetParameterCountException if the method signature changes in the future.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| var parameters = confirmMethod.GetParameters(); | ||
| confirmMethod.Invoke(screen, parameters.Length == 0 ? null : new[] { confirmButton }); |
There was a problem hiding this comment.
If the ConfirmSelection method signature has more than one parameter (e.g., due to future game updates or optional parameters), passing a single-element array new[] { confirmButton } will throw a TargetParameterCountException. It is safer to dynamically construct the arguments array to match the expected parameter count of the method.
var parameters = confirmMethod.GetParameters();
var args = parameters.Length == 0 ? null : new object?[parameters.Length];
if (args != null)
{
args[0] = confirmButton;
}
confirmMethod.Invoke(screen, args);There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for “deck enchant” card selection screens by improving selection-state detection, min/max selection handling, preview container discovery, and confirm behavior.
Changes:
- Track selected cards via reflected
_selectedCardsand surfaceis_selectedin built card state. - Read
MinSelect/MaxSelectmore robustly (directly or via_prefs) and incorporate them into confirm eligibility. - Add deck-enchant preview containers and custom confirm logic invoking
ConfirmSelectionvia reflection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| McpMod.StateBuilder.cs | Enhances card selection state building for deck-enchant screens (selected flags, min/max select, preview detection, confirm eligibility). |
| McpMod.Helpers.cs | Adds reflection helpers to read selector constraints and selected cards consistently. |
| McpMod.Actions.cs | Adds deck-enchant-specific confirm flow that bypasses missing/disabled UI confirm buttons. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var parameters = confirmMethod.GetParameters(); | ||
| confirmMethod.Invoke(screen, parameters.Length == 0 ? null : new[] { confirmButton }); |
|
|
||
| private static Dictionary<string, object?>? TryConfirmDeckEnchantSelection(NCardGridSelectionScreen screen) | ||
| { | ||
| if (screen.GetType().Name != "NDeckEnchantSelectScreen") |
| try | ||
| { | ||
| var property = type.GetProperty(memberName, Flags); | ||
| if (property != null && property.GetIndexParameters().Length == 0) | ||
| return property.GetValue(source); | ||
| } | ||
| catch { } | ||
|
|
||
| try | ||
| { | ||
| var field = type.GetField(memberName, Flags); | ||
| if (field != null) | ||
| return field.GetValue(source); | ||
| } | ||
| catch { } |
|
Addressed the first two bot review comments in follow-up commit
Re-ran local verification:
|
Builds on Gennadiyev#85 and fixes the remaining deck enchant card selection issue.
Problem:
NDeckEnchantSelectScreenstores selected cards in its private_selectedCardsset.selected_cards/selected_countcan stay empty even when cards are visibly selected.confirm_selectionalso needs a special path for this screen, because the final completion goes through the game's ownConfirmSelection/CheckIfSelectionCompleteflow.Fix:
_selectedCards._prefswhen needed.NDeckEnchantSelectScreenthrough the game's ownConfirmSelection.Verified locally:
python scripts/audit_endpoints.py --skip-livepasses.uv run --project mcp python scripts/test_mcp_server.pypasses.selected_count=3; confirm returned to the shop; Kifuda was added; all three selected cards gained the enchant text.