Files
SVSimServer/SVSim.BattleEngine/Engine/NetworkBattleData.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

102 lines
2.7 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Wizard;
public class NetworkBattleData
{
protected NetworkBattleManagerBase _battleMgr;
public bool isEnemyFirstTurn;
protected NetworkBattleReceiver.ReceiveData receiveData;
public bool isReceiveTurnEndAction;
public bool isOppoMulliganEnd;
public bool isPlayerMulliganEnd;
public bool isEchoWait;
public NetworkBattleDefine.NetworkBattleURI nowReceiveUri;
public NetworkBattleData(NetworkBattleManagerBase battleMgr)
{
_battleMgr = battleMgr;
}
public void SetReceiveData(NetworkBattleReceiver.ReceiveData data)
{
receiveData = data;
}
public NetworkBattleReceiver.ReceiveData GetReceiveData()
{
return receiveData;
}
public virtual void BeforeSettingReceiveData()
{
ReplaceReceivedCards(receiveData.knownCardList);
List<CardDataModel> cardList = receiveData.unapprovedList.Where((CardDataModel uCard) => uCard.fromState != NetworkBattleDefine.NetworkCardPlaceState.Deck || !uCard.ToStateList.Any((NetworkBattleDefine.NetworkCardPlaceState s) => s == NetworkBattleDefine.NetworkCardPlaceState.Banish) || !receiveData.knownCardList.Any((CardDataModel kCard) => kCard.Index == uCard.Index && kCard.IsOpen)).ToList();
ReplaceReceivedCards(cardList);
SetEnemyFirstTurn();
}
protected void SetEnemyFirstTurn()
{
if (receiveData.dataUri == NetworkBattleDefine.NetworkBattleURI.Ready && ToolboxGame.RealTimeNetworkAgent.GetIsFirstPlayer() == 1)
{
isEnemyFirstTurn = true;
}
}
private void ReplaceReceivedCards(List<CardDataModel> cardList)
{
List<BattleCardBase> list = new List<BattleCardBase>();
foreach (CardDataModel card in cardList)
{
ReplaceReceivedCard replaceReceivedCard = CreateReplaceReceivedCard(card);
if (card.CardId == 0)
{
if (card.isOpponent)
{
replaceReceivedCard.SetPrivateCardSpellboost(_battleMgr.BattleEnemy);
}
}
else
{
list.Add(replaceReceivedCard.ReplaceCard(_battleMgr.BattleEnemy));
}
}
if (!_battleMgr.IsRecovery && list.Count > 0)
{
_battleMgr.VfxMgr.RegisterSequentialVfx(_battleMgr.LoadCardResources(list));
}
}
protected virtual ReplaceReceivedCard CreateReplaceReceivedCard(CardDataModel cardData)
{
return new ReplaceReceivedCard(_battleMgr, cardData);
}
public void AfterSettingReceiveData()
{
nowReceiveUri = receiveData.dataUri;
if (receiveData.dataUri == NetworkBattleDefine.NetworkBattleURI.TurnStart)
{
isEnemyFirstTurn = false;
}
}
public CardDataModel GetPlayCard()
{
return receiveData.knownCardList.FirstOrDefault((CardDataModel c) => c.Index == receiveData.playCardIndex);
}
public int GetPlayCardIndex()
{
return receiveData.playCardIndex;
}
}