using System.Collections.Generic;
using LitJson;

namespace Wizard;

public class BattlePassBuyTask : BaseTask
{
	public class BattlePassBuyTaskParam : BaseParam
	{
		public int season_id { get; set; }

		public int id { get; set; }
	}

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

	public BattlePassBuyTask()
	{
		base.type = ApiType.Type.BattlePassBuy;
	}

	public void SetParameter(int seasonId, int id)
	{
		BattlePassBuyTaskParam battlePassBuyTaskParam = new BattlePassBuyTaskParam();
		battlePassBuyTaskParam.season_id = seasonId;
		battlePassBuyTaskParam.id = id;
		base.Params = battlePassBuyTaskParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		JsonData jsonData = base.ResponseData["data"]["achieved_info"];
		if (jsonData.Count > 0 && jsonData.Keys.Contains("battle_pass_reward_list"))
		{
			JsonData jsonData2 = jsonData["battle_pass_reward_list"];
			RewardList = new List<ReceivedReward>();
			for (int i = 0; i < jsonData2.Count; i++)
			{
				JsonData jsonData3 = jsonData2[i];
				int rewardType = jsonData3["reward_type"].ToInt();
				long rewardId = jsonData3["reward_detail_id"].ToLong();
				int rewardCount = jsonData3["reward_number"].ToInt();
				RewardList.Add(new ReceivedReward(rewardType, rewardId, rewardCount));
			}
		}
		PlayerStaticData.UpdateHaveUserGoodsNumByJsonData(base.ResponseData["data"]["reward_list"]);
		return num;
	}
}
