diff --git a/Mage.Sets/src/mage/cards/b/BoneMask.java b/Mage.Sets/src/mage/cards/b/BoneMask.java new file mode 100644 index 00000000000..77707ff083d --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BoneMask.java @@ -0,0 +1,94 @@ +package mage.cards.b; + +import java.util.Set; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.PreventionEffectData; +import mage.abilities.effects.PreventionEffectImpl; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.players.Player; +import mage.target.TargetSource; + +/** + * + * @author jeffwadsworth + */ +public final class BoneMask extends CardImpl { + + public BoneMask(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + // {2}, {tap}: The next time a source of your choice would deal damage to you this turn, prevent that damage. Exile cards from the top of your library equal to the damage prevented this way. + Ability ability = new SimpleActivatedAbility(new BoneMaskEffect(), new ManaCostsImpl("{2}")); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetSource()); + this.addAbility(ability); + + } + + private BoneMask(final BoneMask card) { + super(card); + } + + @Override + public BoneMask copy() { + return new BoneMask(this); + } +} + +class BoneMaskEffect extends PreventionEffectImpl { + + public BoneMaskEffect() { + super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false); + this.staticText = "The next time a source of your choice would deal damage to you this turn, prevent that damage. " + + "Exile cards from the top of your library equal to the damage prevented this way."; + } + + public BoneMaskEffect(final BoneMaskEffect effect) { + super(effect); + } + + @Override + public BoneMaskEffect copy() { + return new BoneMaskEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (!this.used + && super.applies(event, source, game)) { + if (event.getTargetId().equals(source.getControllerId()) + && event.getSourceId().equals(source.getFirstTarget())) { + PreventionEffectData preventionData = preventDamageAction(event, source, game); + this.used = true; + this.discard(); + if (preventionData.getPreventedDamage() > 0) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Set cardsToMoveToExileFromTopOfLibrary = controller.getLibrary().getTopCards( + game, + preventionData.getPreventedDamage()); + controller.moveCards(cardsToMoveToExileFromTopOfLibrary, Zone.EXILED, source, game); + } + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/cards/k/KithkinArmor.java b/Mage.Sets/src/mage/cards/k/KithkinArmor.java index 54b41dfee2e..1a43c262fcb 100644 --- a/Mage.Sets/src/mage/cards/k/KithkinArmor.java +++ b/Mage.Sets/src/mage/cards/k/KithkinArmor.java @@ -157,12 +157,16 @@ class KithkinArmorPreventionEffect extends PreventionEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game) && event instanceof DamageCreatureEvent - && event.getAmount() > 0) { + && event.getAmount() > 0 + && !this.used) { UUID enchantedCreatureId = (UUID) game.getState().getValue(source.getSourceId().toString() + "attachedToPermanent"); DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; if (enchantedCreatureId != null - && event.getTargetId().equals(enchantedCreatureId)) { - return (damageEvent.getSourceId().equals(source.getFirstTarget())); + && event.getTargetId().equals(enchantedCreatureId) + && damageEvent.getSourceId().equals(source.getFirstTarget())) { + this.used = true; + this.discard(); + return true; } } return false; diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index b81b18308df..4d54a97400f 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -51,6 +51,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Blinding Light", 5, Rarity.UNCOMMON, mage.cards.b.BlindingLight.class)); cards.add(new SetCardInfo("Blistering Barrier", 159, Rarity.COMMON, mage.cards.b.BlisteringBarrier.class)); cards.add(new SetCardInfo("Bone Harvest", 108, Rarity.COMMON, mage.cards.b.BoneHarvest.class)); + cards.add(new SetCardInfo("Bone Mask", 295, Rarity.RARE, mage.cards.b.BoneMask.class)); cards.add(new SetCardInfo("Boomerang", 56, Rarity.COMMON, mage.cards.b.Boomerang.class)); cards.add(new SetCardInfo("Breathstealer", 109, Rarity.COMMON, mage.cards.b.Breathstealer.class)); cards.add(new SetCardInfo("Brushwagg", 208, Rarity.RARE, mage.cards.b.Brushwagg.class));