From 693fba5003c777e4c4447cf10a5259f795d3d383 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Sun, 7 Jun 2026 00:11:28 -0400 Subject: [PATCH] feat(battlenode): emit engine-resolved clan/tribe on knownList entries (M-HC-4e) Prod always emits clan (int ClanType) + tribe (comma-joined int TribeType string, "0" for none) on every knownList entry (battle-traffic_tk2_regular .ndjson). Source both off the resolved engine (SessionBattleEngine.PlayedCardClan/ PlayedCardTribe -> BattleCardBase.Clan/Tribe), so skill-applied clan/tribe changes ride the wire rather than the static card-master value. Thread through KnownListBuilder.BuildPlayedCard + PlayActionsHandler; add clan/tribe to the KnownCardEntry DTO (always present, non-null). Node-side only; no engine edits, drift clean. Co-Authored-By: Claude Opus 4.8 --- .../Bodies/PlayActionsBroadcastBody.cs | 18 ++- .../Dispatch/Handlers/PlayActionsHandler.cs | 10 +- .../Sessions/Dispatch/KnownListBuilder.cs | 27 ++-- .../Sessions/Engine/SessionBattleEngine.cs | 38 ++++++ .../Integration/CaptureConformanceTests.cs | 15 ++- .../Integration/HeadlessConductorTests.cs | 117 ++++++++++++++++++ .../Integration/NodeNativeBattleHarness.cs | 24 ++++ 7 files changed, 228 insertions(+), 21 deletions(-) diff --git a/SVSim.BattleNode/Protocol/Bodies/PlayActionsBroadcastBody.cs b/SVSim.BattleNode/Protocol/Bodies/PlayActionsBroadcastBody.cs index a1ada3e..75b626f 100644 --- a/SVSim.BattleNode/Protocol/Bodies/PlayActionsBroadcastBody.cs +++ b/SVSim.BattleNode/Protocol/Bodies/PlayActionsBroadcastBody.cs @@ -43,15 +43,27 @@ public sealed record SelectCardEntry( /// the played card's accumulated spell-charge count read straight off the resolved engine /// (SessionBattleEngine.PlayedCardSpellboost); the wire-derived spellboost bookkeeping is retired. /// Cost already folds the discount in by construction; the count rides the entry only to stay prod-faithful -/// (prod sends the real count). attachTarget stays ""; clan/tribe remain deferred (receiver re-derives -/// them from cardId). +/// (prod sends the real count). +/// clan and tribe are likewise ENGINE-SOURCED (M-HC-4e) — read off the resolved card's +/// BattleCardBase.Clan/BattleCardBase.Tribe getters (via +/// SessionBattleEngine.PlayedCardClan/PlayedCardTribe), which fold in +/// any skill-applied clan/tribe CHANGE/ADD (e.g. change_affiliation), so the wire carries the LIVE +/// clan/tribe the engine resolved, not the static card-master value. PROD ALWAYS EMITS BOTH on every +/// knownList entry (tk2 capture battle-traffic_tk2_regular.ndjson, e.g. +/// {idx:17,cardId:128821011,...,clan:8,tribe:"7,16",...}): clan is the int ClanType +/// ordinal (present even when 0); tribe is the comma-joined int TribeType ordinals as a +/// STRING, "0" when the card has no tribe (== ClanType/TribeType.ALL == 0, never empty/omitted — +/// the client reads it via item.Value.ToString(), NetworkBattleReceiver.cs:2382). Both are always +/// present (non-null string for tribe), so neither is null-omitted. attachTarget stays "". public sealed record KnownCardEntry( [property: JsonPropertyName("idx")] int Idx, [property: JsonPropertyName("cardId")] long CardId, [property: JsonPropertyName("to")] int To, [property: JsonPropertyName("spellboost")] int Spellboost, [property: JsonPropertyName("attachTarget")] string AttachTarget, - [property: JsonPropertyName("cost")] int Cost); + [property: JsonPropertyName("cost")] int Cost, + [property: JsonPropertyName("clan")] int Clan, + [property: JsonPropertyName("tribe")] string Tribe); /// Renamed targetList entry. isSelf is actor-relative and passes through /// verbatim — no perspective flip (bullet-3 audit F2). diff --git a/SVSim.BattleNode/Sessions/Dispatch/Handlers/PlayActionsHandler.cs b/SVSim.BattleNode/Sessions/Dispatch/Handlers/PlayActionsHandler.cs index af5a146..1f39cdc 100644 --- a/SVSim.BattleNode/Sessions/Dispatch/Handlers/PlayActionsHandler.cs +++ b/SVSim.BattleNode/Sessions/Dispatch/Handlers/PlayActionsHandler.cs @@ -56,8 +56,16 @@ internal sealed class PlayActionsHandler : IFrameHandler // to stay prod-faithful (prod sends the real count). Same senderSeat mapping as the cost read. int playedSpellboost = ctx.Engine.PlayedCardSpellboost(senderSeat, playIdx, fallback: 0); + // clan/tribe are ALSO engine-sourced (M-HC-4e) — read off the resolved card's Clan/Tribe getters, so + // any skill-applied clan/tribe change (e.g. change_affiliation) rides the wire (the static card-master + // value would miss it). Prod always emits both on every knownList entry: clan as the int ClanType + // ordinal, tribe as the comma-joined int TribeType string ("0" for none). Same senderSeat mapping. + int playedClan = ctx.Engine.PlayedCardClan(senderSeat, playIdx, fallback: 0); + string playedTribe = ctx.Engine.PlayedCardTribe(senderSeat, playIdx); + var played = KnownListBuilder.BuildPlayedCard( - deckMap, playIdx, orderList, cost: playedCost, spellboost: playedSpellboost); + deckMap, playIdx, orderList, cost: playedCost, spellboost: playedSpellboost, + clan: playedClan, tribe: playedTribe); var oppoTargets = KnownListBuilder.RenameTargets(entries.GetValueOrDefault(WireKeys.TargetList)); // Deck-sourced movements (fetch / search / summon-from-deck) ride the uList — a verbatim, diff --git a/SVSim.BattleNode/Sessions/Dispatch/KnownListBuilder.cs b/SVSim.BattleNode/Sessions/Dispatch/KnownListBuilder.cs index e0e1a31..542c9d8 100644 --- a/SVSim.BattleNode/Sessions/Dispatch/KnownListBuilder.cs +++ b/SVSim.BattleNode/Sessions/Dispatch/KnownListBuilder.cs @@ -10,25 +10,28 @@ namespace SVSim.BattleNode.Sessions.Dispatch; internal static class KnownListBuilder { /// The played card's knownList entry, or null when its identity can't be synthesized - /// (token idx not in the deck map, or no matching move op). and - /// are both ENGINE-SOURCED (M-HC-3a/3b) — the handler reads the played - /// card's resolved play-time cost (SessionBattleEngine.PlayedCardCost) and accumulated - /// spell-charge count (SessionBattleEngine.PlayedCardSpellboost) off the shadow engine and passes - /// them in; both land on the entry verbatim. The wire-derived spellboost bookkeeping is retired — - /// the engine owns both cost and count by construction (cost folds the spellboost discount in already; - /// the count rides the entry only to stay prod-faithful, prod sends the real count here). Prod's client - /// reads cost straight into the card's cost model (NetworkBattleReceiver), so a vanilla play - /// resolves to its base cost and count 0. attachTarget stays ""; clan/tribe remain deferred (receiver - /// re-derives from cardId). + /// (token idx not in the deck map, or no matching move op). , + /// , and are ALL + /// ENGINE-SOURCED (M-HC-3a/3b/4e) — the handler reads them off the shadow engine + /// (SessionBattleEngine.PlayedCardCost/PlayedCardSpellboost/PlayedCardClan/ + /// PlayedCardTribe) and passes them in; all land on the entry verbatim. The wire-derived + /// spellboost bookkeeping is retired — the engine owns cost and count by construction (cost folds the + /// spellboost discount in already; the count rides the entry only to stay prod-faithful, prod sends the + /// real count here). / are the LIVE (skill-applied) + /// values the engine resolved — prod always sends both on every knownList entry (clan int, tribe the + /// comma-joined int string, "0" for none). Prod's client reads cost straight into the card's cost model + /// (NetworkBattleReceiver), so a vanilla play resolves to its base cost and count 0. attachTarget + /// stays "". public static KnownCardEntry? BuildPlayedCard( IReadOnlyDictionary deckMap, int playIdx, object? orderList, - int cost = 0, int spellboost = 0) + int cost = 0, int spellboost = 0, int clan = 0, string tribe = "0") { if (!deckMap.TryGetValue(playIdx, out var cardId)) return null; var to = ExtractMoveTo(orderList, playIdx); if (to is null) return null; return new KnownCardEntry( - Idx: playIdx, CardId: cardId, To: to.Value, Spellboost: spellboost, AttachTarget: "", Cost: cost); + Idx: playIdx, CardId: cardId, To: to.Value, Spellboost: spellboost, AttachTarget: "", Cost: cost, + Clan: clan, Tribe: tribe); } /// The to place-state of the FIRST move op whose idx list contains diff --git a/SVSim.BattleNode/Sessions/Engine/SessionBattleEngine.cs b/SVSim.BattleNode/Sessions/Engine/SessionBattleEngine.cs index 27692e7..51b58e0 100644 --- a/SVSim.BattleNode/Sessions/Engine/SessionBattleEngine.cs +++ b/SVSim.BattleNode/Sessions/Engine/SessionBattleEngine.cs @@ -279,6 +279,44 @@ internal sealed class SessionBattleEngine return card?.SpellChargeCount ?? fallback; } + /// The engine-RESOLVED clan of the card whose engine Index == on + /// (M-HC-4e), as the int ClanType ordinal prod sends on the + /// knownList entry (e.g. clan:8 in the tk2 capture). Reads , whose + /// getter returns the skill-applied clan (SkillApplyInformation.ClanSkinInfo.Last() when a skill + /// changed it, else BaseParameter.Clan) — so a change_affiliation is reflected, which is WHY + /// the engine value (not the static card-master clan) is the faithful one to emit. + /// Same post-resolution zone search + degrade-to- contract as + /// : no engine / no card → fallback, so a non-engine session never crashes. + public int PlayedCardClan(bool playerSeat, int idx, int fallback = 0) + { + if (_mgr is null) return fallback; + var card = FindByIndex(Seat(playerSeat), idx); + return card is null ? fallback : (int)card.Clan; + } + + /// The engine-RESOLVED tribe of the card whose engine Index == on + /// (M-HC-4e), in the EXACT wire string form prod sends: the comma-joined + /// int TribeType ordinals (e.g. tribe:"7,16" for MACHINE+SCHOOL in the tk2 capture), and + /// "0" when the card has no tribe (== TribeType.ALL == 0 — prod never sends empty/omitted; + /// the client reads it via item.Value.ToString(), NetworkBattleReceiver.cs:2382). Reads + /// , whose getter folds in any skill-applied tribe CHANGE/ADD over + /// BaseParameter.Tribe (and drops ALL when the resolved list has ≥2 entries) — so the wire carries + /// the LIVE tribe, the faithful value over the static card-master one. + /// Same post-resolution zone search as ; no engine / no card → "" (an + /// engine that isn't owned this session emits no card, so the caller's BuildPlayedCard never fires). + public string PlayedCardTribe(bool playerSeat, int idx) + { + if (_mgr is null) return string.Empty; + var card = FindByIndex(Seat(playerSeat), idx); + if (card is null) return string.Empty; + var tribe = card.Tribe; + // Prod's no-tribe form is the single "0" (TribeType.ALL == 0), never an empty string; an empty list + // (defensive) renders the same "0". + return tribe is null || tribe.Count == 0 + ? "0" + : string.Join(",", tribe.Select(t => (int)t)); + } + // Locate the card with the given engine Index across the seat's post-resolution zones. Order matters // only for disambiguation; Index is unique per card so the first hit is the card. In-play (followers) // and cemetery (spells) are where a just-resolved play lands; hand is the pre-resolution fallback. diff --git a/SVSim.UnitTests/BattleNode/Integration/CaptureConformanceTests.cs b/SVSim.UnitTests/BattleNode/Integration/CaptureConformanceTests.cs index 23fa508..589dcb7 100644 --- a/SVSim.UnitTests/BattleNode/Integration/CaptureConformanceTests.cs +++ b/SVSim.UnitTests/BattleNode/Integration/CaptureConformanceTests.cs @@ -294,7 +294,10 @@ public class CaptureConformanceTests var ourEntry = ourDoc.RootElement.GetProperty("knownList")[0]; using var prodDoc = JsonDocument.Parse(prodEntry); - // We are responsible for idx/cardId/to (+ spellboost/attachTarget). cost/clan/tribe are deferred. + // This is a pure-BUILDER shape check: idx/cardId/to are synthesized here; cost/clan/tribe are + // ENGINE-sourced at the handler (PlayActionsHandler reads them off the resolved engine and passes them + // to BuildPlayedCard — covered by HeadlessConductorTests), so this builder-only call leaves them at + // their defaults and we assert only the structural keys. foreach (var key in new[] { "idx", "cardId", "to" }) { Assert.That(ourEntry.TryGetProperty(key, out var ours), Is.True, $"knownList entry missing '{key}'"); @@ -342,7 +345,8 @@ public class CaptureConformanceTests var ourEntry = ourDoc.RootElement.GetProperty("knownList")[0]; using var prodDoc = JsonDocument.Parse(prodEntry); - // We own idx/cardId/to; cost/clan/tribe are deferred (receiver re-derives from cardId). + // Pure-BUILDER shape check: idx/cardId/to are synthesized here; cost/clan/tribe are ENGINE-sourced at + // the handler (covered by HeadlessConductorTests), so this builder-only call leaves them at defaults. foreach (var key in new[] { "idx", "cardId", "to" }) { Assert.That(ourEntry.TryGetProperty(key, out var ours), Is.True, $"knownList entry missing '{key}'"); @@ -424,7 +428,8 @@ public class CaptureConformanceTests // keyAction is {type,cardId} only (selectCard stripped for the hidden open:0 choice); knownList // reveals the generating DECK card. The choiceAdd lands a hidden token at idx 46 (candidates). // Subset check covers playIdx/type/keyAction — the parts we own; knownList idx/cardId/to are - // asserted explicitly below (cost/clan/tribe are deferred, re-derived by the receiver from cardId). + // asserted explicitly below (cost/clan/tribe are ENGINE-sourced at the handler, covered by + // HeadlessConductorTests, so this builder-only call leaves them at defaults — not checked here). const string prodFrame = """ { "playIdx": 18, "type": 30, "keyAction": [ { "type": 1, "cardId": 810014030 } ] } @@ -471,8 +476,8 @@ public class CaptureConformanceTests Assert.That(ourKa.GetProperty("cardId").GetInt64(), Is.EqualTo(810014030L)); // The generating deck card reveals on its own play (idx 18 -> 810014030, to 30). cost/clan/tribe - // are deferred (receiver re-derives from cardId), so only idx/cardId/to are checked — as in the - // sibling SynthesizedKnownList_* tests. + // are ENGINE-sourced at the handler (covered by HeadlessConductorTests); this builder-only call + // leaves them at defaults, so only idx/cardId/to are checked — as in the sibling SynthesizedKnownList_* tests. var ourKnown = ourDoc.RootElement.GetProperty("knownList")[0]; Assert.That(ourKnown.GetProperty("idx").GetInt32(), Is.EqualTo(18)); Assert.That(ourKnown.GetProperty("cardId").GetInt64(), Is.EqualTo(810014030L)); diff --git a/SVSim.UnitTests/BattleNode/Integration/HeadlessConductorTests.cs b/SVSim.UnitTests/BattleNode/Integration/HeadlessConductorTests.cs index efddbab..ba7b78f 100644 --- a/SVSim.UnitTests/BattleNode/Integration/HeadlessConductorTests.cs +++ b/SVSim.UnitTests/BattleNode/Integration/HeadlessConductorTests.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using SVSim.BattleNode.Bridge; using SVSim.BattleNode.Protocol; using SVSim.BattleNode.Protocol.Bodies; using SVSim.BattleNode.Sessions; @@ -1168,6 +1169,122 @@ public class HeadlessConductorTests "non-vacuity: the emitted cost must NOT be the un-reduced base cost (6)"); } + // === M-HC-4e: engine-resolved clan/tribe on the knownList ===================================== + // + // Prod ALWAYS emits clan (int ClanType ordinal) + tribe (comma-joined int TribeType string, "0" for + // none) on every knownList entry (battle-traffic_tk2_regular.ndjson, e.g. + // {idx:17,cardId:128821011,...,clan:8,tribe:"7,16",...}). The node now sources both off the resolved + // engine (SessionBattleEngine.PlayedCardClan/PlayedCardTribe → BattleCardBase.Clan/Tribe), so a + // skill-applied clan/tribe change rides the wire. The fixture 900231030 (ROYAL/clan 2, LEGION/tribe "2", + // cost 0) gives concrete non-zero values so the assertion is non-vacuous (NOT the 0/"0" no-tribe default). + private const long ClanTribeFollowerId = NodeNativeBattleHarness.ClanTribeFollowerId; // 900231030 + private const int ClanTribeFollowerClan = NodeNativeBattleHarness.ClanTribeFollowerClan; // 2 (ROYAL) + private const string ClanTribeFollowerTribe = NodeNativeBattleHarness.ClanTribeFollowerTribe; // "2" (LEGION) + + [Test] + public void PlayedCardClan_and_Tribe_read_engine_resolved_values() + { + // Engine-read proof (mirrors PlayedCardCost_*): drive a node-native battle under a Swordcraft (clan 2) + // seat A — so the ROYAL fixture is legal — play the cost-0 fixture turn 1, then read clan/tribe off the + // resolved engine by the played card's engine Index. They must be the engine's LIVE values (clan 2, + // tribe "2"), in the exact prod wire form. + using var harness = NodeNativeBattleHarness.Create( + seatADeck: NodeNativeBattleHarness.ClanTribeDeck(), seatAClass: CardClass.Swordcraft); + + Assert.That(harness.Push(NetworkBattleUri.Deal, DealBody(), isPlayerSeat: true).Accepted, Is.True, "Deal"); + Assert.That(harness.Push(NetworkBattleUri.Swap, SwapBody(), isPlayerSeat: true).Accepted, Is.True, "Swap"); + Assert.That(harness.Push(NetworkBattleUri.Ready, ReadyBody(), isPlayerSeat: true).Accepted, Is.True, "Ready"); + Assert.That(harness.Push(NetworkBattleUri.TurnStart, TurnStartBody(), isPlayerSeat: true).Accepted, + Is.True, "turn1 TurnStart"); + + int handIdx = FindHandIdxByCardId(harness, ClanTribeFollowerId); + Assert.That(handIdx, Is.GreaterThan(0), "the clan/tribe fixture must be in seat A's opening hand"); + Assert.That(harness.Push(NetworkBattleUri.PlayActions, PlayBody(handIdx), isPlayerSeat: true).Accepted, + Is.True, "cost-0 fixture play ingest"); + + // The PAYOFF reads: clan/tribe off the resolved engine, in the prod wire form. + Assert.That(harness.Engine.PlayedCardClan(playerSeat: true, handIdx, fallback: -1), + Is.EqualTo(ClanTribeFollowerClan), + "PlayedCardClan must equal the engine-resolved clan (ROYAL == 2)"); + Assert.That(harness.Engine.PlayedCardTribe(playerSeat: true, handIdx), + Is.EqualTo(ClanTribeFollowerTribe), + "PlayedCardTribe must equal the engine-resolved tribe in prod wire form (LEGION == \"2\")"); + } + + [Test] + public void PlayedCardTribe_is_zero_string_for_a_no_tribe_card() + { + // The no-tribe form: prod sends tribe "0" (== TribeType.ALL == 0), never empty/omitted. The default + // vanilla follower (VanillaFollowerId) carries no tribe, so its engine-resolved tribe must render "0". + using var harness = NodeNativeBattleHarness.Create(); + + Assert.That(harness.Push(NetworkBattleUri.Deal, DealBody(), isPlayerSeat: true).Accepted, Is.True, "Deal"); + Assert.That(harness.Push(NetworkBattleUri.Swap, SwapBody(), isPlayerSeat: true).Accepted, Is.True, "Swap"); + Assert.That(harness.Push(NetworkBattleUri.Ready, ReadyBody(), isPlayerSeat: true).Accepted, Is.True, "Ready"); + Assert.That(harness.Push(NetworkBattleUri.TurnStart, TurnStartBody(), isPlayerSeat: true).Accepted, + Is.True, "turn1 TurnStart"); + + int vanillaHandIdx = FindHandIdxByCardId(harness, NodeNativeBattleHarness.VanillaFollowerId); + Assert.That(vanillaHandIdx, Is.GreaterThan(0), "a vanilla follower must be in seat A's opening hand"); + Assert.That(harness.Push(NetworkBattleUri.PlayActions, PlayBody(vanillaHandIdx), isPlayerSeat: true).Accepted, + Is.True, "vanilla play ingest"); + + Assert.That(harness.Engine.PlayedCardTribe(playerSeat: true, vanillaHandIdx), Is.EqualTo("0"), + "a no-tribe card's wire tribe is the single \"0\" (TribeType.ALL), never empty"); + } + + [Test] + public void Handler_emits_engine_resolved_clan_and_tribe_on_knownList() + { + // The end-to-end payoff (mirrors Handler_emits_engine_resolved_cost_on_knownList): play the clan/tribe + // fixture, INGEST it (engine resolves the play), then run PlayActionsHandler.Handle and inspect the + // emitted knownList[0].clan/.tribe. They must equal the engine-resolved values (clan 2, tribe "2") — + // proving clan/tribe reach the opponent-facing wire engine-sourced, matching the prod form. + using var harness = NodeNativeBattleHarness.Create( + seatADeck: NodeNativeBattleHarness.ClanTribeDeck(), seatAClass: CardClass.Swordcraft); + + Assert.That(harness.Push(NetworkBattleUri.Deal, DealBody(), isPlayerSeat: true).Accepted, Is.True, "Deal"); + Assert.That(harness.Push(NetworkBattleUri.Swap, SwapBody(), isPlayerSeat: true).Accepted, Is.True, "Swap"); + Assert.That(harness.Push(NetworkBattleUri.Ready, ReadyBody(), isPlayerSeat: true).Accepted, Is.True, "Ready"); + Assert.That(harness.Push(NetworkBattleUri.TurnStart, TurnStartBody(), isPlayerSeat: true).Accepted, + Is.True, "turn1 TurnStart"); + + int handIdx = FindHandIdxByCardId(harness, ClanTribeFollowerId); + Assert.That(handIdx, Is.GreaterThan(0), "the clan/tribe fixture must be in seat A's opening hand"); + + var playBody = HandlerPlayBody(handIdx); + Assert.That(harness.Push(NetworkBattleUri.PlayActions, playBody, isPlayerSeat: true).Accepted, + Is.True, "fixture play ingest"); + + harness.SeatA.Phase = HandshakePhase.AfterReady; + harness.SeatB.Phase = HandshakePhase.AfterReady; + var env = new MsgEnvelope( + NetworkBattleUri.PlayActions, ViewerId: harness.SeatA.ViewerId, Uuid: "udid-test", Bid: null, + RetryAttempt: 0, Cat: EmitCategory.Battle, PubSeq: null, PlaySeq: null, + Body: new RawBody(playBody)); + var ctx = new FrameDispatchContext + { + A = harness.SeatA, B = harness.SeatB, From = harness.SeatA, Other = harness.SeatB, + Env = env, BattleId = "test-battle", State = harness.State, Engine = harness.Engine, + }; + + var routes = new PlayActionsHandler().Handle(ctx); + + Assert.That(routes, Has.Count.EqualTo(1), "one route to the opponent"); + var body = routes[0].Frame.Body as PlayActionsBroadcastBody; + Assert.That(body, Is.Not.Null, "frame body is a PlayActionsBroadcastBody"); + Assert.That(body!.KnownList, Is.Not.Null.And.Count.EqualTo(1), "one knownList entry (the played fixture)"); + Assert.That(body.KnownList![0].CardId, Is.EqualTo(ClanTribeFollowerId), "the fixture's identity"); + // THE assertions: clan/tribe are the engine-resolved values, in the prod wire form. + Assert.That(body.KnownList[0].Clan, Is.EqualTo(ClanTribeFollowerClan), + "knownList[].clan must be the engine-resolved clan ordinal (ROYAL == 2)"); + Assert.That(body.KnownList[0].Tribe, Is.EqualTo(ClanTribeFollowerTribe), + "knownList[].tribe must be the engine-resolved tribe in prod wire form (LEGION == \"2\")"); + // Non-vacuity: the emitted values must NOT be the 0/"0" no-clan/no-tribe default. + Assert.That(body.KnownList[0].Clan, Is.Not.EqualTo(0), "non-vacuity: clan must not be the 0 default"); + Assert.That(body.KnownList[0].Tribe, Is.Not.EqualTo("0"), "non-vacuity: tribe must not be the \"0\" default"); + } + // The hand POSITION (0-based) of the seat-A hand card with the given engine Index, or -1. Lets a test // re-derive a HandCardId(seat, pos) lookup from an engine Index it already located by identity. private static int FindHandPosByEngineIdx(NodeNativeBattleHarness harness, int engineIdx) diff --git a/SVSim.UnitTests/BattleNode/Integration/NodeNativeBattleHarness.cs b/SVSim.UnitTests/BattleNode/Integration/NodeNativeBattleHarness.cs index 11bdcd5..434e8d7 100644 --- a/SVSim.UnitTests/BattleNode/Integration/NodeNativeBattleHarness.cs +++ b/SVSim.UnitTests/BattleNode/Integration/NodeNativeBattleHarness.cs @@ -132,6 +132,24 @@ internal sealed class NodeNativeBattleHarness : IDisposable /// followers evolved (a SET, not an add) — exactly 1. public const int BoardDependentCostReduced = 1; + /// A non-trivial CLAN+TRIBE fixture follower (M-HC-4e). cards.json id 900231030: char_type 1 + /// (follower), clan 2 (ROYAL / Swordcraft), tribe 2 (LEGION), cost 0, 2/2. Cost 0 makes it playable on + /// turn-1 PP 1; its clan (2) matches so it is legal under a Swordcraft + /// seat. Its clan/tribe (2 / "2") are concretely non-zero so the engine-sourced clan/tribe read + + /// knownList emit assert REAL values (not the 0/"0" no-tribe default). Verified against cards.json AND the + /// prod wire form (comma-joined int TribeType as string: tribe 2 → "2"). Present + creatable in + /// cards.json. + public const long ClanTribeFollowerId = 900231030; + + /// The engine-resolved clan of as the wire int (ROYAL == + /// ClanType 2). The M-HC-4e knownList emit asserts clan equals this. + public const int ClanTribeFollowerClan = 2; + + /// The engine-resolved tribe of in the EXACT prod wire string + /// form (LEGION == TribeType 2 → the single-element comma-join "2"). The M-HC-4e knownList emit asserts + /// tribe equals this. + public const string ClanTribeFollowerTribe = "2"; + public BattleSessionState State { get; } public StubParticipant SeatA { get; } public StubParticipant SeatB { get; } @@ -176,6 +194,12 @@ internal sealed class NodeNativeBattleHarness : IDisposable return deck; } + /// A 30-card deck of the clan+tribe fixture (M-HC-4e). All one + /// identity, all cost 0 — so the opening hand reliably holds a copy to play turn 1, regardless of shuffle, + /// and the engine-resolved clan/tribe read off the played card is unambiguous. + public static IReadOnlyList ClanTribeDeck() => + Enumerable.Repeat(ClanTribeFollowerId, 30).ToList(); + /// Seat the engine exactly as BattleSession.EnsureEngineSetup does: shuffle each /// side's deck from the fixed seed via , then /// SessionBattleEngine.Setup(seed, deckA, deckB, classA, classB).