From d1bd4401bc0374f0face89904fa636e5002cc5ae Mon Sep 17 00:00:00 2001 From: theelk801 Date: Tue, 9 Apr 2024 15:31:43 -0400 Subject: [PATCH] [PIP] Implement Perception Bobblehead --- .../mage/cards/p/PerceptionBobblehead.java | 102 ++++++++++++++++++ Mage.Sets/src/mage/sets/Fallout.java | 1 + 2 files changed, 103 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PerceptionBobblehead.java diff --git a/Mage.Sets/src/mage/cards/p/PerceptionBobblehead.java b/Mage.Sets/src/mage/cards/p/PerceptionBobblehead.java new file mode 100644 index 00000000000..252be857f2f --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PerceptionBobblehead.java @@ -0,0 +1,102 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.mana.AnyColorManaAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.*; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PerceptionBobblehead extends CardImpl { + + public PerceptionBobblehead(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.subtype.add(SubType.BOBBLEHEAD); + + // {T}: Add one mana of any color. + this.addAbility(new AnyColorManaAbility()); + + // {3}, {T}: Look at the top X cards of your library, where X is the number of Bobbleheads you control. You may cast a spell with mana value 3 or less from among them without paying its mana cost. Put the rest on the bottom of your library in a random order. + Ability ability = new SimpleActivatedAbility(new PerceptionBobbleheadEffect(), new GenericManaCost(3)); + ability.addCost(new TapSourceCost()); + this.addAbility(ability.addHint(PerceptionBobbleheadEffect.getHint())); + } + + private PerceptionBobblehead(final PerceptionBobblehead card) { + super(card); + } + + @Override + public PerceptionBobblehead copy() { + return new PerceptionBobblehead(this); + } +} + +class PerceptionBobbleheadEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.BOBBLEHEAD); + private static final FilterCard filter2 = new FilterCard(); + + static { + filter2.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 4)); + } + + private static final Hint hint = new ValueHint( + "Bobbleheads you control", new PermanentsOnBattlefieldCount(filter) + ); + + public static Hint getHint() { + return hint; + } + + PerceptionBobbleheadEffect() { + super(Outcome.Benefit); + staticText = "look at the top X cards of your library, where X is the number of Bobbleheads you control. " + + "You may cast a spell with mana value 3 or less from among them without paying its mana cost. " + + "Put the rest on the bottom of your library in a random order"; + } + + private PerceptionBobbleheadEffect(final PerceptionBobbleheadEffect effect) { + super(effect); + } + + @Override + public PerceptionBobbleheadEffect copy() { + return new PerceptionBobbleheadEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + int count = game.getBattlefield().count(filter, source.getControllerId(), source, game); + if (player == null || count < 1) { + return false; + } + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, count)); + CardUtil.castSpellWithAttributesForFree(player, source, game, cards, filter2); + cards.retainZone(Zone.LIBRARY, game); + player.putCardsOnBottomOfLibrary(cards, game, source, false); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Fallout.java b/Mage.Sets/src/mage/sets/Fallout.java index 12c11997724..e4a1a03ede2 100644 --- a/Mage.Sets/src/mage/sets/Fallout.java +++ b/Mage.Sets/src/mage/sets/Fallout.java @@ -218,6 +218,7 @@ public final class Fallout extends ExpansionSet { cards.add(new SetCardInfo("Panharmonicon", 237, Rarity.RARE, mage.cards.p.Panharmonicon.class)); cards.add(new SetCardInfo("Path of Ancestry", 279, Rarity.COMMON, mage.cards.p.PathOfAncestry.class)); cards.add(new SetCardInfo("Path to Exile", 169, Rarity.UNCOMMON, mage.cards.p.PathToExile.class)); + cards.add(new SetCardInfo("Perception Bobblehead", 139, Rarity.UNCOMMON, mage.cards.p.PerceptionBobblehead.class)); cards.add(new SetCardInfo("Pip-Boy 3000", 140, Rarity.RARE, mage.cards.p.PipBoy3000.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Pip-Boy 3000", 435, Rarity.RARE, mage.cards.p.PipBoy3000.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Pip-Boy 3000", 668, Rarity.RARE, mage.cards.p.PipBoy3000.class, NON_FULL_USE_VARIOUS));