[MKM] Implement Flourishing Bloom-Kin and move Cultivate-like searches to common class (#11837)

* Move Cultivate search effect to common class

* [MKM] Implement Flourishing Bloom-Kin

* Use TargetCardInLibrary, minor changes to improve readability

* Announce cards going to hand
This commit is contained in:
Cameron Merkel 2024-02-24 01:03:29 -06:00 committed by GitHub
parent e7516aa0f1
commit 4e24ef2e47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 190 additions and 357 deletions

View file

@ -1,20 +1,11 @@
package mage.cards.c;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.Set;
import java.util.UUID;
/**
@ -25,8 +16,9 @@ public final class Cultivate extends CardImpl {
public Cultivate(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library.
this.getSpellAbility().addEffect(new CultivateEffect());
// Search your library for up to two basic land cards, reveal those cards, put one onto the battlefield tapped and the other into your hand, then shuffle.
this.getSpellAbility().addEffect(new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(
new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LANDS)));
}
@ -40,63 +32,3 @@ public final class Cultivate extends CardImpl {
}
}
class CultivateEffect extends OneShotEffect {
protected static final FilterCard filter = new FilterCard("card to put on the battlefield tapped");
CultivateEffect() {
super(Outcome.PutLandInPlay);
staticText = "search your library for up to two basic land cards, reveal those cards, " +
"put one onto the battlefield tapped and the other into your hand, then shuffle";
}
private CultivateEffect(final CultivateEffect effect) {
super(effect);
}
@Override
public CultivateEffect copy() {
return new CultivateEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND);
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, source, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
}
Set<Card> cards = revealed.getCards(game);
card = cards.isEmpty() ? null : cards.iterator().next();
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
} else if (target.getTargets().size() == 1) {
Set<Card> cards = revealed.getCards(game);
Card card = cards.isEmpty() ? null : cards.iterator().next();
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
}

View file

@ -0,0 +1,71 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.TurnedFaceUpSourceTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.DisguiseAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.common.FilterControlledPermanent;
import mage.target.common.TargetCardInLibrary;
/**
* @author Cguy7777
*/
public final class FlourishingBloomKin extends CardImpl {
private static final FilterControlledPermanent filterForests = new FilterControlledPermanent(SubType.FOREST);
private static final FilterCard filterForestCards = new FilterCard("Forest cards");
static {
filterForestCards.add(SubType.FOREST.getPredicate());
}
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filterForests);
private static final Hint hint = new ValueHint("Forests you control", xValue);
public FlourishingBloomKin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}");
this.subtype.add(SubType.PLANT);
this.subtype.add(SubType.ELEMENTAL);
this.power = new MageInt(0);
this.toughness = new MageInt(0);
// Flourishing Bloom-Kin gets +1/+1 for each Forest you control.
Ability ability = new SimpleStaticAbility(new BoostSourceEffect(xValue, xValue, Duration.WhileOnBattlefield));
this.addAbility(ability.addHint(hint));
// Disguise {4}{G}
this.addAbility(new DisguiseAbility(this, new ManaCostsImpl<>("{4}{G}")));
// When Flourishing Bloom-Kin is turned face up, search your library for up to two Forest cards and reveal them.
// Put one of them onto the battlefield tapped and the other into your hand, then shuffle.
this.addAbility(new TurnedFaceUpSourceTriggeredAbility(
new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(new TargetCardInLibrary(0, 2, filterForestCards))
.setText("search your library for up to two Forest cards and reveal them. Put one of them onto the battlefield tapped and the other into your hand, then shuffle")));
}
private FlourishingBloomKin(final FlourishingBloomKin card) {
super(card);
}
@Override
public FlourishingBloomKin copy() {
return new FlourishingBloomKin(this);
}
}

View file

