IsMaxCost.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. using System.Security;
  7. public partial class CardEffectCommons
  8. {
  9. public static bool IsMaxCost(Permanent permanent, Player owner, bool IsDigimonOnly)
  10. {
  11. if (permanent == null) return false;
  12. if (permanent.TopCard == null) return false;
  13. if (permanent.TopCard.Owner != owner) return false;
  14. if (!IsPermanentExistsOnOwnerBattleArea(permanent, permanent.TopCard)) return false;
  15. if (!permanent.IsDigimon && !permanent.IsTamer) return false;
  16. if (!permanent.TopCard.HasPlayCost) return false;
  17. List<Permanent> permanents = permanent.TopCard.Owner.GetBattleAreaPermanents();
  18. List<int> costs = new List<int>();
  19. if (IsDigimonOnly)
  20. {
  21. costs = permanent.TopCard.Owner.GetBattleAreaPermanents().Filter(permanent1 =>
  22. permanent1.IsDigimon && permanent1.TopCard.HasPlayCost)
  23. .Map(permanent1 => permanent1.TopCard.GetCostItself);
  24. }
  25. else
  26. {
  27. costs = permanent.TopCard.Owner.GetBattleAreaPermanents().Filter(permanent1 =>
  28. (permanent1.IsDigimon || permanent1.IsTamer) && permanent1.TopCard.HasPlayCost)
  29. .Map(permanent1 => permanent1.TopCard.GetCostItself);
  30. }
  31. return costs.Count >= 1 && permanent.TopCard.GetCostItself == costs.Max();
  32. }
  33. }