using System;
using System.Collections.Generic;
using System.Linq;
using Cute;
using LitJson;
using Wizard;
using Wizard.AutoTest;
using Wizard.Battle.Recovery;

public class DataMgr
{
	public enum SpecialBattleResultType
	{
		None,
		Belphomet,
		Nerva
	}

	public class SpecialBattleSetting
	{
		public string Id { get; private set; }

		public bool? IsPlayerFirstTurn { get; private set; }

		public string PlayerAttachSkillText { get; private set; }

		public string[] PlayerAttachSkills { get; private set; }

		public string EnemyAttachSkillText { get; private set; }

		public string[] EnemyAttachSkills { get; private set; }

		public int PlayerStartPp { get; private set; }

		public int EnemyStartPp { get; private set; }

		public int PlayerStartLife { get; set; }

		public int PlayerStartMaxLife { get; private set; }

		public int EnemyStartMaxLife { get; private set; }

		public string IdOverrideInBattleLogText { get; private set; }

		public Dictionary<int, int> IdOverridePairDict { get; private set; }

		public string BanishEffectOverRideText { get; private set; }

		public string[] BanishEffectOverRideIds { get; private set; }

		public string TokenDrawEffectOverrideText { get; private set; }

		public Dictionary<int, string> TokenDrawOverrideEffectPair { get; private set; }

		public string SpecialTokenDrawEffectOverrideText { get; private set; }

		public Dictionary<int, string> SpecialTokenDrawOverrideEffectPair { get; private set; }

		public bool IsVsEffectOverride { get; private set; }

		public int ClassDestroyEffectOverride { get; private set; }

		public SpecialBattleSetting(string id, bool? isPlayerFirst, string playerSkill, string enemySkill, int playerPp, int enemyPp, int playerLife, int playerMaxLife, int enemyMaxLife, string idOverrideBattleLogText, string banishEffectOverride, string tokenDrawEffectOverride, string specialTokenDrawEffectOverride, bool isVsEffectOverride, int classDestroyEffectOverride)
		{
			Id = id;
			IsPlayerFirstTurn = isPlayerFirst;
			PlayerAttachSkillText = playerSkill;
			PlayerAttachSkills = SplitSpecialBattleDataText(PlayerAttachSkillText);
			EnemyAttachSkillText = enemySkill;
			EnemyAttachSkills = SplitSpecialBattleDataText(EnemyAttachSkillText);
			PlayerStartPp = playerPp;
			EnemyStartPp = enemyPp;
			PlayerStartLife = playerLife;
			PlayerStartMaxLife = playerMaxLife;
			EnemyStartMaxLife = enemyMaxLife;
			IdOverrideInBattleLogText = idOverrideBattleLogText;
			IdOverridePairDict = ParseIdOverrideText(IdOverrideInBattleLogText);
			BanishEffectOverRideText = banishEffectOverride;
			BanishEffectOverRideIds = SplitSpecialBattleDataText(BanishEffectOverRideText);
			TokenDrawEffectOverrideText = tokenDrawEffectOverride;
			TokenDrawOverrideEffectPair = SplitSpecialBattleDataPair(TokenDrawEffectOverrideText);
			SpecialTokenDrawEffectOverrideText = specialTokenDrawEffectOverride;
			SpecialTokenDrawOverrideEffectPair = SplitSpecialBattleDataPair(SpecialTokenDrawEffectOverrideText);
			IsVsEffectOverride = isVsEffectOverride;
			ClassDestroyEffectOverride = classDestroyEffectOverride;
		}
	}

	public enum BattleType
	{
		FreeBattle = 0,
		RankBattle = 1,
		TwoPick = 2,
		RoomBattle = 3,
		Story = 4,
		Practice = 5,
		RoomTwoPick = 6,
		TwoPickBackdraft = 7,
		ColosseumNormal = 8,
		ColosseumTwoPick = 9,
		ColosseumHof = 31,
		Sealed = 32,
		ColosseumWindFall = 33,
		Gathering = 34,
		Quest = 37,
		OfflineEvent = 40,
		CompetitionNormal = 42,
		BossRushQuest = 45,
		SecretBossQuest = 46,
		CompetitionTwoPick = 47,
		Avatar = 48,
		ColosseumAvatar = 49,
		None = 100
	}

	private int _selectDeckId;

	private Format _selectDeckFormat;

	private IList<int> _currentDeckCardIdList;

	private int _deckMaxCardCount;

	private int _enemyDeckMaxCardCount;

	private IList<int> _currentEnemyDeckData;

	private int _playerCharaId;

	private int _playerSubClassId;

	private long _playerSleeveId;

	private string _playerEmotionId = "";

	private int _enemyCharaId;

	private int _enemySubClassId;

	private long _enemySleeveId;

	private string _enemyEmotionId = "";

	public AIDataLibrary m_AIDataLibrary;

	private int _soroPlay3DFieldId = 1;

	private string _storyBgmId = "NONE";

	public int m_EnemyAIDifficulty;

	public int m_EnemyAILogicLevel;

	public int m_EnemyAIDeckId;

	public int m_EnemyAIStyleId;

	public int m_EnemyAIEmoteId;

	public int m_EnemyAIMaxLife;

	public bool m_EnemyAIUseInnerEmote = true;

	private IDictionary<int, int> _possessionCardDict;

	private IDictionary<int, int> _possessionCardDictIncludingSpotCard;

	private IDictionary<int, bool> _isNewCardDict = new Dictionary<int, bool>();

