using System.Collections.Generic;

namespace Wizard;

public class GatheringCreateTask : BaseTask
{
	public class DeckEntry
	{
		public int deck_no;

		public string deck_name;

		public DeckEntry(DeckData deck)
		{
			deck_no = deck.GetDeckID();
			deck_name = deck.GetDeckName();
		}
	}

	public class GatheringCreateTaskParam : BaseParam
	{
		public int join_member_limit;

		public int is_master_joined;

		public int deck_format;

		public int battle_type;

		public int watch_type;

		public long battle_begin_timestamp;

		public int battle_hours;

		public int gathering_type;

		public int is_deck_entry;

		public int tournament_format;

		public Dictionary<string, DeckEntry> deck_list = new Dictionary<string, DeckEntry>();
	}

	public GatheringCreateTask()
	{
		base.type = ApiType.Type.GatheringCreate;
	}

	public void SetParameter(GatheringRule rule, List<DeckData> deckList)
	{
		GatheringCreateTaskParam gatheringCreateTaskParam = new GatheringCreateTaskParam();
		gatheringCreateTaskParam.deck_format = Data.FormatConvertApi(rule.BattleParameterInstance.DeckFormat);
		gatheringCreateTaskParam.join_member_limit = rule.MaxMember;
		gatheringCreateTaskParam.is_master_joined = (rule.IsOwnerEntryBattle ? 1 : 0);
		gatheringCreateTaskParam.battle_type = (int)rule.BattleParameterInstance.Rule;
		gatheringCreateTaskParam.watch_type = (int)rule.WatchSetting;
		gatheringCreateTaskParam.battle_begin_timestamp = (long)ConvertTime.DateTimeToUnixTime(rule.BattleStartUtcTime);
		gatheringCreateTaskParam.battle_hours = rule.BattleTimeHour;
		gatheringCreateTaskParam.is_deck_entry = (rule.IsEntryDeckOnly ? 1 : 0);
		gatheringCreateTaskParam.gathering_type = (int)rule.Type;
		gatheringCreateTaskParam.tournament_format = (int)rule.TournamentType;
		if (deckList != null)
		{
			for (int i = 0; i < deckList.Count; i++)
			{
				gatheringCreateTaskParam.deck_list[i.ToString()] = new DeckEntry(deckList[i]);
			}
		}
		base.Params = gatheringCreateTaskParam;
	}
}
