diff --git a/Mage.Sets/src/mage/cards/p/PlanarGenesis.java b/Mage.Sets/src/mage/cards/p/PlanarGenesis.java new file mode 100644 index 00000000000..fb3da5c3b05 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PlanarGenesis.java @@ -0,0 +1,75 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.effects.common.LookLibraryAndPickControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.PutCards; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class PlanarGenesis extends CardImpl { + + public PlanarGenesis(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{G}{U}"); + + // Look at the top four cards of your library. You may put a land card from among them onto the battlefield tapped. If you don't, put a card from among them into your hand. Put the rest on the bottom of your library in a random order. + this.getSpellAbility().addEffect(new PlanarGenesisEffect()); + } + + private PlanarGenesis(final PlanarGenesis card) { + super(card); + } + + @Override + public PlanarGenesis copy() { + return new PlanarGenesis(this); + } +} + +class PlanarGenesisEffect extends LookLibraryAndPickControllerEffect { + + PlanarGenesisEffect() { + super(4, 1, StaticFilters.FILTER_CARD_LAND, PutCards.BATTLEFIELD_TAPPED, PutCards.BOTTOM_RANDOM, true); + staticText = "Look at the top four cards of your library. You may put a land card from among them onto the battlefield tapped. " + + "If you don't, put a card from among them into your hand. Put the rest on the bottom of your library in a random order."; + } + + private PlanarGenesisEffect(final PlanarGenesisEffect effect) { + super(effect); + } + + @Override + public PlanarGenesisEffect copy() { + return new PlanarGenesisEffect(this); + } + + @Override + protected boolean actionWithPickedCards(Game game, Ability source, Player player, Cards pickedCards, Cards otherCards) { + boolean result = putPickedCards.moveCards(player, pickedCards, source, game); + if (pickedCards.isEmpty()) { + if (otherCards.size() >= 1) { + TargetCard target = new TargetCard(0, 1, Zone.LIBRARY, filter); + target.withChooseHint("to put " + PutCards.HAND.getMessage(false, false)); + if (player.chooseTarget(PutCards.HAND.getOutcome(), otherCards, target, source, game)) { + Cards toPutInHand = new CardsImpl(target.getTargets()); + result |= PutCards.HAND.moveCards(player, toPutInHand, source, game); + } + } + } + otherCards.retainZone(Zone.LIBRARY, game); + result |= putLookedCards.moveCards(player, otherCards, source, game); + return result; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index d26be7d62f4..0b1114a0e2e 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -189,6 +189,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Phyrexian Ironworks", 130, Rarity.UNCOMMON, mage.cards.p.PhyrexianIronworks.class)); cards.add(new SetCardInfo("Phyrexian Tower", 303, Rarity.MYTHIC, mage.cards.p.PhyrexianTower.class)); cards.add(new SetCardInfo("Plains", 304, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS)); + cards.add(new SetCardInfo("Planar Genesis", 198, Rarity.UNCOMMON, mage.cards.p.PlanarGenesis.class)); cards.add(new SetCardInfo("Polluted Delta", 224, Rarity.RARE, mage.cards.p.PollutedDelta.class)); cards.add(new SetCardInfo("Priest of Titania", 286, Rarity.UNCOMMON, mage.cards.p.PriestOfTitania.class)); cards.add(new SetCardInfo("Propagator Drone", 167, Rarity.UNCOMMON, mage.cards.p.PropagatorDrone.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java index c708182bf6c..332ff288d9c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LookLibraryAndPickControllerEffect.java @@ -114,6 +114,9 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff return actionWithPickedCards(game, source, player, pickedCards, cards); } + /** + * Can be overriden for additional effect + */ protected boolean actionWithPickedCards(Game game, Ability source, Player player, Cards pickedCards, Cards otherCards) { boolean result = putPickedCards.moveCards(player, pickedCards, source, game); result |= putLookedCards.moveCards(player, otherCards, source, game);