using System.Collections.Generic;
using System.Linq;
using Wizard.Battle.View.Vfx;

namespace Wizard.Battle.Mulligan;

public class OpponentMulliganCtrl : MulliganCtrl
{
	protected List<int> opponentIndexList = new List<int>();

	protected bool _isHideCard = true;

	public OpponentMulliganCtrl(BattlePlayerBase player, MulliganInfoControl mulliganInfo, bool isUseExchangeMark)
		: base(player)
	{
		_mulliganView = new OpponentMulliganView(mulliganInfo, isUseExchangeMark);
		_isHideCard = true;
	}

	public override VfxBase StartMulliganVfx(SkillProcessor skillProcessor)
	{
		BattlePlayerBase battlePlayer = GetBattlePlayer();
		opponentIndexList = _LotMulliganCardIndex(battlePlayer.DeckCardList.Count);
		_CreateMulliganCardList(opponentIndexList);
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		sequentialVfxPlayer.Register(battlePlayer.BattleMgr.LoadCardResources(_firstDrawList));
		sequentialVfxPlayer.Register(new EnemyMulliganDrawVfx(_firstDrawList, GetMulliganInfo()));
		return sequentialVfxPlayer;
	}

	public override VfxBase SubmitMulliganVfx(IList<BattleCardBase> abandonCards)
	{
		_mulliganChangedNum = abandonCards.Count;
		ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create();
		if (abandonCards.Count > 0)
		{
			parallelVfxPlayer.Register(_MulliganCardChange(abandonCards));
		}
		parallelVfxPlayer.Register(new DummyDeckRemoveCardVfx(isPlayer: false, 3));
		parallelVfxPlayer.Register(_mulliganView.UpdateOpponentMulliganStatusLabel(abandonCards.Count));
		return parallelVfxPlayer;
	}

	public List<int> GetOpponentIndexList()
	{
		return opponentIndexList;
	}

	protected override VfxBase _MulliganSwap(IDictionary<int, BattleCardBase> newList, IList<BattleCardBase> oldList)
	{
		return new EnemyMulliganSwapVfx(newList.Values.ToList(), newList.Keys.ToList(), oldList);
	}
}
