diff --git a/Mage.Server/plugins/mage-player-ai-ma.jar b/Mage.Server/plugins/mage-player-ai-ma.jar index 1e83097c7f..494b6c25f7 100644 Binary files a/Mage.Server/plugins/mage-player-ai-ma.jar and b/Mage.Server/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Server/plugins/mage-player-ai.jar b/Mage.Server/plugins/mage-player-ai.jar index 25e0686986..f181f2319c 100644 Binary files a/Mage.Server/plugins/mage-player-ai.jar and b/Mage.Server/plugins/mage-player-ai.jar differ diff --git a/Mage.Server/plugins/mage-player-aiminimax.jar b/Mage.Server/plugins/mage-player-aiminimax.jar index bc9fe15ec9..9e56bc44a1 100644 Binary files a/Mage.Server/plugins/mage-player-aiminimax.jar and b/Mage.Server/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Server/plugins/mage-player-human.jar b/Mage.Server/plugins/mage-player-human.jar index 6c73a6b704..f01cf42b7f 100644 Binary files a/Mage.Server/plugins/mage-player-human.jar and b/Mage.Server/plugins/mage-player-human.jar differ diff --git a/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java b/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java index 08235191ce..eed89572f8 100644 --- a/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantTargetControlledEffect.java @@ -89,7 +89,7 @@ public class CantTargetControlledEffect extends ReplacementEffectImpl { UUID controllerId = source.getControllerId(); List permanents = game.getBattlefield().getAllActivePermanents(); for (Permanent permanent : permanents) { - if (filter.match(permanent, controllerId, game)) { + if (filter.match(permanent, source.getSourceId(), controllerId, game)) { permanent.addCounters(counter.copy()); applied = true; } diff --git a/Mage/src/mage/filter/FilterInPlay.java b/Mage/src/mage/filter/FilterInPlay.java index 5e9a2bfc12..f74b577e31 100644 --- a/Mage/src/mage/filter/FilterInPlay.java +++ b/Mage/src/mage/filter/FilterInPlay.java @@ -29,6 +29,8 @@ package mage.filter; import java.util.UUID; + +import mage.abilities.Ability; import mage.game.Game; /** @@ -37,7 +39,7 @@ import mage.game.Game; */ public interface FilterInPlay extends Filter { - public boolean match(E o, UUID playerId, Game game); + public boolean match(E o, UUID sourceId, UUID playerId, Game game); @Override public FilterInPlay copy(); diff --git a/Mage/src/mage/filter/FilterObject.java b/Mage/src/mage/filter/FilterObject.java index 8275f5244b..9653e9ea81 100644 --- a/Mage/src/mage/filter/FilterObject.java +++ b/Mage/src/mage/filter/FilterObject.java @@ -73,6 +73,11 @@ public class FilterObject> ex protected UUID id; protected boolean notId; + /** + * Indicates that filter shouldn't match the source. + */ + protected boolean another; + @Override public FilterObject copy() { return new FilterObject(this); @@ -125,6 +130,7 @@ public class FilterObject> ex this.toughnessComparison = filter.toughnessComparison; this.id = filter.id; this.notId = filter.notId; + this.another = filter.another; } @Override @@ -323,4 +329,11 @@ public class FilterObject> ex this.notId = notId; } + public boolean isAnother() { + return another; + } + + public void setAnother(boolean another) { + this.another = another; + } } diff --git a/Mage/src/mage/filter/FilterPermanent.java b/Mage/src/mage/filter/FilterPermanent.java index 042b8c9b46..af7106e1b2 100644 --- a/Mage/src/mage/filter/FilterPermanent.java +++ b/Mage/src/mage/filter/FilterPermanent.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import mage.Constants.TargetController; +import mage.abilities.Ability; import mage.game.Game; import mage.game.permanent.Permanent; @@ -109,7 +110,7 @@ public class FilterPermanent> extends FilterObject< return !notFilter; } - public boolean match(Permanent permanent, UUID playerId, Game game) { + public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (!this.match(permanent)) return notFilter; @@ -130,6 +131,13 @@ public class FilterPermanent> extends FilterObject< } } + if (another) { + // filter out itself + if (permanent.getId().equals(sourceId)) { + return notFilter; + } + } + return !notFilter; } diff --git a/Mage/src/mage/filter/FilterPlayer.java b/Mage/src/mage/filter/FilterPlayer.java index e8a7bac99b..7df285d135 100644 --- a/Mage/src/mage/filter/FilterPlayer.java +++ b/Mage/src/mage/filter/FilterPlayer.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import mage.Constants.TargetController; +import mage.abilities.Ability; import mage.game.Game; import mage.players.Player; @@ -67,7 +68,7 @@ public class FilterPlayer extends FilterImpl implements Fi return !notFilter; } - public boolean match(Player player, UUID playerId, Game game) { + public boolean match(Player player, UUID sourceId, UUID playerId, Game game) { if (!this.match(player)) return notFilter; diff --git a/Mage/src/mage/filter/common/FilterCreatureOrPlayer.java b/Mage/src/mage/filter/common/FilterCreatureOrPlayer.java index ae20f89747..a477139bba 100644 --- a/Mage/src/mage/filter/common/FilterCreatureOrPlayer.java +++ b/Mage/src/mage/filter/common/FilterCreatureOrPlayer.java @@ -29,6 +29,8 @@ package mage.filter.common; import java.util.UUID; + +import mage.abilities.Ability; import mage.filter.Filter; import mage.filter.FilterImpl; import mage.filter.FilterInPlay; @@ -82,12 +84,12 @@ public class FilterCreatureOrPlayer extends FilterImpl range = game.getPlayer(sourcePlayerId).getInRange(); for (Permanent permanent: field.values()) { - if (range.contains(permanent.getControllerId()) && filter.match(permanent, sourcePlayerId, game)) { + if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game)) { count++; } } @@ -193,7 +193,7 @@ public class Battlefield implements Serializable { int count = 0; if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { for (Permanent permanent: field.values()) { - if (filter.match(permanent, sourcePlayerId, game)) { + if (filter.match(permanent, null, sourcePlayerId, game)) { count++; if (num == count) return true; @@ -203,7 +203,7 @@ public class Battlefield implements Serializable { else { Set range = game.getPlayer(sourcePlayerId).getInRange(); for (Permanent permanent: field.values()) { - if (range.contains(permanent.getControllerId()) && filter.match(permanent, sourcePlayerId, game)) { + if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game)) { count++; if (num == count) return true; @@ -352,14 +352,14 @@ public class Battlefield implements Serializable { List active = new ArrayList(); if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) { for (Permanent perm: field.values()) { - if (perm.isPhasedIn() && filter.match(perm, sourcePlayerId, game)) + if (perm.isPhasedIn() && filter.match(perm, null, sourcePlayerId, game)) active.add(perm); } } else { Set range = game.getPlayer(sourcePlayerId).getInRange(); for (Permanent perm: field.values()) { - if (perm.isPhasedIn() && range.contains(perm.getControllerId()) && filter.match(perm, sourcePlayerId, game)) + if (perm.isPhasedIn() && range.contains(perm.getControllerId()) && filter.match(perm, null, sourcePlayerId, game)) active.add(perm); } } diff --git a/Mage/src/mage/target/TargetImpl.java b/Mage/src/mage/target/TargetImpl.java index 9596498a99..f73ce9fe06 100644 --- a/Mage/src/mage/target/TargetImpl.java +++ b/Mage/src/mage/target/TargetImpl.java @@ -102,6 +102,9 @@ public abstract class TargetImpl> implements Target { } return sb.toString(); } + if (targetName.startsWith("another")) { + return "Select " + targetName; + } return "Select a " + targetName; } diff --git a/Mage/src/mage/target/TargetPermanent.java b/Mage/src/mage/target/TargetPermanent.java index a5b2ec24ae..8714747818 100644 --- a/Mage/src/mage/target/TargetPermanent.java +++ b/Mage/src/mage/target/TargetPermanent.java @@ -82,9 +82,9 @@ public class TargetPermanent> extends TargetObject< if (permanent != null) { if (source != null) //TODO: check for replacement effects - return permanent.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(permanent, controllerId, game); + return permanent.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(permanent, source.getSourceId(), controllerId, game); else - return filter.match(permanent, controllerId, game); + return filter.match(permanent, null, controllerId, game); } return false; } diff --git a/Mage/src/mage/target/common/TargetCreatureOrPlayer.java b/Mage/src/mage/target/common/TargetCreatureOrPlayer.java index 033bd88d5c..d04bcf4f57 100644 --- a/Mage/src/mage/target/common/TargetCreatureOrPlayer.java +++ b/Mage/src/mage/target/common/TargetCreatureOrPlayer.java @@ -99,9 +99,9 @@ public class TargetCreatureOrPlayer extends TargetImpl { if (permanent != null) { if (source != null) //TODO: check for replacement effects - return permanent.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(permanent, controllerId, game); + return permanent.canBeTargetedBy(game.getObject(source.getSourceId())) && filter.match(permanent, source.getSourceId(), controllerId, game); else - return filter.match(permanent, controllerId, game); + return filter.match(permanent, source.getSourceId(), controllerId, game); } Player player = game.getPlayer(id); if (player != null) @@ -134,7 +134,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceId, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -163,7 +163,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (filter.match(permanent, sourceControllerId, game)) { + if (filter.match(permanent, null, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -183,7 +183,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } @@ -200,7 +200,7 @@ public class TargetCreatureOrPlayer extends TargetImpl { } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (filter.match(permanent, sourceControllerId, game)) { + if (filter.match(permanent, null, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } diff --git a/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java b/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java index af932aecbc..18ce9c6404 100644 --- a/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java +++ b/Mage/src/mage/target/common/TargetCreatureOrPlayerAmount.java @@ -85,7 +85,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount= this.minNumberOfTargets) return true; @@ -132,7 +132,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount= this.minNumberOfTargets) return true; @@ -152,7 +152,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount MageObject targetSource = game.getObject(source.getSourceId()); if (permanent != null) { if (source != null) - return permanent.canBeTargetedBy(targetSource) && filter.match(permanent, source.getControllerId(), game); + return permanent.canBeTargetedBy(targetSource) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game); else return filter.match(permanent); } @@ -144,7 +144,7 @@ public class TargetPermanentOrPlayer extends TargetImpl } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceId, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -173,7 +173,7 @@ public class TargetPermanentOrPlayer extends TargetImpl } } for (Permanent permanent: game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, game)) { - if (filter.match(permanent, sourceControllerId, game)) { + if (filter.match(permanent, null, sourceControllerId, game)) { count++; if (count >= this.minNumberOfTargets) return true; @@ -193,7 +193,7 @@ public class TargetPermanentOrPlayer extends TargetImpl } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceControllerId, game)) { + if (permanent.canBeTargetedBy(targetSource) && filter.match(permanent, sourceId, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } } @@ -210,7 +210,7 @@ public class TargetPermanentOrPlayer extends TargetImpl } } for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) { - if (filter.match(permanent, sourceControllerId, game)) { + if (filter.match(permanent, null, sourceControllerId, game)) { possibleTargets.add(permanent.getId()); } }