refactor(battlenode): engine-first token identity (cardId); keep wire-mining fallback (M-HC-4f, partial)
Source the played card's opponent-facing knownList[].cardId off the shadow engine (SessionBattleEngine.PlayedCardId -> BattleCardBase.CardId), engine-first with the wire-mined idx->cardId map as the fallback. PROVEN engine-resolved (each backed by a HeadlessConductorTests PlayedCardId_* test): deck cards and receive-path substituted/ revealed tokens (engine seats the wire id at the wire idx). PARTIAL retirement: the wire-mining bookkeeping (MineAddOps/MineChoicePicks/MineCopyTokens + Record*From) is KEPT as the load-bearing fallback. The choice/Discover, copy/clone and cross-side (isSelf:0) token cases are NOT proven to resolve at a wire idx headless — the autonomous token_draw path seats a chosen token at engine Index 0 (would collide with the leader), and copy/cross-side aren't cheaply fixturable. Deleting their mining on faith would silently corrupt opponent reveals, so it stays behind a TODO(M-HC-4f) gate. - SessionBattleEngine.PlayedCardId: new accessor mirroring PlayedCardClan/Tribe. - BuildPlayedCard: signature deckMap->explicit cardId; null on cardId==0 (no engine id AND no mined/deck-map fallback). - PlayActionsHandler: cardId = engine.PlayedCardId(seat, idx, fallback: mapped) ; mining retained. - Tests: PlayedCardId_* (deck/substituted/degrade pass; choice-gap [Explicit] documents the Index-0 finding). KnownListBuilder + CaptureConformance call-sites updated to new signature. Full BattleNode suite 263/263 green; HeadlessConductorTests 27/27; drift clean; no Engine edits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -62,19 +62,19 @@ public class KnownListBuilderTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPlayedCard_returns_null_for_deck_card_with_no_matching_move_op()
|
||||
public void BuildPlayedCard_returns_null_for_card_with_no_matching_move_op()
|
||||
{
|
||||
// idx is in the deck, but the orderList has no move op for it → can't synthesize.
|
||||
var deckMap = new Dictionary<int, long> { [3] = 128821011L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 3, orderList: OrderListMove(7, 10, 20));
|
||||
// A resolved cardId, but the orderList has no move op for the played idx → can't synthesize.
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 128821011L, orderList: OrderListMove(7, 10, 20));
|
||||
Assert.That(entry, Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPlayedCard_synthesizes_entry_for_deck_card()
|
||||
public void BuildPlayedCard_synthesizes_entry_from_engine_sourced_cardId()
|
||||
{
|
||||
var deckMap = new Dictionary<int, long> { [3] = 128821011L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 3, orderList: OrderListMove(3, 10, 20));
|
||||
// M-HC-4f: the handler resolves the cardId engine-first (PlayedCardId, deck-map/mined fallback) and passes
|
||||
// it in; BuildPlayedCard lands it on the entry verbatim.
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 128821011L, orderList: OrderListMove(3, 10, 20));
|
||||
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Idx, Is.EqualTo(3));
|
||||
@@ -90,8 +90,7 @@ public class KnownListBuilderTests
|
||||
{
|
||||
// M-HC-3a: the handler reads the engine-resolved play-time cost and passes it in; BuildPlayedCard
|
||||
// lands it on the entry verbatim. (A wrong cost yields a different field — non-vacuity.)
|
||||
var deckMap = new Dictionary<int, long> { [3] = 101314020L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 3, orderList: OrderListMove(3, 10, 20), cost: 3);
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 101314020L, orderList: OrderListMove(3, 10, 20), cost: 3);
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Cost, Is.EqualTo(3));
|
||||
}
|
||||
@@ -102,17 +101,17 @@ public class KnownListBuilderTests
|
||||
// M-HC-3b: the handler reads the engine-resolved spell-charge count
|
||||
// (SessionBattleEngine.PlayedCardSpellboost) and passes it in; BuildPlayedCard lands it on the
|
||||
// entry verbatim. (Default 0 vs a non-zero value is the non-vacuity.)
|
||||
var deckMap = new Dictionary<int, long> { [3] = 101314020L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 3, orderList: OrderListMove(3, 10, 20), cost: 3, spellboost: 2);
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 101314020L, orderList: OrderListMove(3, 10, 20), cost: 3, spellboost: 2);
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Spellboost, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildPlayedCard_returns_null_for_token_idx_not_in_deck()
|
||||
public void BuildPlayedCard_returns_null_for_zero_cardId()
|
||||
{
|
||||
var deckMap = new Dictionary<int, long> { [3] = 128821011L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, playIdx: 31, orderList: OrderListMove(31, 10, 20));
|
||||
// M-HC-4f: cardId 0 means the engine resolved no id AND the deck-map/mined fallback had no entry for the
|
||||
// idx → un-synthesizable identity → null (the play degrades to {playIdx,type}, no knownList).
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 31, cardId: 0L, orderList: OrderListMove(31, 10, 20));
|
||||
Assert.That(entry, Is.Null);
|
||||
}
|
||||
|
||||
@@ -121,8 +120,7 @@ public class KnownListBuilderTests
|
||||
{
|
||||
// A vanilla play emits spellboost 0 (the engine resolves no spell-charge for a non-boosted card,
|
||||
// so the handler's PlayedCardSpellboost read is 0 and the param defaults to 0).
|
||||
var deckMap = new Dictionary<int, long> { [3] = 101311010L };
|
||||
Assert.That(KnownListBuilder.BuildPlayedCard(deckMap, 3, OrderListMove(3, 10, 20))!.Spellboost, Is.EqualTo(0));
|
||||
Assert.That(KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 101311010L, orderList: OrderListMove(3, 10, 20))!.Spellboost, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -131,9 +129,8 @@ public class KnownListBuilderTests
|
||||
// M-HC-4e: the handler reads the engine-resolved clan/tribe
|
||||
// (SessionBattleEngine.PlayedCardClan / PlayedCardTribe) and passes them in; BuildPlayedCard lands
|
||||
// them on the entry verbatim. (A wrong clan/tribe yields a different field — non-vacuity.)
|
||||
var deckMap = new Dictionary<int, long> { [3] = 101314020L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(
|
||||
deckMap, playIdx: 3, orderList: OrderListMove(3, 10, 20), cost: 3, spellboost: 2, clan: 8, tribe: "7,16");
|
||||
playIdx: 3, cardId: 101314020L, orderList: OrderListMove(3, 10, 20), cost: 3, spellboost: 2, clan: 8, tribe: "7,16");
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Clan, Is.EqualTo(8));
|
||||
Assert.That(entry.Tribe, Is.EqualTo("7,16"));
|
||||
@@ -145,8 +142,7 @@ public class KnownListBuilderTests
|
||||
// A play whose engine read degraded (single-active-engine gate: _mgr null → the accessor fallback)
|
||||
// emits clan 0 (ClanType.ALL ordinal) and tribe "0" (the prod no-tribe form, NEVER empty —
|
||||
// empty is wire-illegal). The param defaults match the accessor fallbacks.
|
||||
var deckMap = new Dictionary<int, long> { [3] = 101311010L };
|
||||
var entry = KnownListBuilder.BuildPlayedCard(deckMap, 3, OrderListMove(3, 10, 20));
|
||||
var entry = KnownListBuilder.BuildPlayedCard(playIdx: 3, cardId: 101311010L, orderList: OrderListMove(3, 10, 20));
|
||||
Assert.That(entry, Is.Not.Null);
|
||||
Assert.That(entry!.Clan, Is.EqualTo(0));
|
||||
Assert.That(entry.Tribe, Is.EqualTo("0"));
|
||||
|
||||
Reference in New Issue
Block a user