From 465d8ba2540a5a49414bd2bb26d6ebde595c759d Mon Sep 17 00:00:00 2001 From: Thomas Winwood Date: Thu, 14 Mar 2019 13:04:34 +0000 Subject: [PATCH 1/2] Implement Benevolent Unicorn --- .../src/mage/cards/b/BenevolentUnicorn.java | 94 +++++++++++++++++++ Mage.Sets/src/mage/sets/Mirage.java | 1 + 2 files changed, 95 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java diff --git a/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java new file mode 100644 index 00000000000..7f46f771d15 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java @@ -0,0 +1,94 @@ + +package mage.cards.b; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; + +/** + * + * @author LoneFox, Ketsuban + + */ +public final class BenevolentUnicorn extends CardImpl { + + public BenevolentUnicorn(UUID ownerId, CardSetInfo setInfo) { + super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}"); + this.subtype.add(SubType.UNICORN); + + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + // If a spell would deal damage to a permanent or player, it deals that much damage minus 1 to that permanent or player instead. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BenevolentUnicornEffect())); + } + + public BenevolentUnicorn(final BenevolentUnicorn card) { + super(card); + } + + @Override + public BenevolentUnicorn copy() { + return new BenevolentUnicorn(this); + } +} + +class BenevolentUnicornEffect extends ReplacementEffectImpl { + + public BenevolentUnicornEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "If a spell would deal damage to a permanent or player, it deals that much damage minus 1 to that permanent or player instead."; + } + + public BenevolentUnicornEffect(final BenevolentUnicornEffect effect) { + super(effect); + } + + @Override + public BenevolentUnicornEffect copy() { + return new BenevolentUnicornEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(event.getAmount() - 1); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == EventType.DAMAGE_CREATURE || event.getType() == EventType.DAMAGE_PLANESWALKER || event.getType() == EventType.DAMAGE_PLAYER; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); + if (stackObject == null) { + stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); + } + if (stackObject instanceof Spell) { + return super.applies(event, source, game); + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index 4d54a97400f..cb2906dcdf1 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -45,6 +45,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Barbed-Back Wurm", 105, Rarity.UNCOMMON, mage.cards.b.BarbedBackWurm.class)); cards.add(new SetCardInfo("Bay Falcon", 54, Rarity.COMMON, mage.cards.b.BayFalcon.class)); cards.add(new SetCardInfo("Bazaar of Wonders", 55, Rarity.RARE, mage.cards.b.BazaarOfWonders.class)); + cards.add(new SetCardInfo("Benevolent Unicorn", 4, Rarity.COMMON, mage.cards.b.BenevolentUnicorn.class)); cards.add(new SetCardInfo("Benthic Djinn", 257, Rarity.RARE, mage.cards.b.BenthicDjinn.class)); cards.add(new SetCardInfo("Binding Agony", 106, Rarity.COMMON, mage.cards.b.BindingAgony.class)); cards.add(new SetCardInfo("Blighted Shaman", 107, Rarity.UNCOMMON, mage.cards.b.BlightedShaman.class)); From f794e9551d586202f6d134555aeb7e0c59f0a652 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Thu, 14 Mar 2019 19:45:03 +0400 Subject: [PATCH 2/2] Fix compilation error --- Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java index 7f46f771d15..c2297b646c0 100644 --- a/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java +++ b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java @@ -85,10 +85,7 @@ class BenevolentUnicornEffect extends ReplacementEffectImpl { if (stackObject == null) { stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); } - if (stackObject instanceof Spell) { - return super.applies(event, source, game); - } - return false; + return stackObject instanceof Spell; } }