	private int[] _maintenanceCardIds;

	private IDictionary<int, ClassCharaPrm> _classPrmDict;

	private bool _isDirtyPossessionCardDict;

	public const int PRACTICE_DIFFICULTY_DEGREE_EASY = 400001;

	public BattleType m_BattleType = BattleType.None;

	public TwoPickFormat TwoPickFormat;

	public string BattleId = "";

	private static string[] ClanNameTextIdList = new string[9] { "Common_0104", "Common_0105", "Common_0106", "Common_0107", "Common_0108", "Common_0109", "Common_0110", "Common_0111", "Common_0112" };

	public static readonly string[] TribeNameTextIdList = new string[18]
	{
		"TN_ALL", "TN_指揮官", "TN_兵士", "TN_土の印", "TN_マナリア", "TN_アーティファクト", "TN_財宝", "TN_機械", "TN_料理", "TN_レヴィオン",
		"TN_自然", "TN_宴楽", "TN_ヒーロー", "TN_武装", "TN_チェス", "TN_八獄", "TN_学園", ""
	};

	public DeckAttributeType LastSelectDeckAttributeType { private get; set; }

	public int PracticeDifficultyDegreeId { get; set; }

	public int Practice3DfieldId { get; set; }

	public DeckData _roomTwoPickDeckData { get; set; }

	public List<int> FavoriteCardList { get; private set; }

	public DeckGroupListData CurrentDeckListParamData { get; set; }

	public SpecialBattleSetting SpecialBattleSettingInfo { get; set; }

	public BattleManagerBase.MissionNecessaryInformation MissionNecessaryInformation { get; set; } = new BattleManagerBase.MissionNecessaryInformation(new Dictionary<string, string>());

	private MyRotationInfo _playerMyRotationInfo { get; set; }

	private MyRotationInfo _enemyMyRotationInfo { get; set; }

	private AvatarBattleInfo _playerAvatarBattleInfo { get; set; }

	private AvatarBattleInfo _enemyAvatarBattleInfo { get; set; }

	public QuestBattleData QuestBattleData { get; private set; }

	public BossRushBattleData BossRushBattleData { get; private set; }

	public int PracticePuzzleGroupId { get; set; }

	public int PuzzleQuestId { get; set; }

	public int PuzzleDifficulty { get; set; }

	public int PuzzleEnemyClass { get; set; }

	public QuestSelectionPage.FirstSelectType QuestFirstSelectType { get; set; }

	public int StoryEnemyClassId { get; set; }

	public JsonData RecoveryData { get; private set; }

	public SpecialBattleResultType SkipStorySpecialBattleResult { get; private set; }

	public SpotCardData SpotCardData { get; set; }

	public string TitleId { get; set; } = "0";

	public bool IsLastSelectDeckAttributeType(DeckAttributeType deckAttributeType)
	{
		return deckAttributeType == LastSelectDeckAttributeType;
	}

