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

public class WatchPlayCardAction : PlayHandCardReflection
{
	public WatchPlayCardAction(BattleManagerBase battleMgr, OperateMgr operateMgr, NetworkBattleData networkBattleData)
		: base(battleMgr, operateMgr, networkBattleData)
	{
	}

	protected override void PlayMove(BattleCardBase playedCard, bool isPlayer = false, List<int> choiceId = null, bool isChoice = false)
	{
		if (isChoice && choiceId != null && (isPlayer || GameMgr.GetIns().IsAdmin))
		{
			return;
		}
		if (!GameMgr.GetIns().IsAdminWatch && !isPlayer)
		{
			base.PlayMove(playedCard, isPlayer, choiceId, isChoice);
			return;
		}
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		if (_networkBattleData.GetReceiveData().mutationAfterCardId != 0)
		{
			sequentialVfxPlayer.Register(InstantVfx.Create(delegate
			{
				playedCard.BattleCardView.HideHandCardInfo();
				playedCard.BattleCardView.HideCanPlayEffect();
			}));
		}
		sequentialVfxPlayer.Register(_operateMgr.InitSetCard(playedCard, isPlayer));
		sequentialVfxPlayer.Register(_operateMgr.PlayCard(playedCard, isPlayer, null, isRecovery: false, choiceId));
		_battleMgr.VfxMgr.RegisterSequentialVfx(sequentialVfxPlayer);
	}

	protected override void PlayActionMove(BattleCardBase receivedCard, List<BattleCardBase> targetCards, bool isPlayer = false, List<int> choiceId = null)
	{
		if (!isPlayer && !GameMgr.GetIns().IsAdmin)
		{
			base.PlayActionMove(receivedCard, targetCards, isPlayer, choiceId);
		}
	}

	protected override void SendEcho(BattleCardBase receivedCard, NetworkBattleDefine.PlayActionType actionType)
	{
	}

	public override void StartSelect(int actingCardIndex, bool isPlayer = true)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleCardBase playedCard = NetworkBattleGenericTool.GetIndexToCardBase(_battleMgr, _battleMgr.GetBattlePlayer(isPlayer), actingCardIndex);
		Skill_transform accelerateOrCrystallizeTransformSkill = playedCard.GetAccelerateOrCrystallizeTransformSkill();
		bool isAccelerateSelect = accelerateOrCrystallizeTransformSkill != null;
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			playedCard.BattleCardView.HideHandCardInfo();
			if (!isPlayer && GameMgr.GetIns().IsAdminWatch)
			{
				_battleMgr.BattleEnemy.UpdateHandCardsPlayability(areArrowsForcedOff: true);
			}
		}));
		sequentialVfxPlayer.Register(_operateMgr.InitSetCard(playedCard, isPlayer, isSelect: true, isRecovery: false, isChoiceSelect: false, isAccelerateSelect));
		sequentialVfxPlayer.Register(CreateStartSelectVfx(playedCard, isEvolve: false, isChoice: false, accelerateOrCrystallizeTransformSkill));
		_battleMgr.VfxMgr.RegisterSequentialVfx(sequentialVfxPlayer);
	}

	public override void StartChoiceSelect(int actingCardIndex, bool isPlayer = true)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleCardBase indexToCardBase = NetworkBattleGenericTool.GetIndexToCardBase(_battleMgr, _battleMgr.GetBattlePlayer(isPlayer), actingCardIndex);
		Skill_transform accelerateOrCrystallizeTransformSkill = indexToCardBase.GetAccelerateOrCrystallizeTransformSkill();
		BattleCardBase battleCardBase = null;
		if (accelerateOrCrystallizeTransformSkill != null)
		{
			int tokenId = accelerateOrCrystallizeTransformSkill.TransformId + (accelerateOrCrystallizeTransformSkill.SkillPrm.ownerCard.BaseParameter.IsFoil ? 1 : 0);
			battleCardBase = _battleMgr.CreateTransformCardRegisterVfx(indexToCardBase, tokenId, isPlayer);
		}
		SkillBase choiceSkill = GetSelectSkills((battleCardBase != null) ? battleCardBase : indexToCardBase, isEvolve: false).FirstOrDefault();
		sequentialVfxPlayer.Register(CreateStartChoiceSelectVfx(indexToCardBase, choiceSkill, isEvolve: false, battleCardBase));
		_battleMgr.VfxMgr.RegisterSequentialVfx(sequentialVfxPlayer);
	}

	public override void StartSelectFusion(int actingCardIndex, bool isPlayer = true)
	{
		SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
		BattleCardBase playedCard = NetworkBattleGenericTool.GetIndexToCardBase(_battleMgr, _battleMgr.GetBattlePlayer(isPlayer), actingCardIndex);
		sequentialVfxPlayer.Register(InstantVfx.Create(delegate
		{
			playedCard.BattleCardView.HideHandCardInfo();
			if (!isPlayer && GameMgr.GetIns().IsAdminWatch)
			{
				_battleMgr.BattleEnemy.UpdateHandCardsPlayability(areArrowsForcedOff: true);
			}
		}));
		sequentialVfxPlayer.Register((_battleMgr as NetworkWatchBattleMgr).CreateVfxResetPositionByCardBase(playedCard, null));
		sequentialVfxPlayer.Register(CreateStartFusionSelectVfx(playedCard));
		_battleMgr.VfxMgr.RegisterSequentialVfx(sequentialVfxPlayer);
	}

	protected override VfxBase CreateAfterSelectVfx(BattleCardBase actingCard, List<int> selectedChoiceCardIds, bool isPlayer, bool isChoiceBrave)
	{
		return _operateMgr.PlayCard(actingCard, isPlayer, _selectedCards, isRecovery: false, selectedChoiceCardIds, isChoiceBrave);
	}
}
