test(battle-engine-port): M4 COMPLETE — when_play self-buff follower resolves headless (4/4 green)

Fold SetupCardEvent into a shared HeadlessEngineEnv.CreateHeadlessHandCard primitive
(consolidating the duplicated M2/M3 helpers), then add the M4 oracle: card 103111050
(ELF cost-1 1/1, when_play powerup add_offense=1&add_life=1 to target=self). New oracle
dimension = the played card's OWN stat delta (1/1 -> 2/2). Gate play_count>2 seeded via
the public AddCurrentTrunPlayCount; proven load-bearing (without the seed the fanfare
gates out and Atk stays 1). No new shim/data gaps were needed — only harness seeding.
Engine still 0 errors; check_drift clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-06 02:36:02 -04:00
parent c47ae93027
commit b13cfa0fad
4 changed files with 142 additions and 35 deletions

View File

@@ -1,3 +1,6 @@
using System.Reflection;
using Wizard;
using Wizard.Battle;
using Wizard.Battle.Phase;
using Wizard.Battle.Recovery;
using Wizard.Battle.Replay;
@@ -19,6 +22,16 @@ namespace SVSim.BattleEngine.Tests
// (the enemy leader) — auto-targeted (no select_count), no RNG. Deterministic burn to the face.
public const int SpellId = 900124030;
// M4 next-hardest deterministic card: a when_play SELF-BUFF follower. 103111050 is an ELF
// (clan 1) cost-1 1/1 whose sole non-evo skill is `when_play` `powerup` `add_offense=1&add_life=1`
// with skill_target `character=me&target=self` — it buffs ITSELF, so no target selection (the
// fanfare auto-resolves). Fixed +1/+1 => a deterministic stat-delta oracle. The skill is gated on
// `play_count>2`; the headless harness seeds that via the public AddCurrentTrunPlayCount (see the
// oracle test). Base 1/1 -> 2/2 after the fanfare.
public const int BuffFollowerId = 103111050;
public const int BuffAddOffense = 1;
public const int BuffAddLife = 1;
private static bool _done;
public static void EnsureInitialized()
@@ -34,9 +47,9 @@ namespace SVSim.BattleEngine.Tests
.SetValue(null, new Wizard.Crossover());
BattleManagerBase.IsForecast = true;
// CardMaster must be non-null before construction (the leader/class card looks up id 0).
// Load the M2 vanilla follower + the M3 fixed-damage spell so each oracle can create +
// look up its real stats.
HeadlessCardMaster.Load(FollowerId, SpellId);
// Load the M2 vanilla follower + the M3 fixed-damage spell + the M4 self-buff follower so
// each oracle can create + look up its real stats.
HeadlessCardMaster.Load(FollowerId, SpellId, BuffFollowerId);
// Master reference data (class-character list) for leader/class card resolution.
HeadlessMasterData.Install();
// Player/enemy leaders (chara ids must map to a ClassCharacterMasterData in Master).
@@ -64,6 +77,30 @@ namespace SVSim.BattleEngine.Tests
((ClassBattleCardBase)mgr.BattleEnemy.Class).InitBaseMaxLife(life);
}
// The shared headless card-creation primitive. CardCreatorBase.CreateCardWithoutResources is
// the engine's own null-view creation path (CreateBase -> new *BattleCard(buildInfo).Setup(
// createNullView:true)); it's private, so reflect it rather than reimplement the 14-arg
// BuildInfo wiring. The public CardCreatorBase.CreateCard goes through prefab cloning.
//
// The engine's CreateCard also calls owner.SetupCardEvent(card); the raw
// CreateCardWithoutResources seam skips it, so we fold it in here. SetupCardEvent wires the
// per-card play events (BattlePlayerBase.cs:1452): for a SPELL/amulet it attaches
// OnPlay -> RemoveSpellCardFromHand and OnFinishWhenPlaySkill -> AddSpellCardToCemetery, which
// are how a non-follower leaves the hand at all (a follower's hand->field move is intrinsic to
// SetUpInplay, not event-driven). For a follower SetupCardEvent only attaches an OnEvolve hook
// that never fires on a vanilla play, so folding it in is a no-op there — making this a single
// primitive both follower and non-follower oracles can share.
public static BattleCardBase CreateHeadlessHandCard(int cardId, int index, bool isPlayer, BattleManagerBase mgr)
{
var io = mgr.CreatePlayerInnerOptionsBuilder();
var m = typeof(CardCreatorBase).GetMethod("CreateCardWithoutResources",
BindingFlags.NonPublic | BindingFlags.Static);
var card = (BattleCardBase)m.Invoke(null, new object[] { cardId, index, isPlayer, mgr, io });
BattlePlayerBase owner = isPlayer ? (BattlePlayerBase)mgr.BattlePlayer : mgr.BattleEnemy;
owner.SetupCardEvent(card);
return card;
}
private static void SetField(object obj, string name, object value)
{
var f = obj.GetType().GetField(name,