diff --git a/Mage.Sets/src/mage/cards/e/ExcavationTechnique.java b/Mage.Sets/src/mage/cards/e/ExcavationTechnique.java new file mode 100644 index 00000000000..151d00b289d --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ExcavationTechnique.java @@ -0,0 +1,69 @@ +package mage.cards.e; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.DemonstrateAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.TreasureToken; +import mage.target.common.TargetNonlandPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ExcavationTechnique extends CardImpl { + + public ExcavationTechnique(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{W}"); + + // Demonstrate + this.addAbility(new DemonstrateAbility()); + + // Destroy target nonland permanent. Its controller creates two Treasure tokens. + this.getSpellAbility().addEffect(new ExcavationTechniqueEffect()); + this.getSpellAbility().addTarget(new TargetNonlandPermanent()); + } + + private ExcavationTechnique(final ExcavationTechnique card) { + super(card); + } + + @Override + public ExcavationTechnique copy() { + return new ExcavationTechnique(this); + } +} + +class ExcavationTechniqueEffect extends OneShotEffect { + + ExcavationTechniqueEffect() { + super(Outcome.Benefit); + staticText = "destroy target nonland permanent. Its controller creates two Treasure tokens"; + } + + private ExcavationTechniqueEffect(final ExcavationTechniqueEffect effect) { + super(effect); + } + + @Override + public ExcavationTechniqueEffect copy() { + return new ExcavationTechniqueEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + permanent.destroy(source, game, false); + new TreasureToken().putOntoBattlefield(2, game, source, permanent.getControllerId()); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2021Edition.java b/Mage.Sets/src/mage/sets/Commander2021Edition.java index 3ef3ef0c1c8..35578adbc2f 100644 --- a/Mage.Sets/src/mage/sets/Commander2021Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2021Edition.java @@ -19,5 +19,7 @@ public final class Commander2021Edition extends ExpansionSet { super("Commander 2021 Edition", "C21", ExpansionSet.buildDate(2021, 4, 23), SetType.SUPPLEMENTAL); this.blockName = "Command Zone"; this.hasBasicLands = false; + + cards.add(new SetCardInfo("Excavation Technique", 16, Rarity.RARE, mage.cards.e.ExcavationTechnique.class)); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java index b9b552d762c..9ab05d3d49f 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CastSourceTriggeredAbility.java @@ -9,7 +9,6 @@ import mage.game.events.GameEvent; import mage.game.stack.Spell; /** - * * @author Plopman */ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl { @@ -48,19 +47,19 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.getSourceId())) { - MageObject spellObject = game.getObject(sourceId); - if ((spellObject instanceof Spell)) { - Spell spell = (Spell) spellObject; - if (spell.getSpellAbility() != null) { - for (Effect effect : getEffects()) { - effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility()); - } - } - } + if (!event.getSourceId().equals(this.getSourceId())) { + return false; + } + MageObject spellObject = game.getObject(sourceId); + if ((!(spellObject instanceof Spell))) { return true; } - return false; + Spell spell = (Spell) spellObject; + if (spell.getSpellAbility() != null) { + getEffects().setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility()); + } + getEffects().setValue("spellCast", spell); + return true; } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java b/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java new file mode 100644 index 00000000000..36dc9487810 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/keyword/DemonstrateAbility.java @@ -0,0 +1,70 @@ +package mage.abilities.keyword; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CastSourceTriggeredAbility; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.players.Player; +import mage.target.common.TargetOpponent; + +/** + * @author TheElk801 + */ +public class DemonstrateAbility extends CastSourceTriggeredAbility { + + public DemonstrateAbility() { + super(new DemonstrateEffect(), true); + } + + private DemonstrateAbility(final DemonstrateAbility ability) { + super(ability); + } + + @Override + public DemonstrateAbility copy() { + return new DemonstrateAbility(this); + } + + @Override + public String getRule() { + return "Demonstrate (When you cast this spell, you may copy it. If you do, " + + "choose an opponent to also copy it. Players may choose new targets for their copies.)"; + } +} + +class DemonstrateEffect extends OneShotEffect { + + DemonstrateEffect() { + super(Outcome.Benefit); + } + + private DemonstrateEffect(final DemonstrateEffect effect) { + super(effect); + } + + @Override + public DemonstrateEffect copy() { + return new DemonstrateEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Spell spell = (Spell) getValue("spellCast"); + if (spell == null) { + return false; + } + spell.createCopyOnStack(game, source, source.getControllerId(), true); + TargetOpponent target = new TargetOpponent(true); + controller.choose(outcome, target, source.getSourceId(), game); + if (game.getPlayer(target.getFirstTarget()) != null) { + spell.createCopyOnStack(game, source, target.getFirstTarget(), true); + } + return true; + } +} diff --git a/Utils/keywords.txt b/Utils/keywords.txt index f3724aab563..74d6b1364bd 100644 --- a/Utils/keywords.txt +++ b/Utils/keywords.txt @@ -17,6 +17,7 @@ Cumulative upkeep|cost| Cycling|cost| Dash|card, manaString| Deathtouch|instance| +Demonstrate|new| Delve|new| Dethrone|new| Devoid|color|