IsMaxCost.cs 1.2 KB

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