using System.Collections.Generic;
using UnityEngine;
using Wizard;
using Wizard.Scripts.Network.Data.TableData.Arena.TwoPick;
using Wizard.Scripts.Network.Data.TaskData.Arena.TwoPick;

public class ArenaColosseum : ArenaEntryDataBase
{
	public enum eRound
	{
		FinalNotAdvance = -1,
		Round1 = 1,
		Round2B = 2,
		Round2A = 3,
		FinalB = 4,
		FinalA = 5,
		FinalMin = 4,
		RoundMax = 5,
		Undecided = 6,
		Lose = 7
	}

	public enum eStageNo
	{
		Stage1 = 1,
		Stage2,
		FinalStage,
		Max
	}

	public enum eEntryStatus
	{
		TwoPickClassSelect = 1,
		TwoPickCardSelect,
		SetUpComplete
	}

	public enum eRule
	{
		NONE = 0,
		RotationBo1 = 1,
		UnlimitedBo1 = 2,
		TwoPick = 3,
		TwoPickChaos = 4,
		Crossover = 5,
		MyRotation = 6,
		HOF = 31,
		WindFall = 33,
		Avatar = 39
	}

	public enum eDeckIndex
	{
		Main = 0,
		First = 0,
		Second = 1,
		Third = 2
	}

	public struct Detail
	{
		public string RoundTimeText { get; set; }

		public string RoundTimeStartText { get; set; }

		public string RoundTimeEndText { get; set; }

		public string GroupName { get; set; }

		public int MaxBattleNum { get; set; }

		public int BreakThroughNum { get; set; }

		public int MaxEntryNum { get; set; }
	}

	public class TwoPick
	{
		public CandidateClass CandidateClass { get; set; }

		public CandidateCardInfo CandidateCard { get; set; }

		public Deck DeckData { get; set; }

		public CandidateChaos CandidateChaos { get; set; }
	}

	public enum eResultEffect
	{
		None,
		GroupA,
		Final,
		Clear
	}

	private bool _isRankMatching;

	public bool CanUseNonPossessionCard;

	public int DeckEntryId { get; set; }

	public bool IsColosseumPeriod { get; set; }

	public bool IsRoundPeriod { get; set; }

	public eEntryStatus EntryStatus { get; set; }

	public Format DeckFormat { get; set; }

	public eRule Rule { get; set; }

	public bool IsNormalTwoPick { get; set; }

	public int ChaosNum { get; set; }

	public bool IsTwoPickRule
	{
		get
		{
			if (Rule != eRule.TwoPick)
			{
				return Rule == eRule.TwoPickChaos;
			}
			return true;
		}
	}

	public bool NeedsFirstTips { get; set; }

	public int ColosseumId { get; set; }

	public int ChaoseTipsId { get; set; }

	public bool IsSpecialDeckSelectRule
	{
		get
		{
			if (Rule != eRule.HOF)
			{
				return Rule == eRule.WindFall;
			}
			return true;
		}
	}

	public bool IsDeckMaxNumberChange => Rule == eRule.WindFall;

	public int DeckMaxNumber
	{
		get
		{
			if (Rule == eRule.WindFall)
			{
				return 35;
			}
			return 40;
		}
	}

	public bool IsRankMatching
	{
		get
		{
			return _isRankMatching;
		}
		set
		{
			if (_isRankMatching != value)
			{
				_isRankMatching = value;
				if (RealTimeNetworkAgent.FinishTaskBase != null)
				{
					RealTimeNetworkAgent.FinishTaskBase = new ColosseumBattleFinishTask();
				}
			}
		}
	}

	public List<DeckData> DeckList { get; set; }

	public eRound Round { get; set; }

	public int ServerRoundId { get; set; }

	public eStageNo StageNo { get; set; }

	public string Name { get; set; }

	public List<ReceivedReward> RewardList { get; set; }

	public eResultEffect ResultEffect { get; set; }

	public string ColorCodeId { get; set; }

