Files
SVSimServer/SVSim.BattleEngine/Engine/NetworkUserInfoData.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

533 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Wizard;
public class NetworkUserInfoData
{
public class NetworkUserInfo
{
public int Rank { get; private set; }
public bool IsMasterRank { get; private set; }
public int BattlePoint { get; private set; }
public int MasterPoint { get; private set; }
public int ClassId { get; private set; }
public int SubClassId { get; private set; } = 10;
public int CharaId { get; private set; }
public string MyRotationId { get; private set; } = "";
public string AvatarBattleId { get; private set; } = "";
public void SetParameter(Dictionary<string, object> info)
{
Rank = Convert.ToInt32(info["rank"]);
IsMasterRank = info.ContainsKey("isMasterRank") && Convert.ToInt32(info["isMasterRank"]) != 0;
BattlePoint = (info.ContainsKey("battlePoint") ? Convert.ToInt32(info["battlePoint"]) : 0);
MasterPoint = (info.ContainsKey("masterPoint") ? Convert.ToInt32(info["masterPoint"]) : 0);
ClassId = Convert.ToInt32(info["classId"]);
if (info.ContainsKey("subclassId"))
{
SubClassId = Convert.ToInt32(info["subclassId"]);
}
CharaId = Convert.ToInt32(info["charaId"]);
if (info.ContainsKey("rotationId"))
{
MyRotationId = Convert.ToString(info["rotationId"]);
}
AvatarBattleId = info["charaId"].ToString();
}
}
private Dictionary<string, object> _selfInfo = new Dictionary<string, object>();
private Dictionary<string, object> _oppoInfo = new Dictionary<string, object>();
private List<CardDataModel> _selfDeck;
private List<CardDataModel> _oppoDeck;
public const int DUMMY_CARD_ID = 100011010;
public const string KEY_IS_OFFICIAL_USER = "isOfficial";
private const string KEY_OPPO_DECK_COUNT = "oppoDeckCount";
public const string KEY_DECK_COUNT = "deckCount";
public int TurnState { get; set; }
public NetworkUserInfo SelfBattleStartInfo { get; private set; }
public NetworkUserInfo OppoBattleStartInfo { get; private set; }
public List<CardDataModel> _selfFirstCards { get; set; }
public List<CardDataModel> _oppoFirstCards { get; set; }
public NetworkUserInfoData()
{
TurnState = -1;
}
public void InitializeSelfInfo()
{
SelfBattleStartInfo = null;
_selfDeck = null;
}
public void SetSelfInfo(Dictionary<string, object> info, bool isWatchReplayRecovery)
{
_selfInfo = info;
if (isWatchReplayRecovery)
{
SetNetworkSelfInfo(info);
}
if (_selfInfo != null && _selfInfo.ContainsKey("seed"))
{
LocalLog.AccumulateLastTraceLog("SetSelfInfo seed" + Convert.ToInt32(_selfInfo["seed"]));
}
}
public void SetNetworkSelfInfo(Dictionary<string, object> info)
{
if (SelfBattleStartInfo == null)
{
SelfBattleStartInfo = new NetworkUserInfo();
}
SelfBattleStartInfo.SetParameter(info);
GameMgr.GetIns().GetDataMgr().SetPlayerCharaId(GetSelfCharaId());
GameMgr.GetIns().GetDataMgr().SetPlayerSubClassID(GetSelfSubClassId());
GameMgr.GetIns().GetDataMgr().SetPlayerMyRotationInfo(GetSelfMyRotationId());
GameMgr.GetIns().GetDataMgr().SetPlayerAvatarBattleInfo(GetSelfAvatarBattleId());
Data.RoomTwoPickBeforeBattleInfo.ReceiveBackDraftCharaId(GetSelfCharaId());
if (_selfInfo != null && _selfInfo.ContainsKey("seed"))
{
LocalLog.AccumulateLastTraceLog("SetNetworkSelfInfo seed" + Convert.ToInt32(_selfInfo["seed"]));
}
}
private int GetDeckMaxNum(bool isSelf)
{
if (isSelf && _selfInfo.ContainsKey("deckCount"))
{
return Convert.ToInt32(_selfInfo["deckCount"]);
}
if (!isSelf && _oppoInfo.ContainsKey("deckCount"))
{
return Convert.ToInt32(_oppoInfo["deckCount"]);
}
return GameMgr.GetIns().GetDataMgr().GetDeckMaxCount(isSelf);
}
public void SetSelfDeck(List<object> deckDatas)
{
if (GameMgr.GetIns().IsReplayBattle || !GameMgr.GetIns().IsWatchBattle)
{
int deckMaxNum = GetDeckMaxNum(isSelf: true);
_selfDeck = new List<CardDataModel>(deckMaxNum);
List<int> list = new List<int>();
for (int i = 0; i < deckMaxNum; i++)
{
CardDataModel cardDataModel = new CardDataModel();
Dictionary<string, object> dictionary = deckDatas[i] as Dictionary<string, object>;
cardDataModel.Index = Convert.ToInt32(dictionary[NetworkBattleDefine.NetworkParameter.idx.ToString()]);
cardDataModel.CardId = Convert.ToInt32(dictionary[NetworkBattleDefine.NetworkParameter.cardId.ToString()]);
_selfDeck.Add(cardDataModel);
list.Add(cardDataModel.CardId);
}
Data.RoomTwoPickBeforeBattleInfo.ReceiveBackDraftCardIdList(list);
}
}
public void SetOppoDeck(List<object> deckDatas)
{
int deckMaxNum = GetDeckMaxNum(isSelf: false);
_oppoDeck = new List<CardDataModel>(deckMaxNum);
for (int i = 0; i < deckMaxNum; i++)
{
CardDataModel cardDataModel = new CardDataModel();
Dictionary<string, object> dictionary = deckDatas[i] as Dictionary<string, object>;
cardDataModel.Index = Convert.ToInt32(dictionary[NetworkBattleDefine.NetworkParameter.idx.ToString()]);
cardDataModel.CardId = Convert.ToInt32(dictionary[NetworkBattleDefine.NetworkParameter.cardId.ToString()]);
_oppoDeck.Add(cardDataModel);
}
}
public void SetOpponentInfo(Dictionary<string, object> info, bool isWatchReplayRecovery)
{
OppoBattleStartInfo = null;
if (!GameMgr.GetIns().IsWatchBattle && !GameMgr.GetIns().IsReplayBattle)
{
_oppoDeck = null;
}
_oppoInfo = info;
if (isWatchReplayRecovery)
{
SetOpponentNetworkInfo(info);
}
if (_oppoInfo.Keys.Contains("oppoDeckCount"))
{
GameMgr.GetIns().GetDataMgr().SetDeckMaxCount(Convert.ToInt32(_oppoInfo["oppoDeckCount"]), isSelf: false);
}
}
public void SetOpponentNetworkInfo(Dictionary<string, object> info)
{
OppoBattleStartInfo = new NetworkUserInfo();
OppoBattleStartInfo.SetParameter(info);
}
public int GetFieldId()
{
return Convert.ToInt32(_selfInfo["fieldId"]);
}
public int GetRandomSeed()
{
if (_selfInfo == null || !_selfInfo.ContainsKey("seed"))
{
string text = "NotSeed ";
text = text + ((_selfInfo == null) ? "infoNull" : "noneKey") + " ";
if (_selfInfo != null)
{
foreach (KeyValuePair<string, object> item in _selfInfo)
{
text = text + item.Key + ":" + item.Value?.ToString() + " ";
}
}
LocalLog.AccumulateLastTraceLog(text);
return 0;
}
return Convert.ToInt32(_selfInfo["seed"]);
}
public int GetSelfViewerId()
{
return Convert.ToInt32(_selfInfo["viewerId"]);
}
public string GetSelfName()
{
return _selfInfo["userName"].ToString();
}
public int GetSelfBattlePoint()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.BattlePoint;
}
public int GetSelfMasterPoint()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.MasterPoint;
}
public int GetSelfClassId()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.ClassId;
}
public int GetSelfSubClassId()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.SubClassId;
}
public int GetSelfCharaId()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.CharaId;
}
public string GetSelfMyRotationId()
{
if (SelfBattleStartInfo == null)
{
return "";
}
return SelfBattleStartInfo.MyRotationId;
}
public string GetSelfAvatarBattleId()
{
if (SelfBattleStartInfo == null)
{
return "";
}
return SelfBattleStartInfo.AvatarBattleId;
}
public long GetSelfSleeveId()
{
return Convert.ToInt64(_selfInfo["sleeveId"]);
}
public long GetSelfEmblemId()
{
return Convert.ToInt64(_selfInfo["emblemId"]);
}
public int GetSelfDegreeId()
{
return Convert.ToInt32(_selfInfo["degreeId"]);
}
public int GetSelfRank()
{
if (SelfBattleStartInfo == null)
{
return 0;
}
return SelfBattleStartInfo.Rank;
}
public string GetSelfCountryCode()
{
return _selfInfo["country_code"].ToString();
}
public bool GetSelfIsOfficialUser()
{
return Convert.ToBoolean(_selfInfo["isOfficial"]);
}
public int GetSelfChaosId()
{
if (!GameMgr.GetIns().IsNetworkBattle && !GameMgr.GetIns().IsReplayBattle)
{
return -1;
}
if (_selfInfo.ContainsKey("chaosId"))
{
return Convert.ToInt32(_selfInfo["chaosId"]);
}
return -1;
}
public string GetOpponentName()
{
return _oppoInfo["userName"].ToString();
}
public int GetOpponentBattlePoint()
{
if (OppoBattleStartInfo == null)
{
return 0;
}
return OppoBattleStartInfo.BattlePoint;
}
public int GetOpponentMasterPoint()
{
if (OppoBattleStartInfo == null)
{
return 0;
}
return OppoBattleStartInfo.MasterPoint;
}
public int GetOpponentClassId()
{
if (OppoBattleStartInfo == null)
{
return 0;
}
return OppoBattleStartInfo.ClassId;
}
public int GetOpponentSubClassId()
{
if (OppoBattleStartInfo == null)
{
return 10;
}
return OppoBattleStartInfo.SubClassId;
}
public int GetOpponentCharaId()
{
if (OppoBattleStartInfo == null)
{
return 0;
}
return OppoBattleStartInfo.CharaId;
}
public string GetOpponentMyRotationId()
{
if (OppoBattleStartInfo == null)
{
return "";
}
return OppoBattleStartInfo.MyRotationId;
}
public string GetOpponentAvatarBattleId()
{
if (SelfBattleStartInfo == null)
{
return "";
}
return OppoBattleStartInfo.AvatarBattleId;
}
public long GetOpponentSleeveId()
{
return Convert.ToInt64(_oppoInfo["sleeveId"]);
}
public long GetOpponentEmblemId()
{
return Convert.ToInt64(_oppoInfo["emblemId"]);
}
public int GetOpponentDegreeId()
{
return Convert.ToInt32(_oppoInfo["degreeId"]);
}
public int GetOpponentRank()
{
if (OppoBattleStartInfo == null)
{
return 0;
}
return OppoBattleStartInfo.Rank;
}
public int GetOpponentUserID()
{
if (GameMgr.GetIns().IsWatchBattle)
{
return Convert.ToInt32(_oppoInfo["viewerId"]);
}
return Convert.ToInt32(_selfInfo["oppoId"]);
}
public bool GetOpponentIsMasterRank()
{
if (OppoBattleStartInfo == null)
{
return false;
}
return OppoBattleStartInfo.IsMasterRank;
}
public string GetOpponentCountryCode()
{
return _oppoInfo["country_code"].ToString();
}
public bool GetOpponentIsOfficialUser()
{
return Convert.ToBoolean(_oppoInfo["isOfficial"]);
}
public int GetOpponentChaosId()
{
if (!GameMgr.GetIns().IsNetworkBattle && !GameMgr.GetIns().IsReplayBattle)
{
return -1;
}
if (_oppoInfo.ContainsKey("chaosId"))
{
return Convert.ToInt32(_oppoInfo["chaosId"]);
}
return -1;
}
public bool GetOpponentChaosOverrideSkin()
{
if (!GameMgr.GetIns().IsNetworkBattle && !GameMgr.GetIns().IsReplayBattle)
{
return false;
}
if (_oppoInfo.ContainsKey("isChaosSkinOverride"))
{
return Convert.ToBoolean(_oppoInfo["isChaosSkinOverride"]);
}
return false;
}
public List<CardDataModel> GetSelfDeck()
{
if (GameMgr.GetIns().IsWatchBattle && _selfDeck == null)
{
int deckMaxNum = GetDeckMaxNum(isSelf: true);
_selfDeck = IdListConvertToModelList(Enumerable.Repeat(100011010, deckMaxNum).ToList());
}
return _selfDeck;
}
public List<CardDataModel> GetOpponentDeck()
{
if (_oppoDeck == null)
{
int deckMaxNum = GetDeckMaxNum(isSelf: false);
_oppoDeck = IdListConvertToModelList(Enumerable.Repeat(100011010, deckMaxNum).ToList());
}
return _oppoDeck;
}
private List<CardDataModel> IdListConvertToModelList(List<int> idList)
{
List<CardDataModel> list = new List<CardDataModel>(idList.Count);
for (int i = 0; i < idList.Count; i++)
{
CardDataModel cardDataModel = new CardDataModel();
cardDataModel.Index = i + 1;
cardDataModel.CardId = idList[i];
list.Add(cardDataModel);
}
return list;
}
public void ReplaceFirstCardData()
{
List<BattleCardBase> list = new List<BattleCardBase>();
NetworkBattleManagerBase networkBattleManagerBase = BattleManagerBase.GetIns() as NetworkBattleManagerBase;
for (int i = 0; i < _selfFirstCards.Count; i++)
{
ReplaceReceivedCard replaceReceivedCard = new ReplaceReceivedCard(networkBattleManagerBase, _selfFirstCards[i]);
list.Add(replaceReceivedCard.ReplaceCard(networkBattleManagerBase.BattlePlayer));
}
if (GameMgr.GetIns().IsAdmin)
{
for (int j = 0; j < _oppoFirstCards.Count; j++)
{
ReplaceReceivedCard replaceReceivedCard2 = new ReplaceReceivedCard(networkBattleManagerBase, _oppoFirstCards[j]);
list.Add(replaceReceivedCard2.ReplaceCard(networkBattleManagerBase.BattleEnemy));
}
}
if (!networkBattleManagerBase.IsRecovery && list.Count > 0)
{
networkBattleManagerBase.VfxMgr.RegisterSequentialVfx(networkBattleManagerBase.LoadCardResources(list));
}
}
}