using LitJson;

namespace Wizard;

public class RoomBattleDoMatchingTask : DoMatchingBase
{
	public RoomBattleDoMatchingTask(bool isConvention, bool isGathering)
	{
		if (isConvention)
		{
			base.type = ApiType.Type.EventRoomBattleBattleDoMatching;
		}
		else if (isGathering)
		{
			base.type = ApiType.Type.GatheringRoomBattleDoMatching;
		}
		else
		{
			base.type = ApiType.Type.OpenRoomBattleBattleDoMatching;
		}
		SkipCuteTimeOutPopup();
		SkipCuteHttpStatusErrorPopup();
		SkipAllCuteResultCodeCheckErrorPopup();
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		Data.RoomBattleMatching.data = new RoomBattleMatchingDetail();
		Data.RoomBattleMatching.data.battle_state = 0;
		Data.RoomBattleMatching.data.matching_state = 0;
		JsonData jsonData = base.ResponseData["data"];
		Data.RoomBattleMatching.data.matching_state = jsonData["matching_state"].ToInt();
		if (jsonData.Keys.Contains("battle_state"))
		{
			Data.RoomBattleMatching.data.battle_state = jsonData["battle_state"].ToInt();
		}
		if (jsonData.TryGetValue("battle_id", out var value))
		{
			Data.LastRoomBattleId = value.ToString();
		}
		Data.RoomBattleMatching.data.battleId = Data.LastRoomBattleId;
		return num;
	}
}
