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

public class SkillTargetHandBanishedThisTurnCardListFilter : ISkillTargetFilter
{
	public IEnumerable<IReadOnlyBattleCardInfo> Filtering(IEnumerable<IBattlePlayerReadOnlyInfo> battlePlayerInfos, SkillConditionCheckerOption option)
	{
		List<IReadOnlyBattleCardInfo> list = new List<IReadOnlyBattleCardInfo>();
		// Turn is battle-scoped; IsSelfTurn on the mgr's home player is equivalent to iterating
		// for the p.IsPlayer entry. Route through the first battle-player-info.
		IBattlePlayerReadOnlyInfo _f = battlePlayerInfos.FirstOrDefault();
		if (_f == null) return list;
		int turn = _f.Turn;
		bool isSelfTurn = (battlePlayerInfos.FirstOrDefault(p => p.IsPlayer) ?? _f).IsSelfTurn;
		list.AddRange(battlePlayerInfos.SelectMany((IBattlePlayerReadOnlyInfo p) => p.SkillInfoBanishCards.Where((IReadOnlyBattleCardInfo pp) => !(pp is NullBattleCard) && pp.BanishedInfo.Turn == turn && pp.BanishedInfo.IsSelfTurn == isSelfTurn && pp.BanishedInfo.Place == BattleCardBase.BanishInfo.BanishPlace.Hand)));
		return list;
	}
}