@ -1,21 +1,12 @@
package mage.cards.k;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.Set;
import java.util.UUID;
/**
@ -27,8 +18,9 @@ public final class KodamasReach extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
this.subtype.add(SubType.ARCANE);
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library.
this.getSpellAbility().addEffect(new KodamasReachEffect());
// Search your library for up to two basic land cards, reveal those cards, put one onto the battlefield tapped and the other into your hand, then shuffle.
this.getSpellAbility().addEffect(new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(
new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LANDS)));
}
private KodamasReach(final KodamasReach card) {
@ -40,70 +32,3 @@ public final class KodamasReach extends CardImpl {
return new KodamasReach(this);
}
}
class KodamasReachEffect extends OneShotEffect {
protected static final FilterCard filter = new FilterCard("card to put on the battlefield tapped");
public KodamasReachEffect() {
super(Outcome.PutLandInPlay);
staticText = "search your library for up to two basic land cards, reveal those cards, " +
"put one onto the battlefield tapped and the other into your hand, then shuffle";
}
private KodamasReachEffect(final KodamasReachEffect effect) {
super(effect);
}
@Override
public KodamasReachEffect copy() {
return new KodamasReachEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND);
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, source, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
}
Set<Card> cards = revealed.getCards(game);
card = cards.isEmpty() ? null : cards.iterator().next();
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
} else if (target.getTargets().size() == 1) {
Set<Card> cards = revealed.getCards(game);
Card card = cards.isEmpty() ? null : cards.iterator().next();
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
}

View file

@ -5,15 +5,11 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.filter.predicate.Predicates;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
@ -23,11 +19,21 @@ import java.util.UUID;
*/
public final class NavigationOrb extends CardImpl {
private static final FilterCard filter = new FilterCard("basic land cards and/or Gate cards");
static {
filter.add(Predicates.or(Predicates.and(
CardType.LAND.getPredicate(),
SuperType.BASIC.getPredicate()
), SubType.GATE.getPredicate()));
}
public NavigationOrb(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// {2}, {T}, Sacrifice Navigation Orb: Search your library for up to two basic land cards and/or Gate cards, reveal those cards, put one onto the battlefield tapped and the other into your hand, then shuffle.
Ability ability = new SimpleActivatedAbility(new NavigationOrbEffect(), new GenericManaCost(2));
Ability ability = new SimpleActivatedAbility(new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(
new TargetCardInLibrary(0, 2, filter)), new GenericManaCost(2));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
this.addAbility(ability);
@ -42,65 +48,3 @@ public final class NavigationOrb extends CardImpl {
return new NavigationOrb(this);
}
}
class NavigationOrbEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("basic land cards and/or Gate cards");
static {
filter.add(Predicates.or(Predicates.and(
CardType.LAND.getPredicate(),
SuperType.BASIC.getPredicate()
), SubType.GATE.getPredicate()));
}
NavigationOrbEffect() {
super(Outcome.Benefit);
staticText = "search your library for up to two basic land cards and/or Gate cards, reveal those cards, " +
"put one onto the battlefield tapped and the other into your hand, then shuffle";
}
private NavigationOrbEffect(final NavigationOrbEffect effect) {
super(effect);
}
@Override
public NavigationOrbEffect copy() {
return new NavigationOrbEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, filter);
player.searchLibrary(target, source, game);
Cards cards = new CardsImpl();
target.getTargets()
.stream()
.map(uuid -> player.getLibrary().getCard(uuid, game))
.forEach(cards::add);
player.revealCards(source, cards, game);
Card card;
switch (cards.size()) {
case 0:
player.shuffleLibrary(source, game);
return true;
case 1:
card = cards.getRandom(game);
break;
default:
TargetCard targetCard = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD);
targetCard.withChooseHint("To put onto the battlefield");
player.choose(outcome, cards, targetCard, source, game);
card = cards.get(targetCard.getFirstTarget(), game);
}
cards.remove(card);
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
player.moveCards(cards, Zone.HAND, source, game);
player.shuffleLibrary(source, game);
return true;
}
}

View file

