From dcc1430b60a2cd11417f86c0545f556e0c14fcf9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 24 Jun 2020 18:44:53 -0400 Subject: [PATCH] Implemented Muxus, Goblin Grandee --- .../src/mage/cards/m/MuxusGoblinGrandee.java | 115 ++++++++++++++++++ Mage.Sets/src/mage/sets/Jumpstart.java | 1 + 2 files changed, 116 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MuxusGoblinGrandee.java diff --git a/Mage.Sets/src/mage/cards/m/MuxusGoblinGrandee.java b/Mage.Sets/src/mage/cards/m/MuxusGoblinGrandee.java new file mode 100644 index 00000000000..ca54830561e --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MuxusGoblinGrandee.java @@ -0,0 +1,115 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.game.Game; +import mage.players.Player; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MuxusGoblinGrandee extends CardImpl { + + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.GOBLIN); + + static { + filter.add(AnotherPredicate.instance); + } + + private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter); + + public MuxusGoblinGrandee(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.GOBLIN); + this.subtype.add(SubType.NOBLE); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // When Muxus, Goblin Grandee enters the battlefield, reveal the top six cards of your library. Put all Goblin creature cards with converted mana cost 5 or less from among them onto the battlefield and the rest on the bottom of your library in a random order. + this.addAbility(new EntersBattlefieldTriggeredAbility(new MuxusGoblinGrandeeEffect())); + + // Whenever Muxus attacks, it gets +1/+1 until end of turn for each other Goblin you control. + this.addAbility(new AttacksTriggeredAbility(new BoostSourceEffect( + xValue, xValue, Duration.EndOfTurn + ).setText("it gets +1/+1 until end of turn for each other Goblin you control"), false)); + } + + private MuxusGoblinGrandee(final MuxusGoblinGrandee card) { + super(card); + } + + @Override + public MuxusGoblinGrandee copy() { + return new MuxusGoblinGrandee(this); + } +} + +class MuxusGoblinGrandeeEffect extends OneShotEffect { + + MuxusGoblinGrandeeEffect() { + super(Outcome.Benefit); + staticText = "reveal the top six cards of your library. " + + "Put all Goblin creature cards with converted mana cost 5 or less " + + "from among them onto the battlefield and the rest on the bottom of your library in a random order."; + } + + private MuxusGoblinGrandeeEffect(final MuxusGoblinGrandeeEffect effect) { + super(effect); + } + + @Override + public MuxusGoblinGrandeeEffect copy() { + return new MuxusGoblinGrandeeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6)); + player.revealCards(source, cards, game); + Cards toBattlfield = new CardsImpl(); + Cards toBottom = new CardsImpl(); + cards.getCards(game) + .stream() + .filter(Objects::nonNull) + .forEach(card -> { + if (card.isCreature() + && card.hasSubtype(SubType.GOBLIN, game) + && card.getConvertedManaCost() <= 5) { + toBattlfield.add(card); + } else { + toBottom.add(card); + } + }); + player.moveCards(toBattlfield, Zone.BATTLEFIELD, source, game); + // need to account for effects like Grafdigger's Cage + toBattlfield + .stream() + .filter(uuid -> game.getState().getZone(uuid) == Zone.LIBRARY) + .forEach(toBottom::add); + player.putCardsOnBottomOfLibrary(toBottom, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Jumpstart.java b/Mage.Sets/src/mage/sets/Jumpstart.java index b45f4c159e9..b028b780562 100644 --- a/Mage.Sets/src/mage/sets/Jumpstart.java +++ b/Mage.Sets/src/mage/sets/Jumpstart.java @@ -292,6 +292,7 @@ public final class Jumpstart extends ExpansionSet { cards.add(new SetCardInfo("Mountain", 62, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Mugging", 352, Rarity.COMMON, mage.cards.m.Mugging.class)); cards.add(new SetCardInfo("Murmuring Phantasm", 157, Rarity.COMMON, mage.cards.m.MurmuringPhantasm.class)); + cards.add(new SetCardInfo("Muxus, Goblin Grandee", 24, Rarity.RARE, mage.cards.m.MuxusGoblinGrandee.class)); cards.add(new SetCardInfo("Myr Sire", 475, Rarity.COMMON, mage.cards.m.MyrSire.class)); cards.add(new SetCardInfo("Mystic Archaeologist", 158, Rarity.RARE, mage.cards.m.MysticArchaeologist.class)); cards.add(new SetCardInfo("Narcolepsy", 159, Rarity.COMMON, mage.cards.n.Narcolepsy.class));