refactor(battlenode): close §A boolean-blindness items (MinedToken, Stock, KeyActionType)

Behavior-preserving; 231 BattleNode tests green.

- MinedToken record struct replaces the transpose-prone (int Idx, long CardId,
  CardOwner IsSelf) tuple returned by KnownListBuilder.Mine*. Positional deconstruct
  keeps the Record*From call sites unchanged.
- enum Stock { Normal, Bypass } replaces the negative `bool noStock` on
  IBattleParticipant.PushAsync and DispatchRoute, threaded through both participants,
  BattleSession, and all handler construction sites.
- enum KeyActionType mirrors the client's SendKeyActionDataManager.KeyActionType;
  the StripKeyActionForOpponent guard compares named values, KeyActionEntry.Type is
  the enum (wire-identical via JsonNumberEnumConverter).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-04 22:53:32 -04:00
parent a3e445cf2f
commit e70f32db79
30 changed files with 124 additions and 67 deletions

View File

@@ -10,7 +10,7 @@ namespace SVSim.BattleNode.Sessions;
/// <summary>
/// v2 broker session. Holds two participants and brokers between them. Subscribes
/// to each participant's <see cref="IBattleParticipant.FrameEmitted"/>; on each frame,
/// runs <see cref="ComputeFrames"/> to determine the routing (target + frame + noStock
/// runs <see cref="ComputeFrames"/> to determine the routing (target + frame + <see cref="Stock"/>
/// flag) and dispatches via <see cref="IBattleParticipant.PushAsync"/>.
/// </summary>
/// <remarks>
@@ -112,7 +112,7 @@ public sealed class BattleSession
try
{
await survivor.PushAsync(
BattleFrames.BuildBattleFinish(BattleResult.DisconnectWin), noStock: true, cancellation)
BattleFrames.BuildBattleFinish(BattleResult.DisconnectWin), Stock.Bypass, cancellation)
.ConfigureAwait(false);
}
catch (Exception ex)
@@ -176,9 +176,9 @@ public sealed class BattleSession
try
{
var routes = ComputeFrames(from, env);
foreach (var (target, frame, noStock) in routes)
foreach (var (target, frame, stock) in routes)
{
await target.PushAsync(frame, noStock, ct);
await target.PushAsync(frame, stock, ct);
}
}
catch (Exception ex)
@@ -193,7 +193,7 @@ public sealed class BattleSession
/// <summary>
/// Pure-logic dispatch: given an inbound frame from one participant, return the list
/// of (target, frame, noStock) tuples the session should dispatch. Transitions
/// of (target, frame, stock) routes the session should dispatch. Transitions
/// <see cref="Phase"/>. Extracted so unit tests can drive the dispatch without
/// standing up real participants.
/// </summary>