CanAttackTargetDefendingPermanentClass.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System;
  5. public class CanAttackTargetDefendingPermanentClass : ICardEffect, ICanAttackTargetDefendingPermanentEffect
  6. {
  7. Func<Permanent, bool> AttackerCondition { get; set; }
  8. Func<Permanent, bool> DefenderCondition { get; set; }
  9. Func<ICardEffect, bool> CardEffectCondition { get; set; }
  10. public void SetUpCanAttackTargetDefendingPermanentClass(Func<Permanent, bool> attackerCondition, Func<Permanent, bool> defenderCondition, Func<ICardEffect, bool> cardEffectCondition)
  11. {
  12. this.AttackerCondition = attackerCondition;
  13. this.DefenderCondition = defenderCondition;
  14. this.CardEffectCondition = cardEffectCondition;
  15. }
  16. public bool CanAttackTargetDefendingPermanent(Permanent Attacker, Permanent Defender, ICardEffect cardEffect)
  17. {
  18. if (Attacker != null && Defender != null)
  19. {
  20. if (Attacker.TopCard != null && Defender.TopCard != null)
  21. {
  22. if (AttackerCondition != null && DefenderCondition != null && CardEffectCondition != null)
  23. {
  24. if (AttackerCondition(Attacker) && DefenderCondition(Defender) && CardEffectCondition(cardEffect))
  25. {
  26. return true;
  27. }
  28. }
  29. }
  30. }
  31. return false;
  32. }
  33. }