using LitJson;

namespace Wizard;

public class RankBattleDoMatchingTask : DoMatchingBase
{
	private const string DATA = "data";

	private const string DISCOVERED_REWAED = "discovered_reward";

	private const string GRADE_ID = "grade_id";

	private const string REWARD_MESSAGE = "reward_message";

	public RankBattleDoMatchingTask()
	{
		switch (Data.CurrentFormat)
		{
		case Format.Rotation:
			base.type = ApiType.Type.RankBattleDoMatchingRotation;
			break;
		case Format.Unlimited:
			base.type = ApiType.Type.RankBattleDoMatchingUnlimited;
			break;
		case Format.Crossover:
			base.type = ApiType.Type.RankBattleDoMatchingCrossover;
			break;
		default:
			Debug.LogError("UnknownFormat:" + Data.CurrentFormat);
			break;
		}
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		SettingDoMatchingData();
		if (base.ResponseData["data"].Keys.Contains("discovered_reward"))
		{
			if (base.ResponseData["data"]["discovered_reward"].Keys.Contains("grade_id"))
			{
				JsonData jsonData = base.ResponseData["data"]["discovered_reward"]["grade_id"];
				JsonData jsonData2 = base.ResponseData["data"]["discovered_reward"]["reward_message"];
				Data.DoMatchingDetail.data.SetWinnerRewardInfo(jsonData.ToInt(), jsonData2.ToString());
			}
		}
		else
		{
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_GRADE, 0);
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_STRING, "");
			Data.DoMatchingDetail.data.ClearWinnerRewardInfo();
		}
		return num;
	}
}
