diff --git a/Mage.Sets/src/mage/cards/r/RemKarolusStalwartSlayer.java b/Mage.Sets/src/mage/cards/r/RemKarolusStalwartSlayer.java new file mode 100644 index 0000000000..daf36be95e --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RemKarolusStalwartSlayer.java @@ -0,0 +1,149 @@ +package mage.cards.r; + +import java.util.Set; +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.constants.*; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.game.stack.StackObject; +import mage.util.CardUtil; + +/** + * + * @author weirddan455 + */ +public final class RemKarolusStalwartSlayer extends CardImpl { + + public RemKarolusStalwartSlayer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Haste + this.addAbility(HasteAbility.getInstance()); + + // If a spell would deal damage to you or another permanent you control, prevent that damage. + this.addAbility(new SimpleStaticAbility(new RemKarolusStalwartSlayerPreventionEffect())); + + // If a spell would deal damage to an opponent or a permanent an opponent controls, it deals that much damage plus 1 instead. + this.addAbility(new SimpleStaticAbility(new RemKarolusStalwartSlayerReplacementEffect())); + } + + private RemKarolusStalwartSlayer(final RemKarolusStalwartSlayer card) { + super(card); + } + + @Override + public RemKarolusStalwartSlayer copy() { + return new RemKarolusStalwartSlayer(this); + } +} + +class RemKarolusStalwartSlayerPreventionEffect extends PreventionEffectImpl { + + public RemKarolusStalwartSlayerPreventionEffect() { + super(Duration.WhileOnBattlefield, Integer.MAX_VALUE, false, false); + staticText = "If a spell would deal damage to you or another permanent you control, prevent that damage"; + } + + private RemKarolusStalwartSlayerPreventionEffect(final RemKarolusStalwartSlayerPreventionEffect effect) { + super(effect); + } + + @Override + public RemKarolusStalwartSlayerPreventionEffect copy() { + return new RemKarolusStalwartSlayerPreventionEffect(this); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + UUID targetId = event.getTargetId(); + if (targetId.equals(source.getSourceId())) { + return false; + } + UUID controllerId = source.getControllerId(); + if (!targetId.equals(controllerId)) { + Permanent permanent = game.getPermanent(targetId); + if (permanent == null || !permanent.isControlledBy(controllerId)) { + return false; + } + } + 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; + } +} + +class RemKarolusStalwartSlayerReplacementEffect extends ReplacementEffectImpl { + + public RemKarolusStalwartSlayerReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Damage); + staticText = "If a spell would deal damage to an opponent or a permanent an opponent controls, it deals that much damage plus 1 instead"; + } + + private RemKarolusStalwartSlayerReplacementEffect(final RemKarolusStalwartSlayerReplacementEffect effect) { + super(effect); + } + + @Override + public RemKarolusStalwartSlayerReplacementEffect copy() { + return new RemKarolusStalwartSlayerReplacementEffect(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmount(CardUtil.overflowInc(event.getAmount(), 1)); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + switch(event.getType()) { + case DAMAGE_PERMANENT: + case DAMAGE_PLAYER: + return true; + default: + return false; + } + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + UUID targetId = event.getTargetId(); + Set opponents = game.getOpponents(source.getControllerId()); + if (!opponents.contains(targetId)) { + Permanent permanent = game.getPermanent(targetId); + if (permanent == null || !opponents.contains(permanent.getControllerId())) { + return false; + } + } + StackObject stackObject = game.getStack().getStackObject(event.getSourceId()); + if (stackObject == null) { + stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); + } + return stackObject instanceof Spell; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 7080025242..bab56d7fdf 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -241,6 +241,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Purifying Dragon", 155, Rarity.UNCOMMON, mage.cards.p.PurifyingDragon.class)); cards.add(new SetCardInfo("Raze the Effigy", 156, Rarity.COMMON, mage.cards.r.RazeTheEffigy.class)); cards.add(new SetCardInfo("Reckless Stormseeker", 157, Rarity.RARE, mage.cards.r.RecklessStormseeker.class)); + cards.add(new SetCardInfo("Rem Karolus, Stalwart Slayer", 235, Rarity.RARE, mage.cards.r.RemKarolusStalwartSlayer.class)); cards.add(new SetCardInfo("Return to Nature", 195, Rarity.COMMON, mage.cards.r.ReturnToNature.class)); cards.add(new SetCardInfo("Revenge of the Drowned", 72, Rarity.COMMON, mage.cards.r.RevengeOfTheDrowned.class)); cards.add(new SetCardInfo("Rise of the Ants", 196, Rarity.UNCOMMON, mage.cards.r.RiseOfTheAnts.class));