From 42a9aed977a3b031b0c4febd2e7166565db9c53b Mon Sep 17 00:00:00 2001
From: LevelX2 <ludwig.hirth@online.de>
Date: Sun, 29 Dec 2019 14:20:24 +0100
Subject: [PATCH] * Tragic Arrogance - Fixed a problem that under some
 circumstances permanents of the wrong player were sacrificed.

---
 .../src/mage/cards/t/TragicArrogance.java     |  5 +-
 .../java/mage/game/permanent/Battlefield.java | 50 +++++++++----------
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/Mage.Sets/src/mage/cards/t/TragicArrogance.java b/Mage.Sets/src/mage/cards/t/TragicArrogance.java
index c06a92a7e3..9e8f0dc4c7 100644
--- a/Mage.Sets/src/mage/cards/t/TragicArrogance.java
+++ b/Mage.Sets/src/mage/cards/t/TragicArrogance.java
@@ -1,4 +1,3 @@
-
 package mage.cards.t;
 
 import java.util.HashSet;
@@ -10,10 +9,10 @@ import mage.cards.CardImpl;
 import mage.cards.CardSetInfo;
 import mage.constants.CardType;
 import mage.constants.Outcome;
+import mage.filter.StaticFilters;
 import mage.filter.common.FilterArtifactPermanent;
 import mage.filter.common.FilterCreaturePermanent;
 import mage.filter.common.FilterEnchantmentPermanent;
-import mage.filter.common.FilterNonlandPermanent;
 import mage.filter.common.FilterPlaneswalkerPermanent;
 import mage.filter.predicate.permanent.ControllerIdPredicate;
 import mage.game.Game;
