- Fixed Aura Swap bug #2025.

This commit is contained in:
jeff 2016-07-15 15:30:47 -05:00
parent 35c3753e56
commit bc1f4e409c
2 changed files with 25 additions and 25 deletions

View file

@ -93,23 +93,24 @@ class AcademyResearchersEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
FilterCard filterCardInHand = new FilterCard();
filterCardInHand.add(new SubtypePredicate("Aura"));
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent academyResearchers = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) { if (controller != null && academyResearchers != null) {
FilterCard filter = new FilterCard(); filterCardInHand.add(new AuraCardCanAttachToPermanentId(academyResearchers.getId()));
filter.add(new SubtypePredicate("Aura")); TargetCardInHand target = new TargetCardInHand(0, 1, filterCardInHand);
filter.add(new AuraCardCanAttachToPermanentId(permanent.getId()));
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Card auraInHand = game.getCard(target.getFirstTarget()); Card auraInHand = game.getCard(target.getFirstTarget());
if (auraInHand != null) { if (auraInHand != null) {
game.getState().setValue("attachTo:" + auraInHand.getId(), permanent); game.getState().setValue("attachTo:" + auraInHand.getId(), academyResearchers);
if (controller.moveCards(auraInHand, Zone.BATTLEFIELD, source, game)) { auraInHand.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), controller.getId());
permanent.addAttachment(auraInHand.getId(), game); if (academyResearchers.addAttachment(auraInHand.getId(), game)) {
game.informPlayers(controller.getLogName() + " put " + auraInHand.getLogName() + " on the battlefield attached to " + academyResearchers.getLogName() + ".");
return true;
} }
} }
} }
return true;
} }
return false; return false;
} }

View file

@ -50,7 +50,6 @@ public class AuraSwapAbility extends ActivatedAbilityImpl {
public AuraSwapAbility(ManaCost manaCost) { public AuraSwapAbility(ManaCost manaCost) {
super(Zone.BATTLEFIELD, new AuraSwapEffect(), manaCost); super(Zone.BATTLEFIELD, new AuraSwapEffect(), manaCost);
} }
public AuraSwapAbility(final AuraSwapAbility ability) { public AuraSwapAbility(final AuraSwapAbility ability) {
@ -72,12 +71,6 @@ public class AuraSwapAbility extends ActivatedAbilityImpl {
class AuraSwapEffect extends OneShotEffect { class AuraSwapEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard();
static {
filter.add(new SubtypePredicate("Aura"));
}
AuraSwapEffect() { AuraSwapEffect() {
super(Outcome.PutCardInPlay); super(Outcome.PutCardInPlay);
this.staticText = "Exchange this Aura with an Aura card in your hand."; this.staticText = "Exchange this Aura with an Aura card in your hand.";
@ -94,20 +87,26 @@ class AuraSwapEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
FilterCard filterCardToCheck = new FilterCard();
filterCardToCheck.add(new SubtypePredicate("Aura"));
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Permanent auraPermanent = game.getPermanent(source.getSourceId()); Permanent auraSourcePermanent = game.getPermanent(source.getSourceId());
if (auraPermanent != null && auraPermanent.getSubtype().contains("Aura") && auraPermanent.getOwnerId().equals(source.getControllerId())) { if (auraSourcePermanent != null
Permanent enchantedPermanent = game.getPermanent(auraPermanent.getAttachedTo()); && auraSourcePermanent.getSubtype().contains("Aura")
filter.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId())); && auraSourcePermanent.getOwnerId().equals(source.getControllerId())) {
TargetCardInHand target = new TargetCardInHand(0, 1, filter); Permanent enchantedPermanent = game.getPermanent(auraSourcePermanent.getAttachedTo());
filterCardToCheck.add(new AuraCardCanAttachToPermanentId(enchantedPermanent.getId()));
TargetCardInHand target = new TargetCardInHand(filterCardToCheck);
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) { if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Card auraInHand = game.getCard(target.getFirstTarget()); Card auraInHand = game.getCard(target.getFirstTarget());
if (auraInHand != null) { if (auraInHand != null) {
controller.moveCards(auraInHand, Zone.BATTLEFIELD, source, game); game.getState().setValue("attachTo:" + auraInHand.getId(), enchantedPermanent);
auraInHand.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), controller.getId());
enchantedPermanent.addAttachment(auraInHand.getId(), game); enchantedPermanent.addAttachment(auraInHand.getId(), game);
controller.moveCards(auraPermanent, Zone.HAND, source, game); game.informPlayers(controller.getLogName() + " put " + auraInHand.getLogName() + " on the battlefield attached to " + enchantedPermanent.getLogName() + ".");
return true; enchantedPermanent.removeAttachment(auraSourcePermanent.getId(), game);
return controller.moveCardToHandWithInfo(auraSourcePermanent, source.getSourceId(), game);
} }
} }
} }