From ed9d51526eccf2e863c965dcf3ee954087e89b24 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Fri, 29 Jun 2018 23:46:35 -0400 Subject: [PATCH] Implement Conjurer's Ban --- Mage.Sets/src/mage/cards/c/ConjurersBan.java | 85 ++++++++++++++++++++ Mage.Sets/src/mage/sets/Guildpact.java | 1 + 2 files changed, 86 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ConjurersBan.java diff --git a/Mage.Sets/src/mage/cards/c/ConjurersBan.java b/Mage.Sets/src/mage/cards/c/ConjurersBan.java new file mode 100644 index 00000000000..f7624da9e81 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ConjurersBan.java @@ -0,0 +1,85 @@ +package mage.cards.c; + +import java.util.UUID; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.abilities.effects.common.ChooseACardNameEffect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author noahg + */ +public final class ConjurersBan extends CardImpl { + + public ConjurersBan(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}{B}"); + + + // Choose a card name. Until your next turn, spells with the chosen name can’t be cast and lands with the chosen name can’t be played. + this.getSpellAbility().addEffect(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL)); + this.getSpellAbility().addEffect(new ConjurersBanEffect()); + + // Draw a card. + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); + } + + public ConjurersBan(final ConjurersBan card) { + super(card); + } + + @Override + public ConjurersBan copy() { + return new ConjurersBan(this); + } +} + +class ConjurersBanEffect extends ContinuousRuleModifyingEffectImpl { + + public ConjurersBanEffect() { + super(Duration.UntilYourNextTurn, Outcome.Detriment, true, false); + this.staticText = "spells with the chosen name can't be cast and lands with the chosen name can't be played"; + } + + public ConjurersBanEffect(final ConjurersBanEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ConjurersBanEffect copy() { + return new ConjurersBanEffect(this); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == GameEvent.EventType.CAST_SPELL || event.getType() == GameEvent.EventType.PLAY_LAND) { + MageObject object = game.getObject(event.getSourceId()); + return object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY)); + } + return false; + } + + @Override + public String getInfoMessage(Ability source, GameEvent event, Game game) { + String namedCard = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); + String playerName = game.getPlayer(source.getControllerId()).getName(); + if (namedCard == null || playerName == null || source.getSourceObject(game) == null){ + return super.getInfoMessage(source, event, game); + } + return "Until "+playerName+"'s next turn, spells named "+namedCard+" can't be cast and lands named "+namedCard+" can't be played ("+source.getSourceObject(game).getIdName()+")."; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Guildpact.java b/Mage.Sets/src/mage/sets/Guildpact.java index 5eadbe6723e..16e31256091 100644 --- a/Mage.Sets/src/mage/sets/Guildpact.java +++ b/Mage.Sets/src/mage/sets/Guildpact.java @@ -44,6 +44,7 @@ public final class Guildpact extends ExpansionSet { cards.add(new SetCardInfo("Castigate", 106, Rarity.COMMON, mage.cards.c.Castigate.class)); cards.add(new SetCardInfo("Caustic Rain", 44, Rarity.UNCOMMON, mage.cards.c.CausticRain.class)); cards.add(new SetCardInfo("Cerebral Vortex", 107, Rarity.RARE, mage.cards.c.CerebralVortex.class)); + cards.add(new SetCardInfo("Conjurer's Ban", 108, Rarity.UNCOMMON, mage.cards.c.ConjurersBan.class)); cards.add(new SetCardInfo("Crash Landing", 82, Rarity.UNCOMMON, mage.cards.c.CrashLanding.class)); cards.add(new SetCardInfo("Cremate", 45, Rarity.COMMON, mage.cards.c.Cremate.class)); cards.add(new SetCardInfo("Cry of Contrition", 46, Rarity.COMMON, mage.cards.c.CryOfContrition.class));