* Simic Guildmage - Fixed that the aura moving ability eas not working (fixes #3319).

This commit is contained in:
LevelX2 2017-05-16 12:16:52 +02:00
parent 7dcfbd5be5
commit 7b61ad7455

View file

@ -30,7 +30,6 @@ package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.MageItem; import mage.MageItem;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
@ -41,7 +40,7 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterPermanent; import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterEnchantmentPermanent; import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayer;
@ -65,14 +64,14 @@ import mage.target.common.TargetCreaturePermanent;
*/ */
public class SimicGuildmage extends CardImpl { public class SimicGuildmage extends CardImpl {
private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("Aura"); private static final FilterEnchantmentPermanent auraFilter = new FilterEnchantmentPermanent("Aura");
static { static {
filter.add(new SubtypePredicate("Aura")); auraFilter.add(new SubtypePredicate("Aura"));
} }
public SimicGuildmage(UUID ownerId, CardSetInfo setInfo) { public SimicGuildmage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{G/U}{G/U}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G/U}{G/U}");
this.subtype.add("Elf"); this.subtype.add("Elf");
this.subtype.add("Wizard"); this.subtype.add("Wizard");
this.power = new MageInt(2); this.power = new MageInt(2);
@ -93,12 +92,12 @@ public class SimicGuildmage extends CardImpl {
target2.setTargetTag(2); target2.setTargetTag(2);
countersAbility.addTarget(target2); countersAbility.addTarget(target2);
this.addAbility(countersAbility); this.addAbility(countersAbility);
// {1}{U}: Attach target Aura enchanting a permanent to another permanent with the same controller. // {1}{U}: Attach target Aura enchanting a permanent to another permanent with the same controller.
Ability auraAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveAuraEffect(), new ManaCostsImpl("{1}{U}")); Ability auraAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MoveAuraEffect(), new ManaCostsImpl("{1}{U}"));
auraAbility.addTarget(new TargetPermanent(filter)); auraAbility.addTarget(new TargetPermanent(auraFilter));
this.addAbility(auraAbility); this.addAbility(auraAbility);
} }
public SimicGuildmage(final SimicGuildmage card) { public SimicGuildmage(final SimicGuildmage card) {
@ -201,40 +200,35 @@ class MoveAuraEffect extends OneShotEffect {
(It doesnt matter who controls the Aura or who controls Simic Guildmage.) (It doesnt matter who controls the Aura or who controls Simic Guildmage.)
If no such permanent exists, the Aura doesnt move. If no such permanent exists, the Aura doesnt move.
*/ */
UUID auraId = getTargetPointer().getFirst(game, source);
Permanent aura = game.getPermanent(auraId);
Permanent fromPermanent = game.getPermanent(aura.getAttachedTo());
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (fromPermanent != null && controller != null) { if (controller != null) {
Permanent aura = game.getPermanent(getTargetPointer().getFirst(game, source));
if (aura == null) {
return true;
}
Permanent fromPermanent = game.getPermanent(aura.getAttachedTo());
if (fromPermanent == null) {
return false;
}
boolean passed = true; boolean passed = true;
FilterPermanent filterChoice = new FilterPermanent("a different permanent with the same controller as the target to attach the enchantments to"); Target chosenPermanentToAttachAuras = aura.getSpellAbility().getTargets().get(0).copy();
chosenPermanentToAttachAuras.setNotTarget(true);
Filter filterChoice = chosenPermanentToAttachAuras.getFilter();
filterChoice.add(new ControllerIdPredicate(fromPermanent.getControllerId())); filterChoice.add(new ControllerIdPredicate(fromPermanent.getControllerId()));
filterChoice.add(Predicates.not(new PermanentIdPredicate(fromPermanent.getId()))); filterChoice.add(Predicates.not(new PermanentIdPredicate(fromPermanent.getId())));
chosenPermanentToAttachAuras.setTargetName("a different " + filterChoice.getMessage() + " with the same controller as the " + filterChoice.getMessage() + " the target aura is attached to");
Target chosenPermanentToAttachAuras = new TargetPermanent(filterChoice);
chosenPermanentToAttachAuras.setNotTarget(true);
if (chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game) if (chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game)
&& controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) { && controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) {
Permanent permanentToAttachAuras = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget()); Permanent permanentToAttachAura = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget());
if (permanentToAttachAuras != null) { if (permanentToAttachAura != null) {
if (aura != null && passed) {
// Check the target filter
Target target = aura.getSpellAbility().getTargets().get(0);
if (target instanceof TargetPermanent) {
if (!target.getFilter().match(permanentToAttachAuras, game)) {
passed = false;
}
}
// Check for protection // Check for protection
MageObject auraObject = game.getObject(auraId); if (permanentToAttachAura.cantBeAttachedBy(aura, game)) {
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
passed = false; passed = false;
} }
}
if (passed) { if (passed) {
fromPermanent.removeAttachment(aura.getId(), game); fromPermanent.removeAttachment(aura.getId(), game);
permanentToAttachAuras.addAttachment(aura.getId(), game); permanentToAttachAura.addAttachment(aura.getId(), game);
return true; return true;
} }
} }