using System;
using LitJson;

namespace Wizard;

public class ColosseumDetailTask : BaseTask
{
	public const int COLOSSEUM_ANNOUNCE_ID_NOT_SET_ERROR_CODE = 4416;

	public ColosseumDetailTask()
	{
		base.type = ApiType.Type.ColosseumDetail;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		JsonData jsonData = base.ResponseData["data"];
		JsonData colosseumOwnStatus = jsonData["colosseum_status"];
		JsonData jsonData2 = jsonData["colosseum_info"];
		ArenaColosseum colosseumData = Data.ArenaData.ColosseumData;
		colosseumData.ApiRuleParseAndSet(jsonData2["format"].ToInt());
		string text = ConvertTime.ToLocal(DateTime.Parse(jsonData2["start_time"].ToString()));
		string text2 = ConvertTime.ToLocal(DateTime.Parse(jsonData2["end_time"].ToString()));
		colosseumData.ColosseumTimeText = Data.SystemText.Get("Colosseum_0033", text, text2);
		colosseumData.AnnounceNo = ((jsonData2["announce_id"] != null) ? jsonData2["announce_id"].ToString() : "");
		colosseumData.FinalRoundEliminateCount = jsonData2["final_round_eliminate_count"].ToInt();
		int num2 = 0;
		colosseumData.FocusStageNo = ArenaColosseum.eStageNo.Max;
		for (int i = 1; i <= 3; i++)
		{
			JsonData jsonData3 = jsonData[i.ToString()];
			text = ConvertTime.ToLocal(DateTime.Parse(jsonData3["start_time"].ToString()), ConvertTime.FORMAT.TIME_DATE_SHORT);
			text2 = ConvertTime.ToLocal(DateTime.Parse(jsonData3["end_time"].ToString()), ConvertTime.FORMAT.TIME_DATE_SHORT);
			if (jsonData3["is_now_round"].ToBoolean())
			{
				colosseumData.FocusStageNo = (ArenaColosseum.eStageNo)i;
			}
			JsonData jsonData4 = jsonData3["round_detail"];
			for (int j = 0; j < jsonData4.Count; j++)
			{
				colosseumData.DetailData[num2].RoundTimeText = Data.SystemText.Get("Colosseum_0033", text, text2);
				colosseumData.DetailData[num2].RoundTimeStartText = Data.SystemText.Get("Colosseum_0106", text);
				colosseumData.DetailData[num2].RoundTimeEndText = Data.SystemText.Get("Colosseum_0107", text2);
				colosseumData.DetailData[num2].GroupName = jsonData4[j]["group"].ToString();
				colosseumData.DetailData[num2].MaxBattleNum = jsonData4[j]["max_battle_count"].ToInt();
				colosseumData.DetailData[num2].BreakThroughNum = jsonData4[j]["breakthrough_number"].ToInt();
				colosseumData.DetailData[num2].MaxEntryNum = jsonData4[j]["entry_number"].ToInt();
				if (colosseumData.DetailData[num2].GroupName == "")
				{
					colosseumData.DetailData[num2].GroupName = Data.SystemText.Get("Colosseum_0079");
				}
				num2++;
			}
		}
		ColosseumEntryInfoTask.SetColosseumOwnStatus(colosseumOwnStatus);
		return num;
	}
}
