using System.Collections.Generic;
using LitJson;

namespace Wizard;

public class ChatDeleteDeckTask : BaseTask
{
	public class ChatDeleteDeckTaskParam : BaseParam
	{
		public int deck_format { get; set; }

		public int message_id { get; set; }
	}

	public Dictionary<Format, List<ChatMessageInfo.DeckLogData>> DictDeckLogList { get; private set; }

	public ChatDeleteDeckTask(ApiType.Type apiType)
	{
		base.type = apiType;
	}

	public void SetParameter(int deckFormat, int messageId)
	{
		ChatDeleteDeckTaskParam chatDeleteDeckTaskParam = new ChatDeleteDeckTaskParam();
		chatDeleteDeckTaskParam.deck_format = deckFormat;
		chatDeleteDeckTaskParam.message_id = messageId;
		base.Params = chatDeleteDeckTaskParam;
	}

	protected override int Parse()
	{
		int num = base.Parse();
		if (num != 1)
		{
			return num;
		}
		JsonData jsonData = base.ResponseData["data"]["deck_log"];
		GameMgr.GetIns().GetDataMgr().SetMaintenanceCardIds(base.ResponseData["data"]["maintenance_card_list"]);
		DictDeckLogList = new Dictionary<Format, List<ChatMessageInfo.DeckLogData>>();
		DictDeckLogList[Format.Rotation] = ChatMessageInfo.DeckLogData.ParseDeckDataList(jsonData[Data.FormatConvertApi(Format.Rotation).ToString()]);
		DictDeckLogList[Format.Unlimited] = ChatMessageInfo.DeckLogData.ParseDeckDataList(jsonData[Data.FormatConvertApi(Format.Unlimited).ToString()]);
		DictDeckLogList[Format.PreRotation] = ChatMessageInfo.DeckLogData.ParseDeckDataList(jsonData[Data.FormatConvertApi(Format.PreRotation).ToString()]);
		if (jsonData.TryGetValue(Data.FormatConvertApi(Format.Crossover).ToString(), out var value))
		{
			DictDeckLogList[Format.Crossover] = ChatMessageInfo.DeckLogData.ParseDeckDataList(value);
		}
		if (jsonData.TryGetValue(Data.FormatConvertApi(Format.MyRotation).ToString(), out var value2))
		{
			DictDeckLogList[Format.MyRotation] = ChatMessageInfo.DeckLogData.ParseDeckDataList(value2);
		}
		return num;
	}
}
