Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 4 additions & 72 deletions Mage.Sets/src/mage/cards/c/Cultivate.java
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -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)));

}

Expand All @@ -40,63 +32,3 @@ public Cultivate copy() {
}

}

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;

}

}
71 changes: 71 additions & 0 deletions Mage.Sets/src/mage/cards/f/FlourishingBloomKin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
83 changes: 4 additions & 79 deletions Mage.Sets/src/mage/cards/k/KodamasReach.java
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -27,8 +18,9 @@ public KodamasReach(UUID ownerId, CardSetInfo setInfo) {
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) {
Expand All @@ -40,70 +32,3 @@ public KodamasReach copy() {
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;

}

}
80 changes: 12 additions & 68 deletions Mage.Sets/src/mage/cards/n/NavigationOrb.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
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;
Expand All @@ -23,11 +19,21 @@
*/
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);
Expand All @@ -42,65 +48,3 @@ public NavigationOrb copy() {
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;
}
}
Loading
Loading