IsMinCost.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 IsMinCost(Permanent permanent, Player owner, bool IsDigimonOnly, Func<Permanent, bool> condition = null)
  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 (condition != null && !condition(permanent)) return false;
  17. if (!permanent.TopCard.HasPlayCost) return false;
  18. List<Permanent> permanents = permanent.TopCard.Owner.GetBattleAreaPermanents();
  19. List<int> costs = new List<int>();
  20. if (IsDigimonOnly)
  21. {
  22. costs = permanents
  23. .Filter(permanent1 => condition == null || (condition != null && condition(permanent1)))
  24. .Filter(permanent1 => permanent1.IsDigimon && permanent1.TopCard.HasPlayCost)
  25. .Map(permanent1 => permanent1.TopCard.GetCostItself);
  26. }
  27. else
  28. {
  29. costs = permanents
  30. .Filter(permanent1 => condition == null || (condition != null && condition(permanent1)))
  31. .Filter(permanent1 => (permanent1.IsDigimon || permanent1.IsTamer) && permanent1.TopCard.HasPlayCost)
  32. .Map(permanent1 => permanent1.TopCard.GetCostItself);
  33. }
  34. return costs.Count >= 1 && permanent.TopCard.GetCostItself == costs.Min();
  35. }
  36. }