diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 40dd05f68b..595ec0b5cc 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -242,8 +242,8 @@ public class HumanPlayer extends PlayerImpl { public boolean chooseTarget(Outcome outcome, Target target, Ability source, Game game) { updateGameStatePriority("chooseTarget", game); while (!abort) { - Set possibleTargets = target.possibleTargets(source==null?null:source.getId(), playerId, game); - boolean required = possibleTargets.size() == 0 ? false : target.isRequired(); + Set possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game); + boolean required = possibleTargets.isEmpty() ? false : target.isRequired(); game.fireSelectTargetEvent(playerId, target.getMessage(), possibleTargets, required, getOptions(target)); waitForResponse(); if (response.getUUID() != null) { diff --git a/Mage.Server/plugins/mage-player-human.jar b/Mage.Server/plugins/mage-player-human.jar index 61d79465e3..b10caac72a 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.Sets/src/mage/sets/innistrad/EvilTwin.java b/Mage.Sets/src/mage/sets/innistrad/EvilTwin.java index 3d410b3b88..a5aa08ca76 100644 --- a/Mage.Sets/src/mage/sets/innistrad/EvilTwin.java +++ b/Mage.Sets/src/mage/sets/innistrad/EvilTwin.java @@ -43,6 +43,8 @@ import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.continious.GainAbilitySourceEffect; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -53,6 +55,12 @@ import mage.target.common.TargetCreaturePermanent; */ public class EvilTwin extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with the same name as this creature"); + + static { + filter.add(new EvilTwinPredicate()); + } + public EvilTwin(UUID ownerId) { super(ownerId, 212, "Evil Twin", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{U}{B}"); this.expansionSetCode = "ISD"; @@ -67,7 +75,7 @@ public class EvilTwin extends CardImpl { Ability ability1 = new SimpleStaticAbility(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new CopyPermanentEffect(), "You may have {this} enter the battlefield as a copy of any creature on the battlefield except it gains {U}{B}, {T}: Destroy target creature with the same name as this creature")); Ability ability2 = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{U}{B}")); ability2.addCost(new TapSourceCost()); - ability2.addTarget(new TargetCreaturePermanent(new EvilTwinFilter())); + ability2.addTarget(new TargetCreaturePermanent(filter)); ability1.addEffect(new GainAbilitySourceEffect(ability2)); this.addAbility(ability1); } @@ -82,24 +90,18 @@ public class EvilTwin extends CardImpl { } } -class EvilTwinFilter extends FilterCreaturePermanent { +class EvilTwinPredicate implements ObjectSourcePlayerPredicate> { - public EvilTwinFilter() { - super("creature with the same name as this creature"); + @Override + public boolean apply(ObjectSourcePlayer input, Game game) { + Permanent permanent = input.getObject(); + Permanent twin = game.getPermanent(input.getSourceId()); + + return permanent != null && twin != null && permanent.getName().equals(twin.getName()); } @Override - public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { - if (!super.match(permanent, game)) - return notFilter; - - Permanent twin = game.getPermanent(sourceId); - if (twin != null) { - if (!permanent.getName().equals(twin.getName())) - return false; - } - - return !notFilter; + public String toString() { + return "SameNameAsSource"; } - } diff --git a/Mage/src/mage/target/Targets.java b/Mage/src/mage/target/Targets.java index 8dcb37cc03..2077fbd8ee 100644 --- a/Mage/src/mage/target/Targets.java +++ b/Mage/src/mage/target/Targets.java @@ -87,7 +87,7 @@ public class Targets extends ArrayList { public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, Game game) { if (this.size() > 0) { - if (!canChoose(source.getId(), playerId, game)) + if (!canChoose(source.getSourceId(), playerId, game)) return false; while (!isChosen()) { Target target = this.getUnchosen().get(0);