Six distinct fixes accumulated over live-test iterations against four bids (654473755566, 806245601092, 283192092460, 131549100204, 799755786270) — together they take the shadow engine from "throws on the first non-mulligan play" to "survives a full PvP battle, only weird-edge-case Unity touches still left to whack". 1. Engine StableRandom seed aligned with clients' Matched.seed (BattleSession.EnsureEngineSetup, NodeNativeBattleHarness.Create). Clients seed _stableRandom with BattleSeeds.Stable(masterSeed) (the value the node ships in Matched.seed); we were passing the RAW masterSeed to engine.Setup, so every StableRandom call diverged from call #1 onward — every turn-1+ draw picked a different deck position than the clients. Verified Stable(1184631275)=1543475792 matches the wire on bid 654473755566. 2. SeedDeck advances cardTotalNum to deck.Count+1 + pins BattleStartDeckCardList. Mirrors SBattleLoad.InitPlayer's tail (SBattleLoad.cs:1292). Without it, skill-generated tokens auto-assigned Index 0,1,... and COLLIDED with deck-loaded indices 1..40 — silent until something addressed the deck card with the colliding Index (Hoverboarder at deck idx 1 + a token at engine Index 1 made GetBattleCardIdx's SingleOrDefault throw on bid 806245601092). 3. BattleCardView.GameObject lazily non-null in the shim (ViewUiTouchStubs.cs). The IsRecovery card-create delegate (NetworkBattleManagerBase.cs:379) passes null cardGameObject; Skill_metamorphose.cs:147 in the in-play branch then NRE'd on `metamorphosedCard.BattleCardView.GameObject.transform.rotation = identity`, a purely cosmetic touch with no game-state implication. Bid 283192092460: Petrification on a board follower. 4. TranslateChoiceKeyAction unwraps wrapped selectCard on shadow ingest (SessionBattleEngine.cs, sibling to TranslateTargetOwners). Live sender-send wires Choice plays as selectCard:{cardId:[...], open:0}; engine's ConvertToListInt does `value as List<object>` — a Dict casts to null and foreach NREs. The receiver's swallow-all catch (NetworkBattleReceiver.cs:1255) logs to Debug.LogError + LocalLog — both shimmed/no-op'd headlessly — and returns false, but Receive calls ReceivedMessage with checkBreakData:false so the false isn't propagated. The play continues with choiceIdList=[], the chosen branch never resolves, the played card stays in hand; a later targeted play (A's bounce on B's "board" idx 20) then can't find the target → NRE on null in ActionProcessor.PlayCard:407. Bid 131549100204: B's Resonance + A's bounce. Opponent-relay path is unaffected — node strips selectCard from broadcasts. 5. HeadlessHandViewStub overrides HandUnfocus/HandFocus/FocusRearrangeHandHand to return NullVfx. CreateHandControl returns null in headless; the base methods unconditionally deref `_handControl.SetHandState(...)`. A follower with a when_spell_play Heal trigger fired on its leader for amount 0 — even a 0-heal drives ApplyHealing → CreatePullHandInVfx → HandUnfocus → NRE. Bid 799755786270: two consecutive spell plays both crashed this stack. Added InternalsVisibleTo("SVSim.BattleEngine.Tests") so the shim-level regression tests can pin the no-op contracts directly. Plus the previous-session fixes carried in this same uncommitted state (see docs/superpowers/plans/2026-06-07-shadow-engine-desync-handoff.md): - doesPlayerGoFirst:true + mgr.IsFirst:true (turn-1 draw count correct per seat) - RecoveryOperationCollection.PlayHandCardOperation routes all type:30 through PlaySkillSelectHandCardOperation (skips the two-phase user-select guard that aborts targeted spells in recovery) - ShadowFeed + ToRawBody: server-generated typed bodies (DealBody, etc.) converted to RawBody before engine.Receive (`env.Body as RawBody` returned null for typed bodies) - Ready idxChangeSeed seeds A's XorShift via the receiver; B's seed is injected via SeedOppoIdxChange (BattleSeeds.IdxChange + viewerId) - ReadySpin defaulted to 0 (was 243) — non-zero double-cranks the shadow which ingests BOTH sides' Ready frames on one stream Test counts: SVSim.UnitTests 1054/1054, SVSim.BattleEngine.Tests 34/34. Open: known-residual Unity touches are individual whack-a-mole now (per-card skill edge cases), not the structural divergences fixed here. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
142 lines
6.5 KiB
C#
142 lines
6.5 KiB
C#
// AUTHORED SHIM (not copied). The battle View / UI / Touch / Replay / RoomMatch
|
|
// presentation tree the engine holds references to but never drives headless
|
|
// (IsForecast suppresses VFX; we never pump input or rendering). Stubbed in their
|
|
// ORIGINAL namespaces so the copied engine's type references resolve. Members grow
|
|
// only as the compile loop demands a specific call. Most are referenced as field/
|
|
// parameter types only, so empty stubs suffice.
|
|
|
|
namespace Wizard.Battle.View
|
|
{
|
|
public partial interface IReadOnlyVoiceInfo { }
|
|
public partial class BattleCardView
|
|
{
|
|
// BuildInfo (14-arg ctor + members) provided by Generated/BattleCardView_BuildInfo.g.cs
|
|
// Parameterless ctor lets the no-op subclass hand stubs (ClassBattleCardViewBase,
|
|
// NullBattleCardView) and any non-chaining stub satisfy their implicit base() call.
|
|
public BattleCardView() { }
|
|
public BattleCardView(BuildInfo buildInfo) { _buildInfo = buildInfo; }
|
|
|
|
// HEADLESS-FIX (M-HC-4a): the receive ATTACK path reads BattleCardView.CardInfo (the backing
|
|
// card) and BattleCardView._inPlayFrameEffect on the resolve path (InPlayCardReflection /
|
|
// ActionProcessor.Attack). The interface getters in Generated/_IfaceImpl.g.cs surface these two
|
|
// fields. CardInfo comes from the stored BuildInfo (cardInfo == the card, IReadOnlyBattleCardInfo,
|
|
// so IsClass etc. are authentic); _inPlayFrameEffect is a non-null no-op frame-effect control
|
|
// whose HideFrameEffect/UpdateCanAttackEffect are empty (Generated/InPlayCardFrameEffectControl.g.cs).
|
|
internal BuildInfo _buildInfo;
|
|
internal IReadOnlyBattleCardInfo HeadlessCardInfo => _buildInfo?.cardInfo;
|
|
internal InPlayCardFrameEffectControl _headlessInPlayFrameEffect =
|
|
new InPlayCardFrameEffectControl(null, null, null);
|
|
|
|
// AttackTargetSelectInfo provided by Generated/BattleCardView_AttackTargetSelectInfo.g.cs
|
|
//
|
|
// HEADLESS-FIX: lazily non-null GameObject so unguarded Unity touches on the IsRecovery
|
|
// path resolve as no-ops instead of NRE-ing on the shim's null default. Matches the
|
|
// existing Component.gameObject lazy pattern (UnityShim.cs:94). The IsRecovery card-create
|
|
// delegate (NetworkBattleManagerBase.cs:379) passes null for cardGameObject, which left
|
|
// BattleCardView.GameObject null and caused Skill_metamorphose.cs:147 (the in-play
|
|
// metamorphose branch — Petrification etc.) to NRE on
|
|
// `metamorphosedCard.BattleCardView.GameObject.transform.rotation = Quaternion.identity`,
|
|
// a purely cosmetic transform reset; making it a no-op preserves the surrounding state
|
|
// mutations (ReplaceInPlay, SetUpInplay, FlagCardAsDestroyedBySkill, RemoveFromInPlay).
|
|
// Live regression: bid 283192092460, A's Petrification on B's in-play card idx 1.
|
|
private UnityEngine.GameObject _gameObject;
|
|
public virtual UnityEngine.GameObject GameObject
|
|
{
|
|
get => _gameObject ??= new UnityEngine.GameObject();
|
|
protected set => _gameObject = value;
|
|
}
|
|
public HandCardFrameEffectControl HandFrameEffect { get; private set; }
|
|
public static HandParameter.IconLayout GetCurrentIconLayout() => default!;
|
|
}
|
|
public partial class NonDialogPopup : UnityEngine.MonoBehaviour { } // Close() in Generated/NonDialogPopup.g.cs
|
|
public abstract class BattlePlayerViewBase
|
|
{
|
|
public enum BattleDialogItem { Menu, Retire }
|
|
public static bool AlwaysShowStatusPanel => true;
|
|
public bool IsSelecting { get; set; }
|
|
}
|
|
public partial class InPlayCardFrameEffectControl { }
|
|
}
|
|
|
|
namespace Wizard.Battle.UI
|
|
{
|
|
public partial class BattleLogItem : UnityEngine.MonoBehaviour { }
|
|
public partial class BattleLogManager { }
|
|
public partial class BattleLogWindow : UnityEngine.MonoBehaviour
|
|
{
|
|
public enum BattleLogType { Battle, PlayCardLog, Destruction, Information }
|
|
public void HideCardListPanel() { }
|
|
}
|
|
public partial class AvatarBattleTitleItem : UnityEngine.MonoBehaviour { }
|
|
public partial class AvatarBattlePassiveBonusItem : UnityEngine.MonoBehaviour { }
|
|
public partial class AvatarBattleBonusItem : UnityEngine.MonoBehaviour { }
|
|
public partial class BossRushEnemySpecialSkillItem : UnityEngine.MonoBehaviour { }
|
|
public partial class MyRotationBonusItem : UnityEngine.MonoBehaviour { }
|
|
public partial class EvolutionConfirmation { }
|
|
}
|
|
|
|
namespace Wizard.Battle.Touch
|
|
{
|
|
public partial class SkillTargetSelectTouchProcessor { }
|
|
public partial class EvolutionTouchProcessor
|
|
{
|
|
// events dropped by m1_stub_gen (generator does not capture `event` decls)
|
|
public event global::System.Func<BattleCardBase, global::Wizard.Battle.View.Vfx.VfxBase> OnFocusTarget;
|
|
public event global::System.Func<BattleCardBase, global::Wizard.Battle.View.Vfx.VfxBase> OnUnfocusTarget;
|
|
public event global::System.Func<BattleCardBase, global::Wizard.Battle.View.Vfx.VfxBase> OnSelectTarget;
|
|
public event global::System.Action OnNotSelectTarget;
|
|
}
|
|
public partial class SetCardProcessor { }
|
|
public partial class EvolutionSimpleProcessor { }
|
|
public partial class EmotionTouchProcessor { }
|
|
public partial class DetailPanelTouchProcessor { }
|
|
public partial class ClassBuffTouchProcessor { }
|
|
}
|
|
|
|
namespace Wizard.Battle.Replay
|
|
{
|
|
public interface IReplayRecordManager
|
|
{
|
|
void SetupRecording(BattleManagerBase battleMgr);
|
|
void SetupBattleInfoFilter();
|
|
void SetupOperateMgrEvents(BattleManagerBase battleMgr);
|
|
}
|
|
public class NetworkBattleReplayOperationRecorder
|
|
{
|
|
public class RecordBattleLogParameter { }
|
|
}
|
|
}
|
|
|
|
namespace Wizard.Replay
|
|
{
|
|
public partial class ReplayController { }
|
|
}
|
|
|
|
namespace Wizard.RoomMatch
|
|
{
|
|
public partial class WatchDataHandler { }
|
|
// RoomConnectController (members + BattleRule/PositionMode enums + InitializeParameter)
|
|
// provided by Generated/RoomConnectController*.g.cs
|
|
}
|
|
|
|
namespace Wizard.Story
|
|
{
|
|
public class StoryRecoveryData
|
|
{
|
|
public StoryRecoveryData(LitJson.JsonData jsonData) { }
|
|
public StoryRecoveryData(SelectedStoryInfo data) { }
|
|
public int ChapterCharaId { get; }
|
|
public LitJson.JsonData ToJsonData() => default!;
|
|
}
|
|
}
|
|
|
|
namespace Wizard.UI.Common
|
|
{
|
|
public partial class TabList : UnityEngine.MonoBehaviour { }
|
|
}
|
|
|
|
namespace Wizard.UI.Dialog.ImageSelection
|
|
{
|
|
public partial class ImageSelection : UnityEngine.MonoBehaviour { }
|
|
}
|