@ -2,23 +2,15 @@
package mage.cards.n;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.common.SpellMasteryCondition;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
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.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
/**
@ -27,12 +19,24 @@ import mage.target.common.TargetCardInLibrary;
*/
public final class NissasPilgrimage extends CardImpl {
private static final FilterCard filter = new FilterCard("basic Forest cards");
static {
filter.add(SuperType.BASIC.getPredicate());
filter.add(SubType.FOREST.getPredicate());
}
public NissasPilgrimage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Search your library for up to two basic Forest cards, reveal those cards, and put one onto the battlefield tapped and the rest into your hand. Then shuffle your library.
// Search your library for up to two basic Forest cards, reveal those cards, and put one onto the battlefield tapped and the rest into your hand. Then shuffle.
// <i>Spell Mastery</i> &mdash; If there are two or more instant and/or sorcery cards in your graveyard, search your library for up to three basic Forest cards instead of two.
this.getSpellAbility().addEffect(new NissasPilgrimageEffect());
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(new TargetCardInLibrary(0, 3, filter)),
new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(new TargetCardInLibrary(0, 2, filter)),
SpellMasteryCondition.instance,
"Search your library for up to two basic Forest cards, reveal those cards, and put one onto the battlefield tapped and the rest into your hand. Then shuffle."
+ "<br><i>Spell mastery</i> &mdash; If there are two or more instant and/or sorcery cards in your graveyard, search your library for up to three basic Forest cards instead of two."));
}
private NissasPilgrimage(final NissasPilgrimage card) {
@ -44,57 +48,3 @@ public final class NissasPilgrimage extends CardImpl {
return new NissasPilgrimage(this);
}
}
class NissasPilgrimageEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("basic Forest card");
static {
filter.add(SuperType.BASIC.getPredicate());
filter.add(SubType.FOREST.getPredicate());
}
public NissasPilgrimageEffect() {
super(Outcome.Benefit);
this.staticText = "Search your library for up to two basic Forest cards, reveal those cards, and put one onto the battlefield tapped and the rest into your hand. Then shuffle."
+ "<br><i>Spell mastery</i> &mdash; If there are two or more instant and/or sorcery cards in your graveyard, search your library for up to three basic Forest cards instead of two.";
}
private NissasPilgrimageEffect(final NissasPilgrimageEffect effect) {
super(effect);
}
@Override
public NissasPilgrimageEffect copy() {
return new NissasPilgrimageEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
int number = 2;
if (SpellMasteryCondition.instance.apply(game, source)) {
number++;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, number, filter);
controller.searchLibrary(target, source, game);
if (!target.getTargets().isEmpty()) {
Cards cards = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), cards, game);
if (!cards.isEmpty()) {
Card card = cards.getRandom(game);
if (card != null) {
cards.remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.moveCards(cards, Zone.HAND, source, game);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
}

View file

@ -1,22 +1,13 @@
package mage.cards.p;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect;
import mage.abilities.effects.keyword.ScryEffect;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
import java.util.Set;
import java.util.UUID;
/**
@ -27,8 +18,10 @@ public final class Peregrination extends CardImpl {
public Peregrination(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}");
// Seach your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle your library, then scry 1.
this.getSpellAbility().addEffect(new PeregrinationEffect());
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle, then scry 1.
this.getSpellAbility().addEffect(new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(
new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LANDS))
.setText("search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle"));
Effect effect = new ScryEffect(1);
effect.concatBy(", then");
this.getSpellAbility().addEffect(effect);
@ -43,63 +36,3 @@ public final class Peregrination extends CardImpl {
return new Peregrination(this);
}
}
class PeregrinationEffect extends OneShotEffect {
protected static final FilterCard filter = new FilterCard("card to put on the battlefield tapped");
public PeregrinationEffect() {
super(Outcome.PutLandInPlay);
staticText = "Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Shuffle";
}
private PeregrinationEffect(final PeregrinationEffect effect) {
super(effect);
}
@Override
public PeregrinationEffect copy() {
return new PeregrinationEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (controller == null || sourceObject == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, StaticFilters.FILTER_CARD_BASIC_LAND);
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
revealed.add(card);
}
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() == 2) {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, source, game);
Card card = revealed.get(target2.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
Set<Card> cards = revealed.getCards(game);
card = cards.isEmpty() ? null : cards.iterator().next();
controller.moveCards(card, Zone.HAND, source, game);
} else if (target.getTargets().size() == 1) {
Set<Card> cards = revealed.getCards(game);
Card card = cards.isEmpty() ? null : cards.iterator().next();
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
}

View file

@ -105,6 +105,7 @@ public final class MurdersAtKarlovManor extends ExpansionSet {
cards.add(new SetCardInfo("Felonious Rage", 125, Rarity.COMMON, mage.cards.f.FeloniousRage.class));
cards.add(new SetCardInfo("Festerleech", 85, Rarity.UNCOMMON, mage.cards.f.Festerleech.class));
cards.add(new SetCardInfo("Flotsam // Jetsam", 247, Rarity.UNCOMMON, mage.cards.f.FlotsamJetsam.class));
cards.add(new SetCardInfo("Flourishing Bloom-Kin", 160, Rarity.UNCOMMON, mage.cards.f.FlourishingBloomKin.class));
cards.add(new SetCardInfo("Forensic Gadgeteer", 57, Rarity.RARE, mage.cards.f.ForensicGadgeteer.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forensic Gadgeteer", 342, Rarity.RARE, mage.cards.f.ForensicGadgeteer.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Forensic Researcher", 58, Rarity.UNCOMMON, mage.cards.f.ForensicResearcher.class));

View file

@ -0,0 +1,77 @@
package mage.abilities.effects.common.search;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.SearchEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
/**
* @author BetaSteward_at_googlemail.com, edited by Cguy7777
*/
public class SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect extends SearchEffect {
private static final FilterCard filter = new FilterCard("card to put on the battlefield tapped");
public SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(TargetCardInLibrary target) {
super(target, Outcome.PutLandInPlay);
staticText = "search your library for " + target.getDescription() +
", reveal those cards, put one onto the battlefield tapped and the other into your hand, then shuffle";
}
protected SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(final SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect effect) {
super(effect);
}
@Override
public SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect copy() {
return new SearchLibraryPutOneOntoBattlefieldTappedRestInHandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (controller == null || sourceObject == null) {
return false;
}
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), revealed, game);
if (target.getTargets().size() >= 2) {
TargetCardInLibrary targetCardToBattlefield = new TargetCardInLibrary(filter);
controller.choose(Outcome.PutLandInPlay, revealed, targetCardToBattlefield, source, game);
Card cardToBattlefield = revealed.get(targetCardToBattlefield.getFirstTarget(), game);
Cards cardsToHand = new CardsImpl(revealed);
if (cardToBattlefield != null) {
controller.moveCards(cardToBattlefield, Zone.BATTLEFIELD, source, game, true, false, false, null);
cardsToHand.remove(cardToBattlefield);
}
controller.moveCardsToHandWithInfo(cardsToHand, source, game, true);
} else if (target.getTargets().size() == 1) {
Cards cards = new CardsImpl(revealed);
Card cardToBattlefield = cards.getRandom(game);
if (cardToBattlefield != null) {
controller.moveCards(cardToBattlefield, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
}