	public string CardPool { get; set; }

	public int RetryRemainingNum { get; set; }

	public int BattleMax { get; set; }

	public int ClearWinNum { get; set; }

	public bool IsDeckEntry { get; set; }

	public bool IsFreeEntry
	{
		get
		{
			return Data.MyPageNotifications.data.IsColosseumFreeEntry;
		}
		set
		{
			Data.MyPageNotifications.data.IsColosseumFreeEntry = value;
		}
	}

	public bool IsRetry { get; set; }

	public bool IsLastDay { get; set; }

	public bool IsClear { get; set; }

	public bool IsRetire { get; set; }

	public bool IsFinish { get; set; }

	public bool IsDeckDeleted { get; set; }

	public bool IsFinalRoundTry { get; set; }

	public eRound NextRound { get; set; }

	public double RemainingUnixTime { get; set; }

	public float RemainingSinceTime { get; set; }

	public double RemainingServerUnixTime { get; set; }

	public string NextRoundStartTimeText { get; set; }

	public string NowRoundTimeText { get; set; }

	public string ColosseumTimeText { get; set; }

	public string AnnounceNo { get; set; }

	public Detail[] DetailData { get; set; }

	public eStageNo FocusStageNo { get; set; }

	public int WinBattleNum { get; set; }

	public List<bool> BattleResultList { get; set; }

	public List<int> BoxGradeList { get; set; }

	public int FinalRoundEliminateCount { get; set; }

	public TwoPick TwoPickData { get; set; }

	public ArenaColosseum()
	{
		base.LootBoxType = PlayerStaticData.LootBoxType.COLOSSEUM;
		DeckList = new List<DeckData>();
		RewardList = new List<ReceivedReward>();
		BattleResultList = new List<bool>();
		BoxGradeList = new List<int>();
		DetailData = new Detail[5];
		Rule = eRule.TwoPick;
		TwoPickData = new TwoPick();
		TwoPickData.CandidateClass = new CandidateClass();
		TwoPickData.CandidateCard = new CandidateCardInfo();
		TwoPickData.CandidateChaos = new CandidateChaos();
	}

	public int GetRoundNumber(eRound inRound)
	{
		switch (inRound)
		{
		case eRound.Round1:
			return 1;
		case eRound.Round2B:
		case eRound.Round2A:
			return 2;
		default:
			return 0;
		}
	}

	public string GetGroupText(eRound inRound)
	{
		switch (inRound)
		{
		case eRound.Round2A:
		case eRound.FinalA:
			return Data.SystemText.Get("Colosseum_0020");
		case eRound.Round2B:
		case eRound.FinalB:
			return Data.SystemText.Get("Colosseum_0021");
		default:
			return "";
		}
	}

	public eStageNo GetStageNoFromRoundId(eRound inRoundId)
	{
		switch (inRoundId)
		{
		case eRound.Round1:
			return eStageNo.Stage1;
		case eRound.Round2B:
		case eRound.Round2A:
			return eStageNo.Stage2;
		case eRound.FinalB:
		case eRound.FinalA:
			return eStageNo.FinalStage;
		default:
			return eStageNo.Stage1;
		}
	}

	public bool IsFinalRound()
	{
		if (Round == eRound.FinalA || Round == eRound.FinalB)
		{
			return true;
		}
		return false;
	}

	public DialogBase CreateDetailDialog(GameObject defaultDetailPrefab)
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		GameObject gameObject = Object.Instantiate(defaultDetailPrefab);
		dialogBase.SetObj(gameObject);
		gameObject.GetComponent<ColosseumDetail>().Init(dialogBase);
		return dialogBase;
	}

	public void ApiRuleParseAndSet(int apiRule)
	{
		ArenaColosseum colosseumData = Data.ArenaData.ColosseumData;
		colosseumData.Rule = (eRule)apiRule;
		colosseumData.DeckFormat = ArenaData.ApiDeckFormatParse(colosseumData.Rule);
	}
}
