From de9cb3be753300f01cacd2eebe0ed05b17b2bd51 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 11 Jan 2019 21:47:07 -0500 Subject: [PATCH] Implemented Goblin Gathering --- .../src/mage/cards/g/GoblinGathering.java | 78 +++++++++++++++++++ .../src/mage/sets/RavnicaAllegiance.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GoblinGathering.java diff --git a/Mage.Sets/src/mage/cards/g/GoblinGathering.java b/Mage.Sets/src/mage/cards/g/GoblinGathering.java new file mode 100644 index 00000000000..3c6dec39ae2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GoblinGathering.java @@ -0,0 +1,78 @@ +package mage.cards.g; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.NamePredicate; +import mage.game.Game; +import mage.game.permanent.token.GoblinToken; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GoblinGathering extends CardImpl { + + public GoblinGathering(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}"); + + // Create a number of 1/1 red Goblin creature tokens equal to two plus the number of cards named Goblin Gathering in your graveyard. + this.getSpellAbility().addEffect(new CreateTokenEffect( + new GoblinToken(), GoblinGatheringDynamicValue.instance + )); + } + + private GoblinGathering(final GoblinGathering card) { + super(card); + } + + @Override + public GoblinGathering copy() { + return new GoblinGathering(this); + } +} + +enum GoblinGatheringDynamicValue implements DynamicValue { + + instance; + private static final FilterCard filter = new FilterCard(); + + static { + filter.add(new NamePredicate("Goblin Gathering")); + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + int amount = 0; + Player player = game.getPlayer(sourceAbility.getControllerId()); + if (player != null) { + amount += player.getGraveyard().count( + filter, sourceAbility.getSourceId(), + sourceAbility.getControllerId(), game + ); + } + return amount + 2; + } + + @Override + public GoblinGatheringDynamicValue copy() { + return instance; + } + + @Override + public String toString() { + return "1"; + } + + @Override + public String getMessage() { + return "two plus the number of cards named Goblin Gathering in your graveyard"; + } +} diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index 4d2f3fc61ee..65e576f8ba1 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -128,6 +128,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("Ghor-Clan Wrecker", 103, Rarity.COMMON, mage.cards.g.GhorClanWrecker.class)); cards.add(new SetCardInfo("Gift of Strength", 127, Rarity.COMMON, mage.cards.g.GiftOfStrength.class)); cards.add(new SetCardInfo("Glass of the Guildpact", 233, Rarity.RARE, mage.cards.g.GlassOfTheGuildpact.class)); + cards.add(new SetCardInfo("Goblin Gathering", 104, Rarity.COMMON, mage.cards.g.GoblinGathering.class)); cards.add(new SetCardInfo("Godless Shrine", 248, Rarity.RARE, mage.cards.g.GodlessShrine.class)); cards.add(new SetCardInfo("Grasping Thrull", 177, Rarity.COMMON, mage.cards.g.GraspingThrull.class)); cards.add(new SetCardInfo("Gravel-Hide Goblin", 105, Rarity.COMMON, mage.cards.g.GravelHideGoblin.class));