From 88a1b9fe22aabdd99e1d46d62d70f01f9a0fadf9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 20 Dec 2019 19:35:27 -0500 Subject: [PATCH] Implemented Underworld Rage-Hound --- .../src/mage/cards/u/UnderworldRageHound.java | 43 +++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + .../abilities/common/EscapesWithAbility.java | 88 +++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/u/UnderworldRageHound.java create mode 100644 Mage/src/main/java/mage/abilities/common/EscapesWithAbility.java diff --git a/Mage.Sets/src/mage/cards/u/UnderworldRageHound.java b/Mage.Sets/src/mage/cards/u/UnderworldRageHound.java new file mode 100644 index 00000000000..8d3b03274e4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/u/UnderworldRageHound.java @@ -0,0 +1,43 @@ +package mage.cards.u; + +import mage.MageInt; +import mage.abilities.common.AttacksEachCombatStaticAbility; +import mage.abilities.keyword.EscapeAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class UnderworldRageHound extends CardImpl { + + public UnderworldRageHound(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); + + this.subtype.add(SubType.ELEMENTAL); + this.subtype.add(SubType.HOUND); + this.power = new MageInt(3); + this.toughness = new MageInt(1); + + // Underworld Rage-Hound attacks each combat if able. + this.addAbility(new AttacksEachCombatStaticAbility()); + + // Escape—{3}{R}, Exile three other cards from your graveyard. + this.addAbility(new EscapeAbility(this, "{3}{R}", 3)); + + // Underworld Rage-Hound escapes with a +1/+1 counter on it. + } + + private UnderworldRageHound(final UnderworldRageHound card) { + super(card); + } + + @Override + public UnderworldRageHound copy() { + return new UnderworldRageHound(this); + } +} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index de4e15adc2e..dcfb5edc379 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -57,6 +57,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Terror of Mount Velus", 295, Rarity.RARE, mage.cards.t.TerrorOfMountVelus.class)); cards.add(new SetCardInfo("The Akroan War", 124, Rarity.RARE, mage.cards.t.TheAkroanWar.class)); cards.add(new SetCardInfo("Treeshaker Chimera", 297, Rarity.RARE, mage.cards.t.TreeshakerChimera.class)); + cards.add(new SetCardInfo("Underworld Rage-Hound", 163, Rarity.COMMON, mage.cards.u.UnderworldRageHound.class)); cards.add(new SetCardInfo("Underworld Sentinel", 293, Rarity.COMMON, mage.cards.u.UnderworldSentinel.class)); cards.add(new SetCardInfo("Victory's Envoy", 289, Rarity.COMMON, mage.cards.v.VictorysEnvoy.class)); } diff --git a/Mage/src/main/java/mage/abilities/common/EscapesWithAbility.java b/Mage/src/main/java/mage/abilities/common/EscapesWithAbility.java new file mode 100644 index 00000000000..3635991e15b --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/EscapesWithAbility.java @@ -0,0 +1,88 @@ +package mage.abilities.common; + +import mage.abilities.Ability; +import mage.abilities.SpellAbility; +import mage.abilities.effects.EntersBattlefieldEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.EscapeAbility; +import mage.constants.AbilityType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class EscapesWithAbility extends EntersBattlefieldAbility { + + private final int counters; + + public EscapesWithAbility(int counters) { + super(new EscapesWithEffect(counters), false); + this.counters = counters; + } + + private EscapesWithAbility(final EscapesWithAbility ability) { + super(ability); + this.counters = ability.counters; + } + + @Override + public EscapesWithAbility copy() { + return new EscapesWithAbility(this); + } + + @Override + public String getRule() { + return "{this} escapes with " + CardUtil.numberToText(counters, "a") + + " +1/+1 counter" + (counters > 1 ? 's' : "") + " on it."; + } +} + +class EscapesWithEffect extends OneShotEffect { + + private final int counter; + + EscapesWithEffect(int counter) { + super(Outcome.BoostCreature); + this.counter = counter; + } + + private EscapesWithEffect(final EscapesWithEffect effect) { + super(effect); + this.counter = effect.counter; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null && source.getAbilityType() == AbilityType.STATIC) { + permanent = game.getPermanentEntering(source.getSourceId()); + } + if (permanent == null) { + return false; + } + SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); + if (!(spellAbility instanceof EscapeAbility) + || !spellAbility.getSourceId().equals(source.getSourceId()) + || permanent.getZoneChangeCounter(game) != spellAbility.getSourceObjectZoneChangeCounter() + || !spellAbility.getSourceId().equals(source.getSourceId())) { + return false; + } + List appliedEffects = (ArrayList) this.getValue("appliedEffects"); + permanent.addCounters(CounterType.P1P1.createInstance(counter), source, game, appliedEffects); + return true; + } + + @Override + public EscapesWithEffect copy() { + return new EscapesWithEffect(this); + } + +}