using System.Collections; using System.Collections.Generic; using System; using System.Linq; using UnityEngine; public partial class CardEffectCommons { #region Can trigger "When this linked card is trashed" effect public static bool CanTriggerOnTrashSelfLinkedCard(Hashtable hashtable, Func cardEffectCondition, CardSource card) { bool PermanentCondition(Permanent permanent) { if (IsPermanentExistsOnBattleArea(permanent)) { if (permanent.LinkedCards.Contains(card)) { return true; } } return false; } bool CardCondition(CardSource cardSource) { return cardSource == card; } return CanTriggerOnTrashLinkedCard(hashtable, PermanentCondition, cardEffectCondition, CardCondition); } #endregion #region Can trigger "When this linked card is trashed due to effect" effect public static bool CanTriggerOnTrashLinkedCard(Hashtable hashtable, Func permanentCondition, Func cardEffectCondition, Func cardCondition) { Permanent permanent = GetPermanentFromHashtable(hashtable); if (permanent != null) { if (permanent.TopCard != null) { if (permanentCondition == null || permanentCondition(permanent)) { ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable); if (CardEffect != null) { if (cardEffectCondition == null || cardEffectCondition(CardEffect)) { List DiscardedCards = GetDiscardedCardsFromHashtable(hashtable); if (DiscardedCards != null) { if (DiscardedCards.Count(cardSource => cardCondition == null || cardCondition(cardSource)) >= 1) { return true; } } } } } } } return false; } #endregion }