IsMaxDP.cs 1.0 KB

12345678910111213141516171819202122232425
  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 IsMaxDP(Permanent permanent, Player owner, Func<Permanent, bool> permanentCondition)
  10. {
  11. if (permanent == null) return false;
  12. if (permanent.TopCard == null) return false;
  13. if (permanent.TopCard.Owner != owner) return false;
  14. if (!IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, permanent.TopCard)) return false;
  15. if (!permanent.TopCard.HasDP && (permanent.BaseDP <= 0)) return false;
  16. if (permanentCondition != null && !permanentCondition(permanent)) return false;
  17. List<int> DPs = permanent.TopCard.Owner.GetBattleAreaDigimons()
  18. .Filter(permanent1 => (permanent1.TopCard.HasDP || (permanent1.BaseDP > 0)) && (permanentCondition == null || permanentCondition(permanent1)))
  19. .Map(permanent1 => permanent1.DP);
  20. return DPs.Count >= 1 && permanent.DP == DPs.Max();
  21. }
  22. }