* 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 mage.MageInt;
import mage.MageItem;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -41,7 +40,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterEnchantmentPermanent;
import mage.filter.predicate.ObjectSourcePlayer;
@ -65,14 +64,14 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class SimicGuildmage extends CardImpl {
private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("Aura");
private static final FilterEnchantmentPermanent auraFilter = new FilterEnchantmentPermanent("Aura");
static {
filter.add(new SubtypePredicate("Aura"));
auraFilter.add(new SubtypePredicate("Aura"));
}
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("Wizard");
this.power = new MageInt(2);
@ -93,12 +92,12 @@ public class SimicGuildmage extends CardImpl {
target2.setTargetTag(2);
countersAbility.addTarget(target2);
this.addAbility(countersAbility);
// {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}"));
auraAbility.addTarget(new TargetPermanent(filter));
auraAbility.addTarget(new TargetPermanent(auraFilter));
this.addAbility(auraAbility);
}
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.)
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());
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;
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(Predicates.not(new PermanentIdPredicate(fromPermanent.getId())));
Target chosenPermanentToAttachAuras = new TargetPermanent(filterChoice);
chosenPermanentToAttachAuras.setNotTarget(true);
chosenPermanentToAttachAuras.setTargetName("a different " + filterChoice.getMessage() + " with the same controller as the " + filterChoice.getMessage() + " the target aura is attached to");
if (chosenPermanentToAttachAuras.canChoose(source.getSourceId(), source.getControllerId(), game)
&& controller.choose(Outcome.Neutral, chosenPermanentToAttachAuras, source.getSourceId(), game)) {
Permanent permanentToAttachAuras = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget());
if (permanentToAttachAuras != 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;
}
}
Permanent permanentToAttachAura = game.getPermanent(chosenPermanentToAttachAuras.getFirstTarget());
if (permanentToAttachAura != null) {
// Check for protection
MageObject auraObject = game.getObject(auraId);
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
if (permanentToAttachAura.cantBeAttachedBy(aura, game)) {
passed = false;
}
}
if (passed) {
fromPermanent.removeAttachment(aura.getId(), game);
permanentToAttachAuras.addAttachment(aura.getId(), game);
permanentToAttachAura.addAttachment(aura.getId(), game);
return true;
}
}