[STX] Implemented Devastating Mastery

This commit is contained in:
Evan Kranzler 2021-04-09 17:31:13 -04:00
parent 10cd439955
commit ed3f6a7c83
3 changed files with 101 additions and 4 deletions

View file

@ -48,7 +48,7 @@ public final class BalefulMastery extends CardImpl {
class BalefulMasteryAlternativeCostEffect extends OneShotEffect {
UUID alternativeCostOriginalID;
private final UUID alternativeCostOriginalID;
BalefulMasteryAlternativeCostEffect(UUID alternativeCostOriginalID) {
super(Outcome.Detriment);
@ -56,7 +56,7 @@ class BalefulMasteryAlternativeCostEffect extends OneShotEffect {
this.alternativeCostOriginalID = alternativeCostOriginalID;
}
BalefulMasteryAlternativeCostEffect(BalefulMasteryAlternativeCostEffect effect) {
private BalefulMasteryAlternativeCostEffect(BalefulMasteryAlternativeCostEffect effect) {
super(effect);
this.alternativeCostOriginalID = effect.alternativeCostOriginalID;
}
@ -68,8 +68,9 @@ class BalefulMasteryAlternativeCostEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean wasActivated = AlternativeCostSourceAbility.getActivatedStatus(game, source, this.alternativeCostOriginalID, false);
if (!wasActivated) {
if (!AlternativeCostSourceAbility.getActivatedStatus(
game, source, this.alternativeCostOriginalID, false
)) {
return false;
}

View file

@ -0,0 +1,95 @@
package mage.cards.d;
import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class DevastatingMastery extends CardImpl {
public DevastatingMastery(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}{W}{W}{W}");
// You may pay {2}{W}{W} rather than pay this spell's mana cost.
Ability costAbility = new AlternativeCostSourceAbility(new ManaCostsImpl<>("{2}{W}{W}"));
this.addAbility(costAbility);
// If the {2}{W}{W} cost was paid, an opponent chooses up to two nonland permanents they control and returns them to their owner's hand.
this.getSpellAbility().addEffect(new DevastatingMasteryAlternativeCostEffect(costAbility.getOriginalId()));
// Destroy all nonland permanents.
this.getSpellAbility().addEffect(new DestroyAllEffect(StaticFilters.FILTER_PERMANENTS_NON_LAND));
}
private DevastatingMastery(final DevastatingMastery card) {
super(card);
}
@Override
public DevastatingMastery copy() {
return new DevastatingMastery(this);
}
}
class DevastatingMasteryAlternativeCostEffect extends OneShotEffect {
private final UUID alternativeCostOriginalID;
DevastatingMasteryAlternativeCostEffect(UUID alternativeCostOriginalID) {
super(Outcome.Detriment);
staticText = "if the {2}{W}{W} cost was paid, an opponent chooses up to two nonland permanents " +
"they control and returns them to their owner's hand.<br>";
this.alternativeCostOriginalID = alternativeCostOriginalID;
}
private DevastatingMasteryAlternativeCostEffect(DevastatingMasteryAlternativeCostEffect effect) {
super(effect);
this.alternativeCostOriginalID = effect.alternativeCostOriginalID;
}
@Override
public DevastatingMasteryAlternativeCostEffect copy() {
return new DevastatingMasteryAlternativeCostEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
if (!AlternativeCostSourceAbility.getActivatedStatus(
game, source, this.alternativeCostOriginalID, false
)) {
return false;
}
Player player = game.getPlayer(source.getControllerId());
TargetOpponent targetOpponent = new TargetOpponent(true);
if (!player.chooseTarget(Outcome.DrawCard, targetOpponent, source, game)) {
return false;
}
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent == null) {
return false;
}
TargetPermanent target = new TargetPermanent(
0, 2, StaticFilters.FILTER_PERMANENTS_NON_LAND, true
);
opponent.choose(Outcome.ReturnToHand, target, source.getSourceId(), game);
return opponent.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game);
}
}

View file

@ -84,6 +84,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
cards.add(new SetCardInfo("Decisive Denial", 177, Rarity.UNCOMMON, mage.cards.d.DecisiveDenial.class));
cards.add(new SetCardInfo("Defend the Campus", 12, Rarity.COMMON, mage.cards.d.DefendTheCampus.class));
cards.add(new SetCardInfo("Detention Vortex", 13, Rarity.UNCOMMON, mage.cards.d.DetentionVortex.class));
cards.add(new SetCardInfo("Devastating Mastery", 14, Rarity.RARE, mage.cards.d.DevastatingMastery.class));
cards.add(new SetCardInfo("Dina, Soul Steeper", 178, Rarity.UNCOMMON, mage.cards.d.DinaSoulSteeper.class));
cards.add(new SetCardInfo("Divide by Zero", 41, Rarity.UNCOMMON, mage.cards.d.DivideByZero.class));
cards.add(new SetCardInfo("Double Major", 179, Rarity.RARE, mage.cards.d.DoubleMajor.class));