OnTrashHand.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. public partial class CardEffectCommons
  7. {
  8. #region Can trigger "When this hand card is trashed due to effect" effect
  9. public static bool CanTriggerOnTrashSelfHand(Hashtable hashtable, Func<ICardEffect, bool> cardEffectCondition, CardSource card)
  10. {
  11. return CanTriggerOnTrashHand(hashtable, cardEffectCondition, cardSource => cardSource == card);
  12. }
  13. #endregion
  14. #region Can trigger "When hand card is trashed due to effect" effect
  15. public static bool CanTriggerOnTrashHand(Hashtable hashtable, Func<ICardEffect, bool> cardEffectCondition, Func<CardSource, bool> cardCondition)
  16. {
  17. ICardEffect CardEffect = GetCardEffectFromHashtable(hashtable);
  18. if (CardEffect != null)
  19. {
  20. if (cardEffectCondition == null || cardEffectCondition(CardEffect))
  21. {
  22. List<CardSource> DiscardedCards = GetDiscardedCardsFromHashtable(hashtable);
  23. if (DiscardedCards != null)
  24. {
  25. if (DiscardedCards.Count(cardSource => cardCondition == null || cardCondition(cardSource)) >= 1)
  26. {
  27. return true;
  28. }
  29. }
  30. }
  31. }
  32. return false;
  33. }
  34. #endregion
  35. }