WhenUseOption.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 you use an Option card" effects
  9. public static bool CanTriggerWhenOwnerUseOption(Hashtable hashtable, Func<CardSource, bool> cardCondition, Func<int, bool> constCondition, CardSource card)
  10. {
  11. bool CardCondition(CardSource cardSource) => cardSource.Owner == card.Owner && (cardCondition == null || cardCondition(cardSource));
  12. return CanTriggerWhenUseOption(hashtable, CardCondition, constCondition, card);
  13. }
  14. #endregion
  15. #region Can trigger "When you or the opponent use an Option card" effects
  16. public static bool CanTriggerWhenUseOption(Hashtable hashtable, Func<CardSource, bool> cardCondition, Func<int, bool> constCondition, CardSource card)
  17. {
  18. CardSource Card = GetCardFromHashtable(hashtable);
  19. if (Card != null)
  20. {
  21. if (cardCondition == null || cardCondition(Card))
  22. {
  23. if (hashtable.ContainsKey("Cost"))
  24. {
  25. if (hashtable["Cost"] is int)
  26. {
  27. int Cost = (int)hashtable["Cost"];
  28. if (constCondition == null || constCondition(Cost))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. #endregion
  39. }