reworked auras which grant protection but don't remove themselves

This commit is contained in:
Evan Kranzler 2022-02-24 20:14:43 -05:00
parent 4024acdb28
commit eb4366013b
10 changed files with 125 additions and 231 deletions

View file

@ -1,36 +1,29 @@
package mage.cards.b;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class BlackWard extends CardImpl {
private static final FilterCard filter = new FilterCard("black");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
}
public BlackWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -38,12 +31,11 @@ public final class BlackWard extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from black. This effect doesn't remove Black Ward.
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from black. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
ProtectionAbility.from(ObjectColor.BLACK), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private BlackWard(final BlackWard card) {

View file

@ -1,36 +1,29 @@
package mage.cards.b;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class BlueWard extends CardImpl {
private static final FilterCard filter = new FilterCard("blue");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
}
public BlueWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -38,12 +31,11 @@ public final class BlueWard extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from blue. This effect doesn't remove Blue Ward.
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from blue. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
ProtectionAbility.from(ObjectColor.BLUE), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private BlueWard(final BlueWard card) {

View file

@ -1,10 +1,7 @@
package mage.cards.g;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class GreenWard extends CardImpl {
private static final FilterCard filter = new FilterCard("green");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
public GreenWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -42,12 +31,11 @@ public final class GreenWard extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from green. This effect doesn't remove Green Ward.
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from green. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
ProtectionAbility.from(ObjectColor.GREEN), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private GreenWard(final GreenWard card) {

View file

@ -1,56 +1,54 @@
package mage.cards.p;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.constants.*;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.FilterObject;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.effects.common.AttachEffect;
import mage.target.TargetPermanent;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author noahg
*/
public final class PledgeOfLoyalty extends CardImpl {
private static final FilterCard filter = new FilterCard("the colors of permanents you control");
static {
filter.add(PledgeOfLoyaltyPredicate.instance);
}
public PledgeOfLoyalty(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from the colors of permanents you control. This effect doesn't remove Pledge of Loyalty.
ProtectionAbility gainedAbility = new PledgeOfLoyaltyProtectionAbility();
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from the colors of permanents you control. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
new ProtectionAbility(filter), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private PledgeOfLoyalty(final PledgeOfLoyalty card) {
@ -61,73 +59,21 @@ public final class PledgeOfLoyalty extends CardImpl {
public PledgeOfLoyalty copy() {
return new PledgeOfLoyalty(this);
}
}
class PledgeOfLoyaltyProtectionAbility extends ProtectionAbility {
enum PledgeOfLoyaltyPredicate implements ObjectSourcePlayerPredicate<MageObject> {
instance;
public PledgeOfLoyaltyProtectionAbility() {
super(new FilterCard());
}
public PledgeOfLoyaltyProtectionAbility(final PledgeOfLoyaltyProtectionAbility ability) {
super(ability);
}
@Override
public PledgeOfLoyaltyProtectionAbility copy() {
return new PledgeOfLoyaltyProtectionAbility(this);
}
@Override
public boolean canTarget(MageObject source, Game game) {
ObjectColor color = new ObjectColor();
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(controllerId)) {
ObjectColor permanentColor = permanent.getColor(game);
if (permanentColor.isColorless()) {
continue;
}
if (permanentColor.isBlack()) {
color.setBlack(true);
}
if (permanentColor.isBlue()) {
color.setBlue(true);
}
if (permanentColor.isGreen()) {
color.setGreen(true);
}
if (permanentColor.isRed()) {
color.setRed(true);
}
if (permanentColor.isWhite()) {
color.setWhite(true);
}
}
List<Predicate<MageObject>> colorPredicates = new ArrayList<>();
if (color.isBlack()) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (color.isBlue()) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (color.isGreen()) {
colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (color.isRed()) {
colorPredicates.add(new ColorPredicate(ObjectColor.RED));
}
if (color.isWhite()) {
colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
}
Filter protectionFilter = new FilterObject("the colors of permanents you control");
protectionFilter.add(Predicates.or(colorPredicates));
this.filter = protectionFilter;
return super.canTarget(source, game);
}
@Override
public String getRule() {
return "{this} has protection from the colors of permanents you control.";
}
@Override
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
ObjectColor color = input.getObject().getColor(game);
return color.hasColor()
&& game
.getBattlefield()
.getActivePermanents(
StaticFilters.FILTER_CONTROLLED_PERMANENT,
input.getPlayerId(), input.getSourceId(), game
).stream()
.anyMatch(permanent -> permanent.getColor(game).shares(color));
}
}

View file

@ -1,10 +1,7 @@
package mage.cards.r;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class RedWard extends CardImpl {
private static final FilterCard filter = new FilterCard("red");
static {
filter.add(new ColorPredicate(ObjectColor.RED));
}
public RedWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -42,12 +31,10 @@ public final class RedWard extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from red. This effect doesn't remove Red Ward.
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from red. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
ProtectionAbility.from(ObjectColor.RED), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private RedWard(final RedWard card) {

View file

@ -1,9 +1,5 @@
package mage.cards.t;
import java.util.UUID;
import mage.constants.SubType;
import mage.target.common.TargetCreaturePermanent;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -12,31 +8,22 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.constants.Outcome;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class TattooWard extends CardImpl {
private static final FilterCard filter = new FilterCard("enchantments");
static {
filter.add(CardType.ENCHANTMENT.getPredicate());
}
public TattooWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}");
@ -46,20 +33,22 @@ public final class TattooWard extends CardImpl {
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature gets +1/+1 and has protection from enchantments. This effect doesn't remove Tattoo Ward.
Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield));
ProtectionAbility protectionAbility = new ProtectionAbility(filter);
protectionAbility.setAuraIdNotToBeRemoved(getId());
ability2.addEffect(new GainAbilityAttachedEffect(protectionAbility, AttachmentType.AURA, Duration.WhileOnBattlefield));
this.addAbility(ability2);
Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(
1, 1, Duration.WhileOnBattlefield
));
ability.addEffect(new GainAbilityAttachedEffect(
new ProtectionAbility(StaticFilters.FILTER_PERMANENT_ENCHANTMENTS),
AttachmentType.AURA, Duration.WhileOnBattlefield
).setDoesntRemoveItself(true));
this.addAbility(ability);
// Sacrifice Tattoo Ward: Destroy target enchantment.
Ability ability3 = new SimpleActivatedAbility(new DestroyTargetEffect(), new SacrificeSourceCost());
ability3.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ENCHANTMENT));
this.addAbility(ability3);
ability = new SimpleActivatedAbility(new DestroyTargetEffect(), new SacrificeSourceCost());
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_PERMANENT_ENCHANTMENT));
this.addAbility(ability);
}

View file

@ -1,10 +1,7 @@
package mage.cards.w;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
@ -13,28 +10,20 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.constants.SubType;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class WhiteWard extends CardImpl {
private static final FilterCard filter = new FilterCard("white");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
}
public WhiteWard(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.subtype.add(SubType.AURA);
// Enchant creature
@ -42,12 +31,11 @@ public final class WhiteWard extends CardImpl {
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Protect));
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted creature has protection from white. This effect doesn't remove White Ward.
ProtectionAbility gainedAbility = new ProtectionAbility(filter);
gainedAbility.setAuraIdNotToBeRemoved(this.getId());
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA);
effect.setText("Enchanted creature has protection from white. This effect doesn't remove {this}.");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect(
ProtectionAbility.from(ObjectColor.WHITE), AttachmentType.AURA
).setDoesntRemoveItself(true)));
}
private WhiteWard(final WhiteWard card) {

View file

@ -5,6 +5,7 @@ import mage.abilities.Mode;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.ProtectionAbility;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -19,6 +20,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
protected AttachmentType attachmentType;
protected boolean independentEffect;
protected String targetObjectName;
protected boolean doesntRemoveItself = false;
public GainAbilityAttachedEffect(Ability ability, AttachmentType attachmentType) {
this(ability, attachmentType, Duration.WhileOnBattlefield);
@ -62,6 +64,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
this.attachmentType = effect.attachmentType;
this.independentEffect = effect.independentEffect;
this.targetObjectName = effect.targetObjectName;
this.doesntRemoveItself = effect.doesntRemoveItself;
}
@Override
@ -82,7 +85,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = null;
Permanent permanent;
if (affectedObjectsSet) {
permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent == null) {
@ -93,9 +96,14 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) {
permanent = game.getPermanentOrLKIBattlefield(equipment.getAttachedTo());
} else {
permanent = null;
}
}
if (permanent != null) {
if (doesntRemoveItself && ability instanceof ProtectionAbility) {
((ProtectionAbility) ability).setAuraIdNotToBeRemoved(source.getSourceId());
}
permanent.addAbility(ability, source.getSourceId(), game);
afterGain(game, source, permanent, ability);
}
@ -114,6 +122,11 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
//
}
public GainAbilityAttachedEffect setDoesntRemoveItself(boolean doesntRemoveItself) {
this.doesntRemoveItself = doesntRemoveItself;
return this;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
@ -138,6 +151,9 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
if (!duration.toString().isEmpty()) {
sb.append(' ').append(duration);
}
if (doesntRemoveItself) {
sb.append(" This effect doesn't remove {this}.");
}
return sb.toString();
}
}

View file

@ -15,7 +15,6 @@ import mage.game.stack.StackObject;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

View file

@ -1204,14 +1204,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override
public boolean cantBeAttachedBy(MageObject attachment, Ability source, Game game, boolean silentMode) {
for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if (!(attachment.hasSubtype(SubType.AURA, game)
&& !ability.removesAuras())
&& !(attachment.hasSubtype(SubType.EQUIPMENT, game)
&& !ability.removesEquipment())) {
if (!attachment.getId().equals(ability.getAuraIdNotToBeRemoved())
&& !ability.canTarget(attachment, game)) {
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
}
if ((!attachment.hasSubtype(SubType.AURA, game) || ability.removesAuras())
&& (!attachment.hasSubtype(SubType.EQUIPMENT, game) || ability.removesEquipment())
&& !attachment.getId().equals(ability.getAuraIdNotToBeRemoved())
&& !ability.canTarget(attachment, game)) {
return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(attachment.getId()));
}
}
return game.getContinuousEffects().preventedByRuleModification(new StayAttachedEvent(this.getId(), attachment.getId(), source), null, game, silentMode);