forked from External/mage
[WOE] Implement Beseech the Mirror (#10842)
Co-authored-by: Evan Kranzler <theelk801@gmail.com>
This commit is contained in:
parent
b892562b95
commit
4cfc6ebc37
3 changed files with 117 additions and 1 deletions
111
Mage.Sets/src/mage/cards/b/BeseechTheMirror.java
Normal file
111
Mage.Sets/src/mage/cards/b/BeseechTheMirror.java
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
package mage.cards.b;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.BargainedCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.BargainAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public final class BeseechTheMirror extends CardImpl {
|
||||
|
||||
public BeseechTheMirror(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}{B}");
|
||||
|
||||
// Bargain
|
||||
this.addAbility(new BargainAbility());
|
||||
|
||||
// Search your library for a card, exile it face down, then shuffle. If this spell was bargained, you may cast the exiled card without paying its mana cost if that spell's mana value is 4 or less. Put the exiled card into your hand if it wasn't cast this way.
|
||||
this.getSpellAbility().addEffect(new BeseechTheMirrorEffect());
|
||||
}
|
||||
|
||||
private BeseechTheMirror(final BeseechTheMirror card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeseechTheMirror copy() {
|
||||
return new BeseechTheMirror(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BeseechTheMirrorEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter = new FilterCard();
|
||||
|
||||
static {
|
||||
filter.add(new ManaValuePredicate(ComparisonType.OR_LESS, 4));
|
||||
}
|
||||
|
||||
BeseechTheMirrorEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Search your library for a card, exile it face down, then shuffle. "
|
||||
+ "If this spell was bargained, you may cast the exiled card without paying "
|
||||
+ "its mana cost if that spell's mana value is 4 or less. Put the exiled card "
|
||||
+ "into your hand if it wasn't cast this way.";
|
||||
}
|
||||
|
||||
private BeseechTheMirrorEffect(final BeseechTheMirrorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BeseechTheMirrorEffect copy() {
|
||||
return new BeseechTheMirrorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Search your library for a card
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
// exile it face down
|
||||
card.setFaceDown(true, game);
|
||||
controller.moveCards(card, Zone.EXILED, source, game, false, true, false, null);
|
||||
card.setFaceDown(true, game);
|
||||
|
||||
// then shuffle
|
||||
controller.shuffleLibrary(source, game);
|
||||
|
||||
// If this spell was bargained,
|
||||
if (BargainedCondition.instance.apply(game, source)) {
|
||||
// you may cast the exiled card without paying its mana cost if that spell's mana value is 4 or less.
|
||||
CardUtil.castSpellWithAttributesForFree(controller, source, game, card, filter);
|
||||
}
|
||||
game.getState().processAction(game);
|
||||
|
||||
if (game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
|
||||
// Put the exiled card into your hand if it wasn't cast this way.
|
||||
controller.moveCards(card, Zone.HAND, source, game, false, true, false, null);
|
||||
card.setFaceDown(false, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ public final class WildsOfEldraine extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Ash, Party Crasher", 201, Rarity.UNCOMMON, mage.cards.a.AshPartyCrasher.class));
|
||||
cards.add(new SetCardInfo("Ashiok's Reaper", 79, Rarity.UNCOMMON, mage.cards.a.AshioksReaper.class));
|
||||
cards.add(new SetCardInfo("Beanstalk Wurm", 161, Rarity.COMMON, mage.cards.b.BeanstalkWurm.class));
|
||||
cards.add(new SetCardInfo("Beseech the Mirror", 82, Rarity.MYTHIC, mage.cards.b.BeseechTheMirror.class));
|
||||
cards.add(new SetCardInfo("Besotted Knight", 4, Rarity.COMMON, mage.cards.b.BesottedKnight.class));
|
||||
cards.add(new SetCardInfo("Bitter Chill", 44, Rarity.UNCOMMON, mage.cards.b.BitterChill.class));
|
||||
cards.add(new SetCardInfo("Break the Spell", 5, Rarity.COMMON, mage.cards.b.BreakTheSpell.class));
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,11 @@ public final class CardUtil {
|
|||
private static final FilterCard defaultFilter = new FilterCard("card to cast");
|
||||
|
||||
public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Card card) {
|
||||
return castSpellWithAttributesForFree(player, source, game, new CardsImpl(card), StaticFilters.FILTER_CARD);
|
||||
return castSpellWithAttributesForFree(player, source, game, card, StaticFilters.FILTER_CARD);
|
||||
}
|
||||
|
||||
public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Card card, FilterCard filter) {
|
||||
return castSpellWithAttributesForFree(player, source, game, new CardsImpl(card), filter);
|
||||
}
|
||||
|
||||
public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue