using System.Collections.Generic;
using System.Linq;

namespace Wizard.Scripts.Network.Data.TaskData.BuildDeckPurchase;

public class BuildDeckProductInfo
{
	private List<BuildDeckCard> _cardList = new List<BuildDeckCard>();

	private List<ShopCommonRewardInfo> _rewardInfoList = new List<ShopCommonRewardInfo>();

	public int product_id { get; set; }

	public string deck_code { get; set; }

	public int leader_id { get; set; }

	public int featured_card_id { get; set; }

	public int purchase_num_max { get; set; }

	public int purchase_num_current { get; set; }

	public bool is_first_price { get; set; }

	public bool is_purchased
	{
		get
		{
			if (purchase_num_max <= purchase_num_current)
			{
				return true;
			}
			return false;
		}
	}

	public ShopCommonSaleInfo saleInfo { get; set; }

	public List<BuildDeckCard> cardList => _cardList;

	public List<ShopCommonRewardInfo> rewardInfoList => _rewardInfoList;

	public List<int> CardIdList
	{
		get
		{
			List<int> list = new List<int>();
			for (int i = 0; i < cardList.Count; i++)
			{
				for (int j = 0; j < cardList[i]._number; j++)
				{
					list.Add(cardList[i]._cardId);
				}
			}
			return list;
		}
	}

	public bool HasResurgentCard
	{
		get
		{
			CardMaster cardMaster = CardMaster.GetInstance(CardMaster.CardMasterId.Default);
			return _cardList.Any((BuildDeckCard card) => cardMaster.GetCardParameterFromId(card._cardId).IsResurgentCard);
		}
	}

	public bool ContainsOnlyRotationCards()
	{
		CardMaster master = CardMaster.GetInstance(CardMaster.CardMasterId.Default);
		List<int> source = _cardList.ConvertAll((BuildDeckCard card) => master.GetCardParameterFromId(card._cardId).BaseCardId);
		source = source.Distinct().ToList();
		for (int num = 0; num < source.Count; num++)
		{
			if (!master.GetCardParameterFromId(source[num]).IsAvailableFormat(Format.Rotation, ClassType.None))
			{
				return false;
			}
		}
		return true;
	}
}
