From 193182aa3dfaa4000274b04e417fa161da86f7d6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Oct 2019 19:42:09 -0400 Subject: [PATCH] Implemented Mtenda Lion --- Mage.Sets/src/mage/cards/m/MtendaLion.java | 78 +++++++++++++++++++ Mage.Sets/src/mage/sets/Mirage.java | 1 + .../PreventCombatDamageBySourceEffect.java | 22 ++---- 3 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/m/MtendaLion.java diff --git a/Mage.Sets/src/mage/cards/m/MtendaLion.java b/Mage.Sets/src/mage/cards/m/MtendaLion.java new file mode 100644 index 0000000000..cdda060084 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MtendaLion.java @@ -0,0 +1,78 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PreventCombatDamageBySourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MtendaLion extends CardImpl { + + public MtendaLion(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}"); + + this.subtype.add(SubType.CAT); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // Whenever Mtenda Lion attacks, defending player may pay {U}. If that player does, prevent all combat damage that would be dealt by Mtenda Lion this turn. + this.addAbility(new AttacksTriggeredAbility(new MtendaLionEffect(), false)); + } + + private MtendaLion(final MtendaLion card) { + super(card); + } + + @Override + public MtendaLion copy() { + return new MtendaLion(this); + } +} + +class MtendaLionEffect extends OneShotEffect { + + MtendaLionEffect() { + super(Outcome.Benefit); + staticText = "defending player may pay {U}. If that player does, " + + "prevent all combat damage that would be dealt by {this} this turn."; + } + + private MtendaLionEffect(final MtendaLionEffect effect) { + super(effect); + } + + @Override + public MtendaLionEffect copy() { + return new MtendaLionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(source.getSourceId(), game)); + if (player == null) { + return false; + } + Cost cost = new ManaCostsImpl("{U}"); + if (!player.chooseUse(outcome, "Pay {U} to prevent damage?", source, game) + || !cost.pay(source, game, source.getSourceId(), player.getId(), false)) { + return false; + } + game.addEffect(new PreventCombatDamageBySourceEffect(Duration.EndOfTurn), source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index 2ec6544413..c71f19c42e 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -208,6 +208,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Mountain", 346, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mtenda Griffin", 28, Rarity.UNCOMMON, mage.cards.m.MtendaGriffin.class)); cards.add(new SetCardInfo("Mtenda Herder", 29, Rarity.COMMON, mage.cards.m.MtendaHerder.class)); + cards.add(new SetCardInfo("Mtenda Lion", 128, Rarity.COMMON, mage.cards.m.MtendaLion.class)); cards.add(new SetCardInfo("Mystical Tutor", 80, Rarity.UNCOMMON, mage.cards.m.MysticalTutor.class)); cards.add(new SetCardInfo("Natural Balance", 231, Rarity.RARE, mage.cards.n.NaturalBalance.class)); cards.add(new SetCardInfo("Nettletooth Djinn", 232, Rarity.UNCOMMON, mage.cards.n.NettletoothDjinn.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventCombatDamageBySourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventCombatDamageBySourceEffect.java index 5c9c3fbb91..6f7abdc467 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventCombatDamageBySourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventCombatDamageBySourceEffect.java @@ -1,5 +1,3 @@ - - package mage.abilities.effects.common; import mage.abilities.Ability; @@ -9,33 +7,27 @@ import mage.game.Game; import mage.game.events.GameEvent; /** - * * @author jeffwadsworth */ public class PreventCombatDamageBySourceEffect extends PreventionEffectImpl { public PreventCombatDamageBySourceEffect(Duration duration) { - super(duration, Integer.MAX_VALUE, true); - staticText = "Prevent all combat damage that would be dealt by {this}" + duration.toString(); + super(duration, Integer.MAX_VALUE, true); + staticText = "Prevent all combat damage that would be dealt by {this}" + duration.toString(); } public PreventCombatDamageBySourceEffect(final PreventCombatDamageBySourceEffect effect) { - super(effect); + super(effect); } @Override public PreventCombatDamageBySourceEffect copy() { - return new PreventCombatDamageBySourceEffect(this); + return new PreventCombatDamageBySourceEffect(this); } @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game)) { - if (event.getSourceId().equals(source.getSourceId())) { - return true; - } - } - return false; + return super.applies(event, source, game) + && event.getSourceId().equals(source.getSourceId()); } - -} \ No newline at end of file +}