implement [MH3] Planar Genesis

This commit is contained in:
Susucre 2024-06-01 17:42:46 +02:00
parent 64265bc2dd
commit d1e12595d9
3 changed files with 79 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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));

View file

@ -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);