	public void SetMissionNecessaryInformation(JsonData data)
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		if (data.Count > 0)
		{
			foreach (string key in data.Keys)
			{
				dictionary.Add(key, data.ToStringOrDefault(key, string.Empty));
			}
		}
		MissionNecessaryInformation = new BattleManagerBase.MissionNecessaryInformation(dictionary);
	}

	public void SetQuestBattleData(QuestBattleData battleData)
	{
		QuestBattleData = battleData;
	}

	public void SetBossRushBattleData(BossRushBattleData battleData)
	{
		BossRushBattleData = battleData;
	}

	public void SetRecoveryData(JsonData recoveryData)
	{
		RecoveryData = recoveryData;
	}

	public void CacheSingleRecovryData()
	{
		if (RecoveryRecordManagerBase.IsExistsSingleRecoveryFile())
		{
			RecoveryData = RecoveryOperationInfo.ReadRecoveryFile(OperationRecorderBase.RecordDirectoryPath + "recovery_single.json");
		}
	}

	public static bool IsNetworkBattleType(BattleType battleType)
	{
		switch (battleType)
		{
		case BattleType.FreeBattle:
		case BattleType.RankBattle:
		case BattleType.TwoPick:
		case BattleType.RoomBattle:
		case BattleType.RoomTwoPick:
		case BattleType.TwoPickBackdraft:
		case BattleType.ColosseumNormal:
		case BattleType.ColosseumTwoPick:
		case BattleType.ColosseumHof:
		case BattleType.Sealed:
		case BattleType.ColosseumWindFall:
		case BattleType.Gathering:
		case BattleType.CompetitionNormal:
		case BattleType.CompetitionTwoPick:
			return true;
		default:
			return false;
		}
	}

	public bool IsColosseumBattleType()
	{
		BattleType battleType = m_BattleType;
		if ((uint)(battleType - 8) <= 1u || battleType == BattleType.ColosseumHof || battleType == BattleType.ColosseumWindFall)
		{
			return true;
		}
		return false;
	}

	public bool IsCompetitionBattleType()
	{
		BattleType battleType = m_BattleType;
		if (battleType == BattleType.CompetitionNormal || battleType == BattleType.CompetitionTwoPick)
		{
			return true;
		}
		return false;
	}

	public static bool IsTwoPickBattleType(BattleType battleType)
	{
		switch (battleType)
		{
		case BattleType.TwoPick:
		case BattleType.RoomTwoPick:
		case BattleType.TwoPickBackdraft:
		case BattleType.ColosseumTwoPick:
		case BattleType.CompetitionTwoPick:
			return true;
		default:
			return false;
		}
	}

	public static bool IsEnableFormatIconBattleType(BattleType battleType)
	{
		switch (battleType)
		{
		case BattleType.FreeBattle:
		case BattleType.RankBattle:
		case BattleType.RoomBattle:
		case BattleType.ColosseumNormal:
		case BattleType.CompetitionNormal:
			return true;
		default:
			return false;
		}
	}

	public bool IsDipslayHighRankFormat()
	{
		switch (m_BattleType)
		{
		case BattleType.TwoPick:
		case BattleType.Story:
		case BattleType.Practice:
		case BattleType.RoomTwoPick:
		case BattleType.TwoPickBackdraft:
		case BattleType.ColosseumTwoPick:
		case BattleType.ColosseumHof:
		case BattleType.Sealed:
		case BattleType.ColosseumWindFall:
		case BattleType.Quest:
		case BattleType.BossRushQuest:
		case BattleType.SecretBossQuest:
		case BattleType.CompetitionTwoPick:
		case BattleType.Avatar:
			return true;
		default:
			if (Data.CurrentFormat != Format.Max && Data.CurrentFormat != Format.Windfall && Data.CurrentFormat != Format.MyRotation)
			{
				return Data.CurrentFormat == Format.Avatar;
			}
			return true;
		}
	}

	public bool IsTwoPickBattleType()
	{
		return IsTwoPickBattleType(m_BattleType);
	}

	public bool IsQuestBattleType()
	{
		return IsQuestBattleType(m_BattleType);
	}

	public static bool IsQuestBattleType(BattleType battleType)
	{
		if (battleType == BattleType.Quest || (uint)(battleType - 45) <= 1u)
		{
			return true;
		}
		return false;
	}

	public bool IsFormatEnableBattleType()
	{
		switch (m_BattleType)
		{
		case BattleType.TwoPick:
		case BattleType.Story:
		case BattleType.Practice:
		case BattleType.ColosseumTwoPick:
		case BattleType.ColosseumHof:
		case BattleType.Sealed:
		case BattleType.ColosseumWindFall:
		case BattleType.Quest:
		case BattleType.BossRushQuest:
		case BattleType.SecretBossQuest:
			return false;
		default:
			if (Data.CurrentFormat == Format.Avatar)
			{
				return false;
			}
			if (IsTwoPickBattleType() || Data.CurrentFormat == Format.Max || Data.CurrentFormat == Format.PreRotation || Data.CurrentFormat == Format.Windfall || Data.CurrentFormat == Format.MyRotation || Data.CurrentFormat == Format.TwoPick)
			{
				return false;
			}
			return true;
		}
	}

	public bool IsRoomBattleType()
	{
		BattleType battleType = m_BattleType;
		if (battleType == BattleType.RoomBattle || (uint)(battleType - 6) <= 1u)
		{
			return true;
		}
		return false;
	}

	public static bool IsSingleBattleType(BattleType battleType)
	{
		if ((uint)(battleType - 4) <= 1u || battleType == BattleType.Quest || (uint)(battleType - 45) <= 1u)
		{
			return true;
		}
		return false;
	}

	public DataMgr()
	{
		_possessionCardDict = new Dictionary<int, int>();
		_possessionCardDictIncludingSpotCard = new Dictionary<int, int>();
		_maintenanceCardIds = null;
		m_AIDataLibrary = new AIDataLibrary();
		FavoriteCardList = new List<int>();
		PracticeDifficultyDegreeId = 400001;
	}

	public void PrintAIDataLibraryOnlyDebug()
	{
	}

	public void Load()
	{
		LoadClassData();
	}

	public void LoadEnemy()
	{
		LoadEnemyClassData();
	}

	public void LoadClassData()
	{
		if (_playerCharaId == 0)
		{
			SetPlayerCharaId(1);
		}
		SetPlayerSleeveId(_playerSleeveId);
	}

	public void ResetEnemyData()
	{
		_currentEnemyDeckData = null;
	}

	public void LoadEnemyClassData()
	{
		if (_enemyCharaId == 0)
		{
			SetEnemyCharaId(1);
		}
		SetEnemySleeveId(_enemySleeveId);
	}

	public void RegisterAICommonData()
	{
		for (int i = 0; i < Data.Master.AIBasicDataList.Set.Count; i++)
		{
			AICardDataAsset asset = Data.Master.AIBasicDataList.Set[i];
			m_AIDataLibrary.RegisterBasicData(asset);
		}
		for (int j = 0; j < Data.Master.AICommonDataList.Set.Count; j++)
		{
			AICardDataAsset asset2 = Data.Master.AICommonDataList.Set[j];
			m_AIDataLibrary.RegisterCommonData(asset2);
		}
		for (int k = 0; k < Data.Master.AIAllyCommonDataList.Set.Count; k++)
		{
			AICardDataAsset asset3 = Data.Master.AIAllyCommonDataList.Set[k];
			m_AIDataLibrary.RegisterAllyCommonData(asset3);
		}
		m_AIDataLibrary.RegisterCommonStyle(Data.Master.AIStyleCommonDataList);
	}

	public void RegisterAIDeckData()
	{
		if (Data.Master.AIDeckDic == null)
		{
			return;
		}
		foreach (KeyValuePair<string, AICardDataAssetSet> item in Data.Master.AIDeckDic)
		{
			m_AIDataLibrary.RegisterDeckToDeckDic(item.Key, item.Value.Set);
		}
	}

	public void RegisterAIStyleData()
	{
		foreach (KeyValuePair<string, List<AIPolicyDataAsset>> item in Data.Master.AIStyleDic)
		{
			m_AIDataLibrary.RegisterDeckStyle(item.Key, item.Value);
		}
	}

	public void RegisterAIEmoteData()
	{
		foreach (KeyValuePair<string, List<AIEmoteDataAsset>> item in Data.Master.AIEmoteDic)
		{
			AIEmoteSet aIEmoteSet = new AIEmoteSet();
			aIEmoteSet.CreateFromAsset(item.Value);
			m_AIDataLibrary.RegisterEmoteSet(item.Key, aIEmoteSet);
		}
	}

	public void RegisterAllAIData()
	{
		m_AIDataLibrary.Clear();
		RegisterAICommonData();
		RegisterAIDeckData();
		RegisterAIStyleData();
		RegisterAIEmoteData();
	}

	public void SetPlayerCharaId(int charaId)
	{
		_playerCharaId = charaId;
		SetPlayerSubClassID(10);
		SetPlayerMyRotationInfo("");
	}

	public void SetPlayerSubClassID(int subClassId)
	{
		_playerSubClassId = subClassId;
	}

	public void SetPlayerMyRotationInfo(string myRotationId)
	{
		_playerMyRotationInfo = Data.MyRotationAllInfo.Get(myRotationId);
	}

	public void SetPlayerAvatarBattleInfo(string id)
	{
		_playerAvatarBattleInfo = Data.AvatarBattleAllInfo.Get(id);
	}

	public void SetPlayerCharaIdByClassId(int classId, bool isCurrentChara = true)
	{
		SetPlayerCharaId(GetCharaPrmByClassId(classId, isCurrentChara).chara_id);
	}

	public void SetPlayerCharaIdBySkinId(int skinId)
	{
		SetPlayerCharaId(GetCharaPrmBySkinId(skinId).chara_id);
	}

	public void SetPlayerSleeveId(long sleeveId)
	{
		_playerSleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(GetAbleSleeveId(sleeveId));
	}

	public void SetEnemyCharaId(int charaId)
	{
		_enemyCharaId = charaId;
		SetEnemySubClassID(10);
		SetEnemyMyRotationInfo("");
	}

	public void SetEnemySubClassID(int classId)
	{
		_enemySubClassId = classId;
	}

	public void SetEnemyMyRotationInfo(string myRotationId)
	{
		_enemyMyRotationInfo = Data.MyRotationAllInfo.Get(myRotationId);
	}

	public void SetEnemyAvatarBattleInfo(string id)
	{
		_enemyAvatarBattleInfo = Data.AvatarBattleAllInfo.Get(id);
	}

	public void ClearEnemyAvatarBattleInfo()
	{
		_enemyAvatarBattleInfo = null;
	}

	public void SetEnemySleeveId(long sleeveId)
	{
		_enemySleeveId = Toolbox.ResourcesManager.GetExistingSleeveId(GetAbleSleeveId(sleeveId));
	}

	public bool GetSelectDefDeck()
	{
		if (_selectDeckId == 0)
		{
			return PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.LAST_BATTLE_IS_DEFDECK);
		}
		return IsLastSelectDeckAttributeType(DeckAttributeType.DefaultDeck);
	}

	public void SetSelectDeckId(int id)
	{
		_selectDeckId = id;
	}

	public void SetSelectDeckFormat(Format format)
	{
		_selectDeckFormat = format;
	}

	public Format GetSelectDeckFormat()
	{
		return _selectDeckFormat;
	}

	public void SetCurrentDeckData(IList<int> deckdata)
	{
		_currentDeckCardIdList = deckdata;
	}

	public void SetCurrentEnemyDeckData(IList<int> deckdata)
	{
		_currentEnemyDeckData = deckdata;
	}

	public void SetDeckMaxCount(int count, bool isSelf)
	{
		if (count != -1 && count != 0)
		{
			if (isSelf)
			{
				_deckMaxCardCount = count;
			}
			else
			{
				_enemyDeckMaxCardCount = count;
			}
		}
	}

	public void SetStoryAILogicAndDeckData(int classId, int enemyAiId)
	{
		StoryAISettingData settingData = Data.Master.StoryAISettingList.GetSettingData(enemyAiId);
		SetCurrentEnemyDeckDataFromAIDeck(classId, -1, settingData.LogicLevel, 20, settingData.DeckId, settingData.StyleId, settingData.EmoteId, settingData.UseInnerEmote, enemyAiId);
	}

	public void SetQuestAILogicAndDeckData(int classId, int enemyAiId)
	{
		StoryAISettingData settingData = Data.Master.QuestAISettingList.GetSettingData(enemyAiId);
		SetCurrentEnemyDeckDataFromAIDeck(classId, -1, settingData.LogicLevel, 20, settingData.DeckId, settingData.StyleId, settingData.EmoteId, settingData.UseInnerEmote, enemyAiId);
	}

	public void SetRankMatchAILogicAndDeckData(int enemyAiId)
	{
		RankMatchAISettingData settingData = Data.Master.RankMatchAISettingList.GetSettingData(enemyAiId);
		SetCurrentEnemyDeckDataFromAIDeck(settingData.ClassId, -1, 2, 20, settingData.DeckId, settingData.StyleId, -1, useInnerEmote: false, enemyAiId);
	}

	public void SetCurrentEnemyDeckDataFromAIDeck(int classID, int difficulty, int logicLevel, int maxLife, int deckId, int styleId, int emoteId, bool useInnerEmote, int enemyAiID = -1, List<int> specialAbilityIdList = null)
	{
		if (classID == 0)
		{
			classID = 8;
		}
		m_EnemyAIDifficulty = difficulty;
		m_EnemyAIDeckId = deckId;
		m_EnemyAIStyleId = styleId;
		m_EnemyAIEmoteId = emoteId;
		m_EnemyAILogicLevel = logicLevel;
		m_EnemyAIMaxLife = maxLife;
		m_EnemyAIUseInnerEmote = useInnerEmote;
		AITestGlobal.AI_MAX_LIFE = maxLife;
		AI_LOGIC_LV logicLv = AI_LOGIC_LV.STRONG;
		switch (logicLevel)
		{
		case 0:
			logicLv = AI_LOGIC_LV.WEAK;
			break;
		case 1:
			logicLv = AI_LOGIC_LV.MIDDLE;
			break;
		case 2:
			logicLv = AI_LOGIC_LV.STRONG;
			break;
		}
		string text = "ai/" + Data.Master.AIDeckFileNameList.GetFileName(deckId);
		string styleName = "ai/" + Data.Master.AIStyleFileNameList.GetFileName(styleId);
		string emoteName = "ai/" + Data.Master.AIEmoteFileNameList.GetFileName(emoteId);
		m_AIDataLibrary.SaveBattleSetUpInfo(classID, logicLv, text, styleName, emoteName, useEmote: true, useInnerEmote, enemyAiID, specialAbilityIdList);
		SetCurrentEnemyDeckDataFromAIDeck(text);
	}

	public void SetEnemyAIDeckFromCustomDeck(int classId, IList<int> deck, int difficulty = 2, int logicLevel = 2, int maxLife = 20, int styleId = 0, int emoteId = 0, bool useInnerEmote = true, int enemyAiID = -1)
	{
		m_EnemyAIDifficulty = difficulty;
		m_EnemyAIDeckId = int.MinValue;
		m_EnemyAIStyleId = styleId;
		m_EnemyAIEmoteId = emoteId;
		m_EnemyAILogicLevel = logicLevel;
		m_EnemyAIMaxLife = maxLife;
		m_EnemyAIUseInnerEmote = useInnerEmote;
		AITestGlobal.AI_MAX_LIFE = m_EnemyAIMaxLife;
		AI_LOGIC_LV logicLv = AI_LOGIC_LV.STRONG;
		switch (logicLevel)
		{
		case 0:
			logicLv = AI_LOGIC_LV.WEAK;
			break;
		case 1:
			logicLv = AI_LOGIC_LV.MIDDLE;
			break;
		case 2:
			logicLv = AI_LOGIC_LV.STRONG;
			break;
		}
		string styleName = "ai/" + Data.Master.AIStyleFileNameList.GetFileName(styleId);
		string emoteName = "ai/" + Data.Master.AIEmoteFileNameList.GetFileName(emoteId);
		m_AIDataLibrary.SaveBattleSetUpInfo(classId, logicLv, "", styleName, emoteName, useEmote: true, m_EnemyAIUseInnerEmote, enemyAiID, null);
		SetCurrentEnemyDeckData(deck);
	}

	public void SetCurrentEnemyDeckDataFromAIDeck(string deckName)
	{
		AIDeckData aIDeckData = m_AIDataLibrary.SearchDeckData(deckName);
		if (aIDeckData == null)
		{
			return;
		}
		_currentEnemyDeckData = new List<int>();
		foreach (KeyValuePair<int, AICardData> item in aIDeckData.CardDic)
		{
			for (int i = 0; i < item.Value.CardNum; i++)
			{
				_currentEnemyDeckData.Add(item.Key);
			}
		}
	}

	public void SetUserOwnCardData(IDictionary<int, int> userowncarddata)
	{
		_possessionCardDict = userowncarddata;
		SetDirtyPossessionCardDict();
	}

	public void SetClassPrm(JsonData userClassCharaList, JsonData userRankMatchList)
	{
		Dictionary<int, ClassCharaPrm> dictionary = new Dictionary<int, ClassCharaPrm>();
		for (int i = 0; i < userClassCharaList.Count; i++)
		{
			JsonData jsonData = userClassCharaList[i];
			int num = jsonData["class_id"].ToInt();
			if (num < 1 || 9 <= num)
			{
				continue;
			}
			ClassCharaPrm classCharaPrm = new ClassCharaPrm();
			classCharaPrm.SetParamWithUserClassJson(jsonData);
			for (int j = 0; j < userRankMatchList.Count; j++)
			{
				JsonData jsonData2 = userRankMatchList[j];
				if (jsonData2["class_id"].ToInt() == num)
				{
					classCharaPrm.SetClassCharaWin(jsonData2["win"].ToInt());
					classCharaPrm.SetClassCharaBattleCount(jsonData2["match_count"].ToInt());
				}
			}
			dictionary.Add(num, classCharaPrm);
		}
		_classPrmDict = dictionary;
	}

	public void SetSoroPlay3DFieldID(int fieldID)
	{
		_soroPlay3DFieldId = fieldID;
	}

	public void SetStoryBgmID(string bgmID)
	{
		_storyBgmId = bgmID;
	}

	public void SetSpecialBattleSetting(bool? isPlayerFirst, string playerSkill, string enemySkill, int playerPp, int enemyPp, int playerLife, int playerMaxLife, int enemyMaxLife, string idOverrideBattleLogText, string id = "", string banishEffectOverride = "", string tokenDrawEffectOverride = "", string specialTokenDrawEffectOverride = "", int skipResult = 0, bool isVsEffectOverride = false, int classDestroyEffectOverride = 0)
	{
		SpecialBattleSettingInfo = new SpecialBattleSetting(id, isPlayerFirst, playerSkill, enemySkill, playerPp, enemyPp, playerLife, playerMaxLife, enemyMaxLife, idOverrideBattleLogText, banishEffectOverride, tokenDrawEffectOverride, specialTokenDrawEffectOverride, isVsEffectOverride, classDestroyEffectOverride);
		SkipStorySpecialBattleResult = (SpecialBattleResultType)skipResult;
	}

	public void ClearSpecialBattleSettingInfo()
	{
		SpecialBattleSettingInfo = null;
	}

	public void ResetStorySpecialBattleResultSkipFlag()
	{
		SkipStorySpecialBattleResult = SpecialBattleResultType.None;
	}

	private static Dictionary<int, int> ParseIdOverrideText(string idOverrideText)
	{
		if (string.IsNullOrEmpty(idOverrideText))
		{
			return null;
		}
		Dictionary<int, int> dictionary = new Dictionary<int, int>();
		string[] array = SplitSpecialBattleDataText(idOverrideText);
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split('=');
			dictionary.Add(int.Parse(array2[0]), int.Parse(array2[1]));
			dictionary.Add(int.Parse(array2[0]) + 1, int.Parse(array2[1]) + 1);
		}
		return dictionary;
	}

	private static string[] SplitSpecialBattleDataText(string text)
	{
		return text.Split(',');
	}

	private static Dictionary<int, string> SplitSpecialBattleDataPair(string text)
	{
		string[] array = text.Split(',');
		Dictionary<int, string> dictionary = new Dictionary<int, string>();
		for (int i = 0; i < array.Count(); i++)
		{
			string[] array2 = array[i].Split('=');
			if (array2.Length == 2)
			{
				int key = int.Parse(array2[0]);
				dictionary[key] = array2[1];
			}
		}
		return dictionary;
	}

	public string GetClanNameByKey(int intclantype)
	{
		if (intclantype < ClanNameTextIdList.Length)
		{
			return Data.SystemText.Get(ClanNameTextIdList[intclantype]);
		}
		return "";
	}

	public static string GetTribeNameByKey(int tribeType)
	{
		if (tribeType >= TribeNameTextIdList.Length)
		{
			return "";
		}
		string text = TribeNameTextIdList[tribeType];
		if (string.IsNullOrEmpty(text))
		{
			return "";
		}
		return Data.Master.GetTribeNameText(text);
	}

	public IDictionary<int, ClassCharaPrm> GetClassPrmDictionary()
	{
		return _classPrmDict;
	}

	public ClassCharaPrm GetClassPrm(int classId)
	{
		return _classPrmDict[classId];
	}

	public ClassCharacterMasterData GetCharaPrmByClassId(int classId, bool isCurrentChara = true)
	{
		ClassCharaPrm classPrm = GetClassPrm(classId);
		if (!isCurrentChara)
		{
			return classPrm.DefaultCharaData;
		}
		return classPrm.CurrentCharaData;
	}

	public ClassCharacterMasterData GetCharaPrmByCharaId(int charaId)
	{
		return Data.Master.ClassCharacterList.Find((ClassCharacterMasterData x) => x.chara_id == charaId);
	}

	public ClassCharacterMasterData GetCharaPrmBySkinId(int skinId)
	{
		return Data.Master.ClassCharacterList.Find((ClassCharacterMasterData x) => x.skin_id == skinId && x.is_usable);
	}

	public int GetPlayerCharaId()
	{
		if (_playerCharaId == 0)
		{
			return PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.LAST_BATTLE_LEADER_ID);
		}
		return _playerCharaId;
	}

	public int GetPlayerSubClassId()
	{
		return _playerSubClassId;
	}

	public bool TryGetPlayerSubClassId(out int subClassId)
	{
		subClassId = GetPlayerSubClassId();
		return IsValidSubClass(subClassId);
	}

	private static bool IsValidSubClass(int subClassId)
	{
		if (subClassId > 0)
		{
			return subClassId != 10;
		}
		return false;
	}

	public bool TryGetPlayerMyRotationInfo(out MyRotationInfo myRotationInfo)
	{
		myRotationInfo = _playerMyRotationInfo;
		return myRotationInfo != null;
	}

	public bool TryGetPlayerAvatarBattleInfo(out AvatarBattleInfo avatarBattleInfo)
	{
		avatarBattleInfo = _playerAvatarBattleInfo;
		return avatarBattleInfo != null;
	}

	public ClassCharacterMasterData GetPlayerCharaData()
	{
		return GetCharaPrmByCharaId(GetPlayerCharaId());
	}

	public ClassCharacterMasterData GetPlayerSubCharaData()
	{
		return GetCharaPrmByCharaId(GetPlayerSubClassId());
	}

	public int GetPlayerClassId()
	{
		return GetPlayerCharaData().class_id;
	}

	public int GetPlayerSkinId()
	{
		return GetPlayerCharaData().skin_id;
	}

	public long GetPlayerSleeveId()
	{
		return GetAbleSleeveId(_playerSleeveId);
	}

	public int GetPlayerBattleSkillReverse()
	{
		return GetPlayerCharaData().battle_skin_reverse;
	}

	public Dictionary<ClassCharaPrm.EmotionType, Emotion> GetPlayerEmotionData()
	{
		return Data.Master._emotionDic[GetPlayerEmotionId()];
	}

	public string GetPlayerEmotionId()
	{
		if (!(_playerEmotionId == ""))
		{
			return _playerEmotionId;
		}
		return GetPlayerSkinId().ToString();
	}

	public void SetPlayerEmotionId(string id)
	{
		_playerEmotionId = id;
	}

	public Dictionary<ClassCharaPrm.EmotionType, Emotion> GetEnemyEmotionData()
	{
		return Data.Master._emotionDic[GetEnemyEmotionId()];
	}

	public string GetEnemyEmotionId()
	{
		if (!(_enemyEmotionId == ""))
		{
			return _enemyEmotionId;
		}
		return GetEnemySkinId().ToString();
	}

	public void SetEnemyEmotionId(string id)
	{
		_enemyEmotionId = id;
	}

	public int GetEnemyCharaId()
	{
		if (_enemyCharaId == 0)
		{
			return 1;
		}
		return _enemyCharaId;
	}

	public int GetEnemySubClassId()
	{
		return _enemySubClassId;
	}

	public bool TryGetEnemySubClassId(out int subClassId)
	{
		subClassId = GetEnemySubClassId();
		return IsValidSubClass(subClassId);
	}

	public ClassCharacterMasterData GetEnemyCharaData()
	{
		return GetCharaPrmByCharaId(GetEnemyCharaId());
	}

	public ClassCharacterMasterData GetEnemySubCharaData()
	{
		return GetCharaPrmByCharaId(GetEnemySubClassId());
	}

	public int GetEnemyClassId()
	{
		if (GameMgr.GetIns().IsPuzzleQuest)
		{
			return PuzzleEnemyClass;
		}
		if (m_BattleType == BattleType.Story)
		{
			return StoryEnemyClassId;
		}
		return GetEnemyCharaData().class_id;
	}

	public int GetEnemySkinId()
	{
		return GetEnemyCharaData().skin_id;
	}

	public bool TryGetEnemyMyRotationInfo(out MyRotationInfo myRotationInfo)
	{
		myRotationInfo = _enemyMyRotationInfo;
		return myRotationInfo != null;
	}

	public bool TryGetEnemyAvatarBattleInfo(out AvatarBattleInfo avatarBattleInfo)
	{
		avatarBattleInfo = _enemyAvatarBattleInfo;
		return avatarBattleInfo != null;
	}

	public long GetEnemySleeveId()
	{
		return GetAbleSleeveId(_enemySleeveId);
	}

	public int GetEnemyBattleSkillReverse()
	{
		return GetEnemyCharaData().battle_skin_reverse;
	}

	public bool IsHighRankSkinPlayer()
	{
		return GetPlayerCharaData().IsHighRank;
	}

	public bool IsHighRankSkinEnemy()
	{
		return GetEnemyCharaData().IsHighRank;
	}

	public bool Is3DSkin(bool isPlayer)
	{
		if (isPlayer)
		{
			return GetPlayerCharaData().Is3d;
		}
		return GetEnemyCharaData().Is3d;
	}

	public bool IsEvolveSkin(bool isPlayer)
	{
		if (isPlayer)
		{
			return GetPlayerCharaData().IsEvolveSkin;
		}
		return GetEnemyCharaData().IsEvolveSkin;
	}

	public int GetEvolutionDelayFrame(bool isPlayer)
	{
		if (isPlayer)
		{
			return GetPlayerCharaData().EvolutionDelayFrame;
		}
		return GetEnemyCharaData().EvolutionDelayFrame;
	}

	public bool IsSelectEmptyDeck()
	{
		if (_selectDeckId != -1)
		{
			return false;
		}
		return true;
	}

	public int GetSelectDeckId()
	{
		if (_selectDeckId == 0)
		{
			return PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.LAST_BATTLE_DECK_ID);
		}
		return _selectDeckId;
	}

	public IList<int> GetCurrentDeckData()
	{
		return _currentDeckCardIdList;
	}

	public IList<int> GetCurrentEnemyDeckData()
	{
		return _currentEnemyDeckData;
	}

	public int GetDeckMaxCount(bool isSelf)
	{
		if (!isSelf)
		{
			return _enemyDeckMaxCardCount;
		}
		return _deckMaxCardCount;
	}

	public IDictionary<int, int> GetUserOwnCardData(bool isIncludingSpotCard)
	{
		if (isIncludingSpotCard)
		{
			if (_isDirtyPossessionCardDict)
			{
				UpdatePossessionCardDictIncludingSpotCard();
				_isDirtyPossessionCardDict = false;
			}
			return _possessionCardDictIncludingSpotCard;
		}
		return _possessionCardDict;
	}

	public Dictionary<int, int> ClonePossessionCardDictionary(bool isIncludingSpotCard)
	{
		return new Dictionary<int, int>(GetUserOwnCardData(isIncludingSpotCard));
	}

	public bool HasPossesionCardInfo(int cardId, bool isIncludingSpotCard)
	{
		return GetUserOwnCardData(isIncludingSpotCard).ContainsKey(cardId);
	}

	public int GetPossessionCardNum(int cardId, bool isIncludingSpotCard)
	{
		int value = 0;
		GetUserOwnCardData(isIncludingSpotCard).TryGetValue(cardId, out value);
		return value;
	}

	public static int GetPossessionBaseCardNum(int baseCardId, IDictionary<int, int> cardPool, CardMaster.CardMasterId cardMasterId)
	{
		CardMaster instance = CardMaster.GetInstance(cardMasterId);
		int num = 0;
		foreach (KeyValuePair<int, int> item in cardPool)
		{
			if (instance.GetCardParameterFromId(item.Key).BaseCardId == baseCardId)
			{
				try
				{
					num = checked(num + item.Value);
				}
				catch (OverflowException)
				{
					return int.MaxValue;
				}
			}
		}
		return num;
	}

	public int GetPossessionBaseCardNum(int baseCardId, bool isIncludingSpotCard, CardMaster.CardMasterId cardMasterId)
	{
		return GetPossessionBaseCardNum(baseCardId, GetUserOwnCardData(isIncludingSpotCard), cardMasterId);
	}

	public void UpdatePossessionCardNum(int cardId, int num)
	{
		GetUserOwnCardData(isIncludingSpotCard: false)[cardId] = num;
		SetDirtyPossessionCardDict();
	}

	public void RemovePossessionCard(int cardId)
	{
		IDictionary<int, int> userOwnCardData = GetUserOwnCardData(isIncludingSpotCard: false);
		if (userOwnCardData.ContainsKey(cardId))
		{
			userOwnCardData[cardId] = 0;
			SetDirtyPossessionCardDict();
		}
	}

	public List<int> GetPossessionCardIdList(bool isIncludingSpotCard)
	{
		return GetUserOwnCardData(isIncludingSpotCard).Keys.ToList();
	}

	public Dictionary<int, int> GetPossessionBaseCardDictionary(bool isIncludingSpotCard, CardMaster.CardMasterId cardMasterId)
	{
		CardMaster instance = CardMaster.GetInstance(cardMasterId);
		Dictionary<int, int> dictionary = new Dictionary<int, int>();
		foreach (KeyValuePair<int, int> userOwnCardDatum in GetUserOwnCardData(isIncludingSpotCard))
		{
			int baseCardId = instance.GetCardParameterFromId(userOwnCardDatum.Key).BaseCardId;
			int value = 0;
			if (dictionary.TryGetValue(baseCardId, out value))
			{
				try
				{
					dictionary[baseCardId] = checked(value + userOwnCardDatum.Value);
				}
				catch (OverflowException)
				{
					dictionary[baseCardId] = int.MaxValue;
				}
			}
			else
			{
				dictionary.Add(baseCardId, userOwnCardDatum.Value);
			}
		}
		return dictionary;
	}

	private void UpdatePossessionCardDictIncludingSpotCard()
	{
		_possessionCardDictIncludingSpotCard = SpotCardData.CreateDictionaryIncludingSpotCard(_possessionCardDict);
	}

	public void SetDirtyPossessionCardDict()
	{
		_isDirtyPossessionCardDict = true;
	}

	public void UpdateUserOwnCardData(int cardid, int num)
	{
		bool isNew = !HasPossesionCardInfo(cardid, isIncludingSpotCard: false);
		SetIsNewCard(cardid, isNew);
		if (_possessionCardDict.ContainsKey(cardid))
		{
			_possessionCardDict[cardid] = num;
		}
		else
		{
			_possessionCardDict.Add(cardid, num);
		}
		SetDirtyPossessionCardDict();
	}

	public bool IsNewCard(int cardId)
	{
		if (!_isNewCardDict.TryGetValue(cardId, out var value))
		{
			return false;
		}
		return value;
	}

	public void SetIsNewCard(int cardId, bool isNew)
	{
		_isNewCardDict[cardId] = isNew;
	}

	public void RegisterUserOwnCardData(int cardId, int num)
	{
		_possessionCardDict.Add(cardId, num);
		SetDirtyPossessionCardDict();
	}

	public void UnregisterUserOwnCardData(int cardId)
	{
		_possessionCardDict.Remove(cardId);
		SetDirtyPossessionCardDict();
	}

	public int GetSoroPlay3DFieldID()
	{
		return _soroPlay3DFieldId;
	}

	public string GetStoryBgmID()
	{
		return _storyBgmId;
	}

	public void SetMaintenanceCardIds(JsonData responseData)
	{
		if (responseData == null)
		{
			_maintenanceCardIds = null;
			return;
		}
		_maintenanceCardIds = new int[responseData.Count];
		for (int i = 0; i < responseData.Count; i++)
		{
			_maintenanceCardIds[i] = responseData[i]["card_id"].ToInt();
		}
	}

	public void SetMaintenanceCardIds(int[] ids)
	{
		_maintenanceCardIds = ids;
	}

	public bool IsMaintenanceCard(int id)
	{
		if (_maintenanceCardIds != null)
		{
			return _maintenanceCardIds.Contains(id);
		}
		return false;
	}

	public Dictionary<ClassCharaPrm.EmotionType, Emotion> GetEmotionDataBySkinId(string skinId)
	{
		if (!Data.Master._emotionDic.ContainsKey(skinId))
		{
			LocalLog.AccumulateTraceLog("Not contain key given. skinId : " + skinId + " emotionMasterKeyCount : " + Data.Master._emotionDic.Keys.Count);
		}
		return Data.Master._emotionDic[skinId];
	}

	public static long GetAbleSleeveId(long sleeveId)
	{
		return Data.Master.SleeveMgr.Get(sleeveId).sleeve_id;
	}
}
