From 0fc29302f41d2f751c1dc63a9f893273607a9ce1 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 15 Sep 2021 08:54:51 -0400 Subject: [PATCH] [MIC] Implemented Celebrate the Harvest --- .../src/mage/cards/c/CelebrateTheHarvest.java | 96 +++++++++++++++++++ .../src/mage/sets/MidnightHuntCommander.java | 1 + 2 files changed, 97 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java diff --git a/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java b/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java new file mode 100644 index 00000000000..47fcbcb28f7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CelebrateTheHarvest.java @@ -0,0 +1,96 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.common.CovenHint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CelebrateTheHarvest extends CardImpl { + + public CelebrateTheHarvest(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}"); + + // Search your library for up to X basic land cards, where X is the number of different powers among creatures you control. Put those cards onto the battlefield tapped, then shuffle. + this.getSpellAbility().addEffect(new CelebrateTheHarvestEffect()); + this.getSpellAbility().addHint(CovenHint.instance); + } + + private CelebrateTheHarvest(final CelebrateTheHarvest card) { + super(card); + } + + @Override + public CelebrateTheHarvest copy() { + return new CelebrateTheHarvest(this); + } +} + +class CelebrateTheHarvestEffect extends OneShotEffect { + + CelebrateTheHarvestEffect() { + super(Outcome.Benefit); + staticText = "search your library for up to X basic land cards, where X is the number of different powers " + + "among creatures you control. Put those cards onto the battlefield tapped, then shuffle"; + } + + private CelebrateTheHarvestEffect(final CelebrateTheHarvestEffect effect) { + super(effect); + } + + @Override + public CelebrateTheHarvestEffect copy() { + return new CelebrateTheHarvestEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int powerCount = game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + source.getControllerId(), source.getSourceId(), game + ) + .stream() + .filter(Objects::nonNull) + .map(MageObject::getPower) + .mapToInt(MageInt::getValue) + .distinct() + .map(x -> 1) + .sum(); + TargetCardInLibrary target = new TargetCardInLibrary(0, powerCount, StaticFilters.FILTER_CARD_BASIC_LAND); + player.searchLibrary(target, source, game); + Cards cards = new CardsImpl(); + target.getTargets() + .stream() + .map(cardId -> player.getLibrary().getCard(cardId, game)) + .forEach(cards::add); + player.moveCards( + cards.getCards(game), Zone.BATTLEFIELD, source, game, + true, false, true, null + ); + player.shuffleLibrary(source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MidnightHuntCommander.java b/Mage.Sets/src/mage/sets/MidnightHuntCommander.java index 006b0d437db..10cb23af0f5 100644 --- a/Mage.Sets/src/mage/sets/MidnightHuntCommander.java +++ b/Mage.Sets/src/mage/sets/MidnightHuntCommander.java @@ -35,6 +35,7 @@ public final class MidnightHuntCommander extends ExpansionSet { cards.add(new SetCardInfo("Bojuka Bog", 167, Rarity.COMMON, mage.cards.b.BojukaBog.class)); cards.add(new SetCardInfo("Butcher of Malakir", 107, Rarity.RARE, mage.cards.b.ButcherOfMalakir.class)); cards.add(new SetCardInfo("Canopy Vista", 168, Rarity.RARE, mage.cards.c.CanopyVista.class)); + cards.add(new SetCardInfo("Celebrate the Harvest", 24, Rarity.RARE, mage.cards.c.CelebrateTheHarvest.class)); cards.add(new SetCardInfo("Cemetery Reaper", 108, Rarity.RARE, mage.cards.c.CemeteryReaper.class)); cards.add(new SetCardInfo("Champion of Lambholt", 136, Rarity.RARE, mage.cards.c.ChampionOfLambholt.class)); cards.add(new SetCardInfo("Charcoal Diamond", 158, Rarity.COMMON, mage.cards.c.CharcoalDiamond.class));