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 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 _selfInfo = new Dictionary(); private Dictionary _oppoInfo = new Dictionary(); private List _selfDeck; private List _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 _selfFirstCards { get; set; } public List _oppoFirstCards { get; set; } public NetworkUserInfoData() { TurnState = -1; } public void InitializeSelfInfo() { SelfBattleStartInfo = null; _selfDeck = null; } public void SetSelfInfo(Dictionary 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 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 deckDatas) { if (GameMgr.GetIns().IsReplayBattle || !GameMgr.GetIns().IsWatchBattle) { int deckMaxNum = GetDeckMaxNum(isSelf: true); _selfDeck = new List(deckMaxNum); List list = new List(); for (int i = 0; i < deckMaxNum; i++) { CardDataModel cardDataModel = new CardDataModel(); Dictionary dictionary = deckDatas[i] as Dictionary; 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 deckDatas) { int deckMaxNum = GetDeckMaxNum(isSelf: false); _oppoDeck = new List(deckMaxNum); for (int i = 0; i < deckMaxNum; i++) { CardDataModel cardDataModel = new CardDataModel(); Dictionary dictionary = deckDatas[i] as Dictionary; 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 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 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 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 GetSelfDeck() { if (GameMgr.GetIns().IsWatchBattle && _selfDeck == null) { int deckMaxNum = GetDeckMaxNum(isSelf: true); _selfDeck = IdListConvertToModelList(Enumerable.Repeat(100011010, deckMaxNum).ToList()); } return _selfDeck; } public List GetOpponentDeck() { if (_oppoDeck == null) { int deckMaxNum = GetDeckMaxNum(isSelf: false); _oppoDeck = IdListConvertToModelList(Enumerable.Repeat(100011010, deckMaxNum).ToList()); } return _oppoDeck; } private List IdListConvertToModelList(List idList) { List list = new List(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 list = new List(); 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)); } } }