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 <noreply@anthropic.com>
This commit is contained in:
@@ -43,15 +43,27 @@ public sealed record SelectCardEntry(
|
||||
/// the played card's accumulated spell-charge count read straight off the resolved engine
|
||||
/// (<c>SessionBattleEngine.PlayedCardSpellboost</c>); 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).</summary>
|
||||
/// (prod sends the real count).
|
||||
/// <para><c>clan</c> and <c>tribe</c> are likewise ENGINE-SOURCED (M-HC-4e) — read off the resolved card's
|
||||
/// <c>BattleCardBase.Clan</c>/<c>BattleCardBase.Tribe</c> getters (via
|
||||
/// <c>SessionBattleEngine.PlayedCardClan</c>/<c>PlayedCardTribe</c>), which fold in
|
||||
/// any skill-applied clan/tribe CHANGE/ADD (e.g. <c>change_affiliation</c>), 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 <c>battle-traffic_tk2_regular.ndjson</c>, e.g.
|
||||
/// <c>{idx:17,cardId:128821011,...,clan:8,tribe:"7,16",...}</c>): <c>clan</c> is the int <c>ClanType</c>
|
||||
/// ordinal (present even when 0); <c>tribe</c> is the comma-joined int <c>TribeType</c> ordinals as a
|
||||
/// STRING, <c>"0"</c> when the card has no tribe (== <c>ClanType/TribeType.ALL == 0</c>, never empty/omitted —
|
||||
/// the client reads it via <c>item.Value.ToString()</c>, NetworkBattleReceiver.cs:2382). Both are always
|
||||
/// present (non-null string for tribe), so neither is null-omitted. attachTarget stays "".</para></summary>
|
||||
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);
|
||||
|
||||
/// <summary>Renamed <c>targetList</c> entry. <c>isSelf</c> is actor-relative and passes through
|
||||
/// verbatim — no perspective flip (bullet-3 audit F2).</summary>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -10,25 +10,28 @@ namespace SVSim.BattleNode.Sessions.Dispatch;
|
||||
internal static class KnownListBuilder
|
||||
{
|
||||
/// <summary>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). <paramref name="cost"/> and
|
||||
/// <paramref name="spellboost"/> are both ENGINE-SOURCED (M-HC-3a/3b) — the handler reads the played
|
||||
/// card's resolved play-time cost (<c>SessionBattleEngine.PlayedCardCost</c>) and accumulated
|
||||
/// spell-charge count (<c>SessionBattleEngine.PlayedCardSpellboost</c>) 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 (<c>NetworkBattleReceiver</c>), so a vanilla play
|
||||
/// resolves to its base cost and count 0. attachTarget stays ""; clan/tribe remain deferred (receiver
|
||||
/// re-derives from cardId).</summary>
|
||||
/// (token idx not in the deck map, or no matching move op). <paramref name="cost"/>,
|
||||
/// <paramref name="spellboost"/>, <paramref name="clan"/> and <paramref name="tribe"/> are ALL
|
||||
/// ENGINE-SOURCED (M-HC-3a/3b/4e) — the handler reads them off the shadow engine
|
||||
/// (<c>SessionBattleEngine.PlayedCardCost</c>/<c>PlayedCardSpellboost</c>/<c>PlayedCardClan</c>/
|
||||
/// <c>PlayedCardTribe</c>) 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). <paramref name="clan"/>/<paramref name="tribe"/> 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
|
||||
/// (<c>NetworkBattleReceiver</c>), so a vanilla play resolves to its base cost and count 0. attachTarget
|
||||
/// stays "".</summary>
|
||||
public static KnownCardEntry? BuildPlayedCard(
|
||||
IReadOnlyDictionary<int, long> 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);
|
||||
}
|
||||
|
||||
/// <summary>The <c>to</c> place-state of the FIRST <c>move</c> op whose <c>idx</c> list contains
|
||||
|
||||
@@ -279,6 +279,44 @@ internal sealed class SessionBattleEngine
|
||||
return card?.SpellChargeCount ?? fallback;
|
||||
}
|
||||
|
||||
/// <summary>The engine-RESOLVED clan of the card whose engine <c>Index</c> == <paramref name="idx"/> on
|
||||
/// <paramref name="playerSeat"/> (M-HC-4e), as the int <c>ClanType</c> ordinal prod sends on the
|
||||
/// knownList entry (e.g. <c>clan:8</c> in the tk2 capture). Reads <see cref="BattleCardBase.Clan"/>, whose
|
||||
/// getter returns the skill-applied clan (<c>SkillApplyInformation.ClanSkinInfo.Last()</c> when a skill
|
||||
/// changed it, else <c>BaseParameter.Clan</c>) — so a <c>change_affiliation</c> is reflected, which is WHY
|
||||
/// the engine value (not the static card-master clan) is the faithful one to emit.
|
||||
/// <para>Same post-resolution zone search + degrade-to-<paramref name="fallback"/> contract as
|
||||
/// <see cref="PlayedCardCost"/>: no engine / no card → fallback, so a non-engine session never crashes.</para></summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>The engine-RESOLVED tribe of the card whose engine <c>Index</c> == <paramref name="idx"/> on
|
||||
/// <paramref name="playerSeat"/> (M-HC-4e), in the EXACT wire string form prod sends: the comma-joined
|
||||
/// int <c>TribeType</c> ordinals (e.g. <c>tribe:"7,16"</c> for MACHINE+SCHOOL in the tk2 capture), and
|
||||
/// <c>"0"</c> when the card has no tribe (== <c>TribeType.ALL == 0</c> — prod never sends empty/omitted;
|
||||
/// the client reads it via <c>item.Value.ToString()</c>, NetworkBattleReceiver.cs:2382). Reads
|
||||
/// <see cref="BattleCardBase.Tribe"/>, whose getter folds in any skill-applied tribe CHANGE/ADD over
|
||||
/// <c>BaseParameter.Tribe</c> (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.
|
||||
/// <para>Same post-resolution zone search as <see cref="PlayedCardCost"/>; no engine / no card → "" (an
|
||||
/// engine that isn't owned this session emits no card, so the caller's BuildPlayedCard never fires).</para></summary>
|
||||
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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -132,6 +132,24 @@ internal sealed class NodeNativeBattleHarness : IDisposable
|
||||
/// followers evolved (a SET, not an add) — exactly 1.</summary>
|
||||
public const int BoardDependentCostReduced = 1;
|
||||
|
||||
/// <summary>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 <see cref="CardClass.Swordcraft"/> 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.</summary>
|
||||
public const long ClanTribeFollowerId = 900231030;
|
||||
|
||||
/// <summary>The engine-resolved clan of <see cref="ClanTribeFollowerId"/> as the wire int (ROYAL ==
|
||||
/// ClanType 2). The M-HC-4e knownList emit asserts <c>clan</c> equals this.</summary>
|
||||
public const int ClanTribeFollowerClan = 2;
|
||||
|
||||
/// <summary>The engine-resolved tribe of <see cref="ClanTribeFollowerId"/> in the EXACT prod wire string
|
||||
/// form (LEGION == TribeType 2 → the single-element comma-join "2"). The M-HC-4e knownList emit asserts
|
||||
/// <c>tribe</c> equals this.</summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>A 30-card deck of the <see cref="ClanTribeFollowerId"/> 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.</summary>
|
||||
public static IReadOnlyList<long> ClanTribeDeck() =>
|
||||
Enumerable.Repeat(ClanTribeFollowerId, 30).ToList();
|
||||
|
||||
/// <summary>Seat the engine exactly as <c>BattleSession.EnsureEngineSetup</c> does: shuffle each
|
||||
/// side's deck from the fixed seed via <see cref="BattleSessionState.GetShuffledDeck"/>, then
|
||||
/// <c>SessionBattleEngine.Setup(seed, deckA, deckB, classA, classB)</c>.</summary>
|
||||
|
||||
Reference in New Issue
Block a user