@@ -127,7 +126,7 @@ class TragicArroganceffect extends OneShotEffect {
             for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
                 Player player = game.getPlayer(playerId);
                 if (player != null) {
-                    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent(), game)) {
+                    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENTS_NON_LAND, playerId, game)) {
                         if (!choosenPermanent.contains(permanent)) {
                             permanent.sacrifice(playerId, game);
                         }
diff --git a/Mage/src/main/java/mage/game/permanent/Battlefield.java b/Mage/src/main/java/mage/game/permanent/Battlefield.java
index 178880baa6..6aacd3e45f 100644
--- a/Mage/src/main/java/mage/game/permanent/Battlefield.java
+++ b/Mage/src/main/java/mage/game/permanent/Battlefield.java
@@ -1,15 +1,14 @@
 package mage.game.permanent;
 
-import mage.abilities.keyword.PhasingAbility;
-import mage.constants.CardType;
-import mage.constants.RangeOfInfluence;
-import mage.filter.FilterPermanent;
-import mage.game.Game;
-
 import java.io.Serializable;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.stream.Collectors;
+import mage.abilities.keyword.PhasingAbility;
+import mage.constants.CardType;
+import mage.constants.RangeOfInfluence;
+import mage.filter.FilterPermanent;
+import mage.game.Game;
 
 /**
  * @author BetaSteward_at_googlemail.com
@@ -58,8 +57,8 @@ public class Battlefield implements Serializable {
         return (int) field.values()
                 .stream()
                 .filter(permanent -> permanent.isControlledBy(controllerId)
-                        && filter.match(permanent, game)
-                        && permanent.isPhasedIn())
+                && filter.match(permanent, game)
+                && permanent.isPhasedIn())
                 .count();
 
     }
@@ -69,8 +68,8 @@ public class Battlefield implements Serializable {
      * influence of the specified player id and that match the supplied filter.
      *
      * @param filter
-     * @param sourceId       - sourceId of the MageObject the calling effect/ability
-     *                       belongs to
+     * @param sourceId - sourceId of the MageObject the calling effect/ability
+     * belongs to
      * @param sourcePlayerId
      * @param game
      * @return count
@@ -80,15 +79,15 @@ public class Battlefield implements Serializable {
             return (int) field.values()
                     .stream()
                     .filter(permanent -> filter.match(permanent, sourceId, sourcePlayerId, game)
-                            && permanent.isPhasedIn())
+                    && permanent.isPhasedIn())
                     .count();
         } else {
             List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
             return (int) field.values()
                     .stream()
                     .filter(permanent -> range.contains(permanent.getControllerId())
-                            && filter.match(permanent, sourceId, sourcePlayerId, game)
-                            && permanent.isPhasedIn()).count();
+                    && filter.match(permanent, sourceId, sourcePlayerId, game)
+                    && permanent.isPhasedIn()).count();
         }
     }
 
@@ -105,7 +104,7 @@ public class Battlefield implements Serializable {
         return field.values()
                 .stream()
                 .filter(permanent -> filter.match(permanent, game)
-                        && permanent.isPhasedIn()).count() >= num;
+                && permanent.isPhasedIn()).count() >= num;
 
     }
 
@@ -124,8 +123,8 @@ public class Battlefield implements Serializable {
         return field.values()
                 .stream()
                 .filter(permanent -> permanent.isControlledBy(controllerId)
-                        && filter.match(permanent, game)
-                        && permanent.isPhasedIn())
+                && filter.match(permanent, game)
+                && permanent.isPhasedIn())
                 .count() >= num;
 
     }
@@ -145,14 +144,14 @@ public class Battlefield implements Serializable {
         if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
             return field.values().stream()
                     .filter(permanent -> filter.match(permanent, null, sourcePlayerId, game)
-                            && permanent.isPhasedIn()).count() >= num;
+                    && permanent.isPhasedIn()).count() >= num;
 
         } else {
             List<UUID> range = game.getState().getPlayersInRange(sourcePlayerId, game);
             return field.values().stream()
                     .filter(permanent -> range.contains(permanent.getControllerId())
-                            && filter.match(permanent, null, sourcePlayerId, game)
-                            && permanent.isPhasedIn())
+                    && filter.match(permanent, null, sourcePlayerId, game)
+                    && permanent.isPhasedIn())
                     .count() >= num;
         }
     }
@@ -212,7 +211,7 @@ public class Battlefield implements Serializable {
         return field.values()
                 .stream()
                 .filter(perm -> perm.isPhasedIn()
-                        && perm.isControlledBy(controllerId))
+                && perm.isControlledBy(controllerId))
                 .collect(Collectors.toList());
     }
 
@@ -233,7 +232,8 @@ public class Battlefield implements Serializable {
 
     /**
      * Returns all {@link Permanent} on the battlefield that match the supplied
-     * filter. This method ignores the range of influence. It's ignore controllers preficate
+     * filter. This method ignores the range of influence. It ignores controller
+     * predicates
      *
      * @param filter
      * @param game
@@ -300,7 +300,7 @@ public class Battlefield implements Serializable {
             return field.values()
                     .stream()
                     .filter(perm -> perm.isPhasedIn() && range.contains(perm.getControllerId())
-                            && filter.match(perm, sourceId, sourcePlayerId, game)).collect(Collectors.toList());
+                    && filter.match(perm, sourceId, sourcePlayerId, game)).collect(Collectors.toList());
         }
     }
 
@@ -321,7 +321,7 @@ public class Battlefield implements Serializable {
             return field.values()
                     .stream()
                     .filter(perm -> perm.isPhasedIn()
-                            && range.contains(perm.getControllerId()))
+                    && range.contains(perm.getControllerId()))
                     .collect(Collectors.toList());
 
         }
@@ -331,8 +331,8 @@ public class Battlefield implements Serializable {
         return field.values()
                 .stream()
                 .filter(perm -> perm.getAbilities().containsKey(PhasingAbility.getInstance().getId())
-                        && perm.isPhasedIn() &&
-                        perm.isControlledBy(controllerId))
+                && perm.isPhasedIn()
+                && perm.isControlledBy(controllerId))
                 .collect(Collectors.toList());
     }