From b139e5b0e1f180e79a0d2ac834f5ec2e663d7ed1 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 10 Apr 2020 21:52:23 -0400 Subject: [PATCH] Implemented Boot Nipper --- Mage.Sets/src/mage/cards/b/BootNipper.java | 40 +++++++++++++ Mage.Sets/src/mage/cards/h/HelicaGlider.java | 48 ++------------- .../src/mage/cards/w/WingfoldPteron.java | 48 ++------------- .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + .../counter/AddCounterChoiceSourceEffect.java | 60 +++++++++++++++++++ 5 files changed, 109 insertions(+), 88 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/b/BootNipper.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java diff --git a/Mage.Sets/src/mage/cards/b/BootNipper.java b/Mage.Sets/src/mage/cards/b/BootNipper.java new file mode 100644 index 00000000000..be5e5d3df15 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BootNipper.java @@ -0,0 +1,40 @@ +package mage.cards.b; + +import mage.MageInt; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.effects.common.counter.AddCounterChoiceSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BootNipper extends CardImpl { + + public BootNipper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}"); + + this.subtype.add(SubType.BEAST); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + // Boot Nipper enters the battlefield with your choice of a deathtouch counter or a lifelink counter on it. + this.addAbility(new EntersBattlefieldAbility( + new AddCounterChoiceSourceEffect(CounterType.DEATHTOUCH, CounterType.LIFELINK) + )); + } + + private BootNipper(final BootNipper card) { + super(card); + } + + @Override + public BootNipper copy() { + return new BootNipper(this); + } +} diff --git a/Mage.Sets/src/mage/cards/h/HelicaGlider.java b/Mage.Sets/src/mage/cards/h/HelicaGlider.java index 9c4dd93202c..5c85a861600 100644 --- a/Mage.Sets/src/mage/cards/h/HelicaGlider.java +++ b/Mage.Sets/src/mage/cards/h/HelicaGlider.java @@ -1,19 +1,13 @@ package mage.cards.h; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCounterChoiceSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.counters.Counter; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import java.util.UUID; @@ -31,7 +25,9 @@ public final class HelicaGlider extends CardImpl { this.toughness = new MageInt(2); // Helica Glider enters the battlfield with your choice of a flying counter or a first strike counter on it. - this.addAbility(new EntersBattlefieldAbility(new HelicaGliderEffect())); + this.addAbility(new EntersBattlefieldAbility( + new AddCounterChoiceSourceEffect(CounterType.FLYING, CounterType.FIRST_STRIKE) + )); } private HelicaGlider(final HelicaGlider card) { @@ -43,39 +39,3 @@ public final class HelicaGlider extends CardImpl { return new HelicaGlider(this); } } - -class HelicaGliderEffect extends OneShotEffect { - - HelicaGliderEffect() { - super(Outcome.Benefit); - staticText = "with your choice of a flying counter or a first strike counter on it"; - } - - private HelicaGliderEffect(final HelicaGliderEffect effect) { - super(effect); - } - - @Override - public HelicaGliderEffect copy() { - return new HelicaGliderEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentEntering(source.getSourceId()); - if (player == null || permanent == null) { - return false; - } - Counter counter; - if (player.chooseUse( - Outcome.Neutral, "Choose flying or first strike", null, - "Flying", "First strike", source, game - )) { - counter = CounterType.FLYING.createInstance(); - } else { - counter = CounterType.FIRST_STRIKE.createInstance(); - } - return permanent.addCounters(counter, source, game); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/w/WingfoldPteron.java b/Mage.Sets/src/mage/cards/w/WingfoldPteron.java index 7579646eca2..ee968dcc231 100644 --- a/Mage.Sets/src/mage/cards/w/WingfoldPteron.java +++ b/Mage.Sets/src/mage/cards/w/WingfoldPteron.java @@ -1,19 +1,13 @@ package mage.cards.w; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCounterChoiceSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.counters.Counter; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import java.util.UUID; @@ -30,7 +24,9 @@ public final class WingfoldPteron extends CardImpl { this.toughness = new MageInt(6); // Wingfold Pteron enters the battlefield with your choice of a flying counter or a hexproof counter on it. - this.addAbility(new EntersBattlefieldAbility(new WingfoldPteronEffect())); + this.addAbility(new EntersBattlefieldAbility( + new AddCounterChoiceSourceEffect(CounterType.FLYING, CounterType.HEXPROOF) + )); } private WingfoldPteron(final WingfoldPteron card) { @@ -42,39 +38,3 @@ public final class WingfoldPteron extends CardImpl { return new WingfoldPteron(this); } } - -class WingfoldPteronEffect extends OneShotEffect { - - WingfoldPteronEffect() { - super(Outcome.Benefit); - staticText = "with your choice of a flying counter or a hexproof counter on it"; - } - - private WingfoldPteronEffect(final WingfoldPteronEffect effect) { - super(effect); - } - - @Override - public WingfoldPteronEffect copy() { - return new WingfoldPteronEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentEntering(source.getSourceId()); - if (player == null || permanent == null) { - return false; - } - Counter counter; - if (player.chooseUse( - Outcome.Neutral, "Choose flying or hexproof", null, - "Flying", "Hexproof", source, game - )) { - counter = CounterType.FLYING.createInstance(); - } else { - counter = CounterType.HEXPROOF.createInstance(); - } - return permanent.addCounters(counter, source, game); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 924c51b69b0..df11135649b 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -83,6 +83,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Bonder's Enclave", 245, Rarity.RARE, mage.cards.b.BondersEnclave.class)); cards.add(new SetCardInfo("Boneyard Lurker", 178, Rarity.UNCOMMON, mage.cards.b.BoneyardLurker.class)); cards.add(new SetCardInfo("Boon of the Wish-Giver", 43, Rarity.UNCOMMON, mage.cards.b.BoonOfTheWishGiver.class)); + cards.add(new SetCardInfo("Boot Nipper", 76, Rarity.COMMON, mage.cards.b.BootNipper.class)); cards.add(new SetCardInfo("Bristling Boar", 146, Rarity.COMMON, mage.cards.b.BristlingBoar.class)); cards.add(new SetCardInfo("Bushmeat Poacher", 77, Rarity.COMMON, mage.cards.b.BushmeatPoacher.class)); cards.add(new SetCardInfo("Call of the Death-Dweller", 78, Rarity.UNCOMMON, mage.cards.c.CallOfTheDeathDweller.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java new file mode 100644 index 00000000000..a62cb8145c0 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCounterChoiceSourceEffect.java @@ -0,0 +1,60 @@ +package mage.abilities.effects.common.counter; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.counters.Counter; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * @author TheElk801 + */ +public class AddCounterChoiceSourceEffect extends OneShotEffect { + + private final CounterType counterType1; + private final CounterType counterType2; + + public AddCounterChoiceSourceEffect(CounterType counterType1, CounterType counterType2) { + super(Outcome.Benefit); + this.counterType1 = counterType1; + this.counterType2 = counterType2; + staticText = "with your choice of a " + counterType1 + " counter or a " + counterType2 + " counter on it"; + } + + private AddCounterChoiceSourceEffect(final AddCounterChoiceSourceEffect effect) { + super(effect); + this.counterType1 = effect.counterType1; + this.counterType2 = effect.counterType2; + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanentEntering(source.getSourceId()); + if (player == null || permanent == null) { + return false; + } + Counter counter; + if (player.chooseUse( + Outcome.Neutral, "Choose " + counterType1 + " or " + counterType2, null, + cap(counterType1.getName()), cap(counterType2.getName()), source, game + )) { + counter = counterType1.createInstance(); + } else { + counter = counterType2.createInstance(); + } + return permanent.addCounters(counter, source, game); + } + + private static final String cap(String string) { + return string != null ? string.substring(0, 1).toUpperCase() + string.substring(1) : null; + } + + @Override + public AddCounterChoiceSourceEffect copy() { + return new AddCounterChoiceSourceEffect(this); + } +}