using LitJson;

namespace Wizard.Scripts.Network.Task.Arena.TwoPick;

public class TwoPickDoMatchingTask : 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 TwoPickDoMatchingTask()
	{
		base.type = ApiType.Type.ArenaTwoPickDoMatching;
		if (GameMgr.GetIns().GetDataMgr().TwoPickFormat == TwoPickFormat.Chaos)
		{
			base.type = ApiType.Type.ArenaTwoPickChaosDoMatching;
		}
		if (GameMgr.GetIns().GetDataMgr().TwoPickFormat == TwoPickFormat.Cube)
		{
			base.type = ApiType.Type.ArenaTwoPickCubeDoMatching;
		}
	}

	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"];
				Wizard.Data.DoMatchingDetail.data.SetWinnerRewardInfo(jsonData.ToInt(), jsonData2.ToString());
			}
		}
		else
		{
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_GRADE, 0);
			PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_STRING, "");
			Wizard.Data.DoMatchingDetail.data.ClearWinnerRewardInfo();
		}
		return num;
	}
}
