Remove some obsolete (or possibly never correct) code from AuraReplacementEffect. Fixes #8859

This commit is contained in:
Alex W. Jackson 2022-04-19 01:26:00 -04:00
parent d745141b7b
commit 95056edf22
4 changed files with 18 additions and 42 deletions

View file

@ -84,8 +84,7 @@ class AccursedWitchReturnTransformedEffect extends OneShotEffect {
}
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
UUID secondFaceId = card.getSecondCardFace().getId();
game.getState().setValue("attachTo:" + secondFaceId, attachTo.getId());
game.getState().setValue("attachTo:" + source.getSourceId(), attachTo.getId());
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
attachTo.addAttachment(card.getId(), source, game);
}

View file

@ -96,8 +96,7 @@ class RadiantGraceEffect extends OneShotEffect {
}
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
UUID secondFaceId = game.getCard(source.getSourceId()).getSecondCardFace().getId();
game.getState().setValue("attachTo:" + secondFaceId, player.getId());
game.getState().setValue("attachTo:" + source.getSourceId(), player.getId());
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
player.addAttachment(card.getId(), source, game);
}

View file

@ -92,8 +92,7 @@ class VengefulStranglerEffect extends OneShotEffect {
}
game.getState().setValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + source.getSourceId(), Boolean.TRUE);
UUID secondFaceId = game.getCard(source.getSourceId()).getSecondCardFace().getId();
game.getState().setValue("attachTo:" + secondFaceId, permanent.getId());
game.getState().setValue("attachTo:" + source.getSourceId(), permanent);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
permanent.addAttachment(card.getId(), source, game);
}

View file

@ -2,7 +2,6 @@ package mage.abilities.effects;
import java.util.Locale;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.AttachEffect;
@ -14,16 +13,14 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.stack.StackAbility;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInGraveyard;
import static org.apache.log4j.LogMF.info;
/**
* Cards with the Aura subtype don't change the zone they are in, if there is no
* valid target on the battlefield. Also, when entering the battlefield and it
* was not cast (so from Zone != Hand), this effect gets the target to whitch to
* was not cast (so from Zone != Stack), this effect gets the target to which to
* attach it and adds the Aura the the battlefield and attachs it to the target.
* The "attachTo:" value in game state has to be set therefore.
* <p>
@ -63,15 +60,6 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
return false;
}
Card firstCardFace = null;
if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null) {
firstCardFace = card;
card = card.getSecondCardFace();
if (!card.isEnchantment(game) || !card.hasSubtype(SubType.AURA, game)) {
return false;
}
}
// Aura cards that go to battlefield face down (Manifest) don't have to select targets
if (card.isFaceDown(game)) {
return false;
@ -93,14 +81,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
}
UUID targetId = null;
MageObject sourceObject = game.getObject(event.getSourceId());
boolean enchantCardInGraveyard = false;
if (sourceObject instanceof StackAbility) {
StackAbility stackAbility = (StackAbility) sourceObject;
if (!stackAbility.getEffects().isEmpty()) {
targetId = stackAbility.getEffects().get(0).getTargetPointer().getFirst(game, stackAbility);
}
}
game.applyEffects(); // So continuousEffects are removed if previous effect of the same ability did move objects that cause continuous effects
Player controllingPlayer = null;
@ -153,12 +134,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
}
Player targetPlayer = game.getPlayer(targetId);
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
if (firstCardFace != null) {
// transforming card. remove first face (original card) from old zone
firstCardFace.removeFromZone(game, fromZone, source);
} else {
card.removeFromZone(game, fromZone, source);
}
card.removeFromZone(game, fromZone, source);
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, event.getPlayerId(), fromZone, Zone.BATTLEFIELD);
permanent.updateZoneChangeCounter(game, zoneChangeEvent);
@ -202,16 +178,19 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
&& (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) {
Card card = game.getCard(event.getTargetId());
return card != null && (card.isEnchantment(game) && card.hasSubtype(SubType.AURA, game)
|| // in case of transformable enchantments
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().isEnchantment(game)
&& card.getSecondCardFace().hasSubtype(SubType.AURA, game)));
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() != Zone.BATTLEFIELD || zEvent.getFromZone() == Zone.STACK) {
return false;
}
return false;
Card card = game.getCard(zEvent.getTargetId());
if (card == null) {
return false;
}
// in case of transformable enchantments
if (Boolean.TRUE.equals(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()))
&& card.getSecondCardFace() != null) {
card = card.getSecondCardFace();
}
return card.isEnchantment(game) && card.hasSubtype(SubType.AURA, game);
}
}