using System.Collections.Generic;
using LitJson;

namespace Wizard;

public class QuestDeckListTask : BaseTask
{
	public class QuestDeckListTaskParam : BaseParam
	{
		public int quest_stage_id;
	}

	public DeckGroupListData DeckGroupListData { get; private set; }

	public List<Format> BonusFormatList { get; private set; }

	public List<CardBasePrm.ClanType> BonusClassList { get; private set; }

	public QuestDeckListTask()
	{
		base.type = ApiType.Type.QuestGetDeckList;
	}

	public void SetParameter(int questStageId)
	{
		QuestDeckListTaskParam questDeckListTaskParam = new QuestDeckListTaskParam();
		questDeckListTaskParam.quest_stage_id = questStageId;
		base.Params = questDeckListTaskParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		JsonData jsonData = base.ResponseData["data"];
		GameMgr.GetIns().GetDataMgr().SetMaintenanceCardIds(base.ResponseData["data"]["maintenance_card_list"]);
		DeckGroupListData = new DeckGroupListData(jsonData, Format.All);
		DeckGroupListData.RemoveUseSubClassDeckList();
		BonusFormatList = new List<Format>();
		for (int i = 0; i < jsonData["bonus_deck_format"].Count; i++)
		{
			BonusFormatList.Add(Data.ParseApiFormat(jsonData["bonus_deck_format"][i].ToInt()));
		}
		BonusClassList = new List<CardBasePrm.ClanType>();
		for (int j = 0; j < jsonData["bonus_class_id"].Count; j++)
		{
			BonusClassList.Add((CardBasePrm.ClanType)jsonData["bonus_class_id"][j].ToInt());
		}
		return num;
	}
}
