diff --git a/Mage.Sets/src/mage/cards/b/BenevolentBlessing.java b/Mage.Sets/src/mage/cards/b/BenevolentBlessing.java new file mode 100644 index 00000000000..f3ef8527b29 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BenevolentBlessing.java @@ -0,0 +1,61 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.ChooseColorEffect; +import mage.abilities.effects.keyword.ProtectionChosenColorAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +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 TheElk801 + */ +public final class BenevolentBlessing extends CardImpl { + + public BenevolentBlessing(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + + this.subtype.add(SubType.AURA); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // 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); + + // As Benevolent Blessing enters the battlefield, choose a color. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Benefit))); + + // Enchanted creature has protection from the chosen color. This effect doesn't remove Auras and Equipment you control that are already attached to it. + this.addAbility(new SimpleStaticAbility( + new ProtectionChosenColorAttachedEffect(false) + .setNotRemoveControlled(true) + .setText("Enchanted creature has protection from the chosen color. This effect doesn't " + + "remove Auras and Equipment you control that are already attached to it.") + )); + } + + private BenevolentBlessing(final BenevolentBlessing card) { + super(card); + } + + @Override + public BenevolentBlessing copy() { + return new BenevolentBlessing(this); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 95a0dc53f20..e56e3cf04f8 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -69,6 +69,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Azure Fleet Admiral", 58, Rarity.COMMON, mage.cards.a.AzureFleetAdmiral.class)); cards.add(new SetCardInfo("Beast Within", 423, Rarity.UNCOMMON, mage.cards.b.BeastWithin.class)); cards.add(new SetCardInfo("Belbe, Corrupted Observer", 270, Rarity.RARE, mage.cards.b.BelbeCorruptedObserver.class)); + cards.add(new SetCardInfo("Benevolent Blessing", 13, Rarity.COMMON, mage.cards.b.BenevolentBlessing.class)); cards.add(new SetCardInfo("Biowaste Blob", 219, Rarity.RARE, mage.cards.b.BiowasteBlob.class)); cards.add(new SetCardInfo("Bitter Revelation", 109, Rarity.COMMON, mage.cards.b.BitterRevelation.class)); cards.add(new SetCardInfo("Blackblade Reforged", 457, Rarity.RARE, mage.cards.b.BlackbladeReforged.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java index 0779d8c9ffc..8520d285d68 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/ProtectionChosenColorAttachedEffect.java @@ -15,14 +15,14 @@ import mage.game.Game; import mage.game.permanent.Permanent; /** - * * @author LevelX2 */ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl { protected ObjectColor chosenColor; protected ProtectionAbility protectionAbility; - protected boolean notRemoveItself; + protected final boolean notRemoveItself; + protected boolean notRemoveControlled; public ProtectionChosenColorAttachedEffect(boolean notRemoveItself) { super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); @@ -59,6 +59,11 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl { if (notRemoveItself) { protectionAbility.setAuraIdNotToBeRemoved(source.getSourceId()); } + if (notRemoveControlled) { + protectionAbility.setDoesntRemoveControlled(true); + protectionAbility.setRemoveEquipment(false); + protectionAbility.setRemovesAuras(false); + } } if (protectionAbility != null) { Permanent attachedTo = game.getPermanent(attachement.getAttachedTo()); @@ -70,4 +75,9 @@ public class ProtectionChosenColorAttachedEffect extends ContinuousEffectImpl { } return false; } + + public ProtectionChosenColorAttachedEffect setNotRemoveControlled(boolean notRemoveControlled) { + this.notRemoveControlled = notRemoveControlled; + return this; + } } diff --git a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java index 8d4cd79bb80..500560a71fa 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ProtectionAbility.java @@ -25,6 +25,8 @@ public class ProtectionAbility extends StaticAbility { protected Filter filter; protected boolean removeAuras; + protected boolean removeEquipment; + protected boolean doesntRemoveControlled; protected static List colors = new ArrayList<>(); protected UUID auraIdNotToBeRemoved; // defines an Aura objectId that will not be removed from this protection ability @@ -32,6 +34,8 @@ public class ProtectionAbility extends StaticAbility { super(Zone.BATTLEFIELD, null); this.filter = filter; this.removeAuras = true; + this.removeEquipment = true; + this.doesntRemoveControlled = false; this.auraIdNotToBeRemoved = null; } @@ -39,6 +43,8 @@ public class ProtectionAbility extends StaticAbility { super(ability); this.filter = ability.filter.copy(); this.removeAuras = ability.removeAuras; + this.removeEquipment = ability.removeEquipment; + this.doesntRemoveControlled = ability.doesntRemoveControlled; this.auraIdNotToBeRemoved = ability.auraIdNotToBeRemoved; } @@ -97,14 +103,14 @@ public class ProtectionAbility extends StaticAbility { return true; } } - + // Emrakul, the Aeons Torn if (filter instanceof FilterStackObject) { if (filter.match(source, game)) { return (!source.isInstantOrSorcery()); } } - + if (filter instanceof FilterObject) { return !filter.match(source, game); } @@ -138,6 +144,22 @@ public class ProtectionAbility extends StaticAbility { return removeAuras; } + public void setRemoveEquipment(boolean removeEquipment) { + this.removeEquipment = removeEquipment; + } + + public boolean removesEquipment() { + return removeEquipment; + } + + public void setDoesntRemoveControlled(boolean doesntRemoveControlled) { + this.doesntRemoveControlled = doesntRemoveControlled; + } + + public boolean getDoesntRemoveControlled() { + return doesntRemoveControlled; + } + public List getColors() { return colors; } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index f60c34f77e7..912983a0b15 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -1104,9 +1104,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) { if (!(source.hasSubtype(SubType.AURA, game) && !ability.removesAuras()) - && !source.getId().equals(ability.getAuraIdNotToBeRemoved()) - && !ability.canTarget(source, game)) { - return true; + && !(source.hasSubtype(SubType.EQUIPMENT, game) + && !ability.removesEquipment())) { + if (!source.getId().equals(ability.getAuraIdNotToBeRemoved()) + && !ability.canTarget(source, game)) { + return !ability.getDoesntRemoveControlled() || isControlledBy(game.getControllerId(source.getId())); + } } } return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, silentMode);