IsMinCost.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Linq;
  3. public partial class CardEffectCommons
  4. {
  5. public static bool IsMinCost(Permanent permanent, Player owner, bool IsDigimonOnly, Func<Permanent, bool> condition = null)
  6. {
  7. if (permanent == null) return false;
  8. if (permanent.TopCard == null) return false;
  9. if (permanent.TopCard.Owner != owner) return false;
  10. if (!IsPermanentExistsOnOwnerBattleArea(permanent, permanent.TopCard)) return false;
  11. if (!permanent.IsDigimon && !permanent.IsTamer) return false;
  12. if (condition != null && !condition(permanent)) return false;
  13. if (!permanent.TopCard.HasPlayCost) return false;
  14. if (IsDigimonOnly)
  15. {
  16. if (!permanent.IsDigimon) return false;
  17. var costs = permanent.TopCard.Owner.GetBattleAreaDigimons()
  18. .Filter(x => x.TopCard.HasPlayCost)
  19. .Select(x => x.TopCard.GetCostItself).ToList();
  20. return costs.Count >= 1 && permanent.TopCard.GetCostItself == costs.Min();
  21. }
  22. else
  23. {
  24. var costs = permanent.TopCard.Owner.GetBattleAreaPermanents()
  25. .Filter(x => (x.IsDigimon || x.IsTamer) && x.TopCard.HasPlayCost)
  26. .Select(x => x.TopCard.GetCostItself).ToList();
  27. return costs.Count >= 1 && permanent.TopCard.GetCostItself == costs.Min();
  28. }
  29. }
  30. }