forked from External/mage
[CMM] Implement Desecrate Reality (#10684)
This commit is contained in:
parent
d205981516
commit
a8bba53adf
3 changed files with 155 additions and 6 deletions
134
Mage.Sets/src/mage/cards/d/DesecrateReality.java
Normal file
134
Mage.Sets/src/mage/cards/d/DesecrateReality.java
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.AdamantCondition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.common.FilterPermanentCard;
|
||||
import mage.filter.predicate.mageobject.ManaValueParityPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
import mage.target.targetpointer.EachTargetPointer;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public final class DesecrateReality extends CardImpl {
|
||||
|
||||
public DesecrateReality(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{7}");
|
||||
|
||||
|
||||
// For each opponent, exile up to one target permanent that player controls with an even mana value.
|
||||
this.getSpellAbility().addEffect(new ExileTargetEffect()
|
||||
.setTargetPointer(new EachTargetPointer())
|
||||
.setText("for each opponent, exile up to one target permanent that player controls with an even mana value."));
|
||||
this.getSpellAbility().setTargetAdjuster(DesecrateRealityAdjuster.instance);
|
||||
|
||||
// Adamant -- If at least three colorless mana was spent to cast this spell, return a permanent card with an odd mana value from your graveyard to the battlefield.
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
new DesecrateRealityEffect(),
|
||||
AdamantCondition.COLORLESS, "<br><i>Adamant</i> — "
|
||||
+ "If at least three colorless mana was spent to cast this spell, "
|
||||
+ "return a permanent card with an odd mana value from your graveyard to the battlefield."
|
||||
));
|
||||
}
|
||||
|
||||
private DesecrateReality(final DesecrateReality card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesecrateReality copy() {
|
||||
return new DesecrateReality(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum DesecrateRealityAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
private static final FilterControlledPermanent filterCount = new FilterControlledPermanent("");
|
||||
|
||||
static {
|
||||
filterCount.add(ManaValueParityPredicate.EVEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
ability.getTargets().clear();
|
||||
for (UUID opponentId : game.getOpponents(ability.getControllerId())) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
|
||||
if (opponent == null || game.getBattlefield().count(
|
||||
filterCount,
|
||||
opponentId, ability, game
|
||||
) < 1) {
|
||||
continue;
|
||||
}
|
||||
FilterPermanent filter = new FilterPermanent("permanent controlled by " + opponent.getName() + " with an even mana value.");
|
||||
filter.add(new ControllerIdPredicate(opponentId));
|
||||
filter.add(ManaValueParityPredicate.EVEN);
|
||||
TargetPermanent targetPermanent = new TargetPermanent(0, 1, filter);
|
||||
ability.addTarget(targetPermanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DesecrateRealityEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCard filter
|
||||
= new FilterPermanentCard("permanent card with an odd mana value in your graveyard");
|
||||
|
||||
static {
|
||||
filter.add(ManaValueParityPredicate.ODD);
|
||||
}
|
||||
|
||||
DesecrateRealityEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
private DesecrateRealityEffect(final DesecrateRealityEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DesecrateRealityEffect copy() {
|
||||
return new DesecrateRealityEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// return a permanent card with an odd mana value from your graveyard to the battlefield.
|
||||
Target target = new TargetCardInYourGraveyard(filter);
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(outcome, target, source, game)) {
|
||||
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
|
||||
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
|
||||
effect.apply(game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -162,6 +162,7 @@ public final class CommanderMasters extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Demonlord Belzenlok", 151, Rarity.RARE, mage.cards.d.DemonlordBelzenlok.class));
|
||||
cards.add(new SetCardInfo("Deploy the Gatewatch", 819, Rarity.MYTHIC, mage.cards.d.DeployTheGatewatch.class));
|
||||
cards.add(new SetCardInfo("Deranged Assistant", 87, Rarity.COMMON, mage.cards.d.DerangedAssistant.class));
|
||||
cards.add(new SetCardInfo("Desecrate Reality", 714, Rarity.RARE, mage.cards.d.DesecrateReality.class));
|
||||
cards.add(new SetCardInfo("Destiny Spinner", 890, Rarity.UNCOMMON, mage.cards.d.DestinySpinner.class));
|
||||
cards.add(new SetCardInfo("Diffusion Sliver", 845, Rarity.UNCOMMON, mage.cards.d.DiffusionSliver.class));
|
||||
cards.add(new SetCardInfo("Disrupt Decorum", 215, Rarity.RARE, mage.cards.d.DisruptDecorum.class));
|
||||
|
|
|
|||
|
|
@ -19,22 +19,33 @@ public enum AdamantCondition implements Condition {
|
|||
BLACK(ColoredManaSymbol.B),
|
||||
RED(ColoredManaSymbol.R),
|
||||
GREEN(ColoredManaSymbol.G),
|
||||
COLORLESS(null, true),
|
||||
ANY(null);
|
||||
|
||||
private final ColoredManaSymbol coloredManaSymbol;
|
||||
private final boolean colorless;
|
||||
|
||||
|
||||
private AdamantCondition(ColoredManaSymbol coloredManaSymbol) {
|
||||
this(coloredManaSymbol, false);
|
||||
}
|
||||
|
||||
private AdamantCondition(ColoredManaSymbol coloredManaSymbol, boolean colorless) {
|
||||
this.coloredManaSymbol = coloredManaSymbol;
|
||||
this.colorless = colorless;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source.getAbilityType() == AbilityType.SPELL) {
|
||||
if (colorless) {
|
||||
return source.getManaCostsToPay().getUsedManaToPay().getColorless() > 2;
|
||||
}
|
||||
if (coloredManaSymbol == null) {
|
||||
return Arrays
|
||||
.stream(ColoredManaSymbol.values())
|
||||
.map(source.getManaCostsToPay().getUsedManaToPay()::getColor)
|
||||
.anyMatch(i -> i > 2);
|
||||
.stream(ColoredManaSymbol.values())
|
||||
.map(source.getManaCostsToPay().getUsedManaToPay()::getColor)
|
||||
.anyMatch(i -> i > 2);
|
||||
}
|
||||
return source.getManaCostsToPay().getUsedManaToPay().getColor(coloredManaSymbol) > 2;
|
||||
}
|
||||
|
|
@ -46,11 +57,14 @@ public enum AdamantCondition implements Condition {
|
|||
if (payment == null) {
|
||||
return false;
|
||||
}
|
||||
if (colorless) {
|
||||
return payment.getColorless() > 2;
|
||||
}
|
||||
if (coloredManaSymbol == null) {
|
||||
return Arrays
|
||||
.stream(ColoredManaSymbol.values())
|
||||
.map(payment::getColor)
|
||||
.anyMatch(i -> i > 2);
|
||||
.stream(ColoredManaSymbol.values())
|
||||
.map(payment::getColor)
|
||||
.anyMatch(i -> i > 2);
|
||||
}
|
||||
return payment.getColor(coloredManaSymbol) > 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue