From bd93a4841b02386143fd54dd17f2b6b58f1a5148 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 8 Sep 2021 17:26:31 -0500 Subject: [PATCH] [MID] Implemented Curse of Silence --- .../src/mage/cards/c/CurseOfSilence.java | 144 ++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + 2 files changed, 145 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CurseOfSilence.java diff --git a/Mage.Sets/src/mage/cards/c/CurseOfSilence.java b/Mage.Sets/src/mage/cards/c/CurseOfSilence.java new file mode 100644 index 0000000000..080057596b --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CurseOfSilence.java @@ -0,0 +1,144 @@ +package mage.cards.c; + +import java.util.UUID; + +import mage.abilities.SpellAbility; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.AsEntersBattlefieldAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.common.ChooseACardNameEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.cards.Card; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPlayer; +import mage.abilities.Ability; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.util.CardUtil; + +/** + * + * @author weirddan455 + */ +public final class CurseOfSilence extends CardImpl { + + public CurseOfSilence(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + + this.subtype.add(SubType.AURA); + this.subtype.add(SubType.CURSE); + + // Enchant player + TargetPlayer auraTarget = new TargetPlayer(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // As Curse of Silence enters the battlefield, choose a card name. + this.addAbility(new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.ALL))); + + // Spells with the chosen name enchanted player casts cost {2} more to cast. + this.addAbility(new SimpleStaticAbility(new CurseOfSilenceCostEffect())); + + // Whenever enchanted player casts a spell with the chosen name, you may sacrifice Curse of Silence. If you do, draw a card. + this.addAbility(new CurseOfSilenceTriggeredAbility()); + } + + private CurseOfSilence(final CurseOfSilence card) { + super(card); + } + + @Override + public CurseOfSilence copy() { + return new CurseOfSilence(this); + } +} + +class CurseOfSilenceCostEffect extends CostModificationEffectImpl { + + public CurseOfSilenceCostEffect() { + super(Duration.WhileOnBattlefield, Outcome.Detriment, CostModificationType.INCREASE_COST); + staticText = "Spells with the chosen name enchanted player casts cost {2} more to cast"; + } + + private CurseOfSilenceCostEffect(final CurseOfSilenceCostEffect effect) { + super(effect); + } + + @Override + public CurseOfSilenceCostEffect copy() { + return new CurseOfSilenceCostEffect(this); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.increaseCost(abilityToModify, 2); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (abilityToModify instanceof SpellAbility) { + Permanent enchantment = source.getSourcePermanentIfItStillExists(game); + if (enchantment != null && abilityToModify.isControlledBy(enchantment.getAttachedTo())) { + Card card = game.getCard(abilityToModify.getSourceId()); + String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); + if (card != null && cardName != null && !cardName.isEmpty()) { + return CardUtil.haveSameNames(card, cardName, game); + } + } + } + return false; + } +} + +class CurseOfSilenceTriggeredAbility extends TriggeredAbilityImpl { + + public CurseOfSilenceTriggeredAbility() { + super(Zone.BATTLEFIELD, new DoIfCostPaid( + new DrawCardSourceControllerEffect(1), + new SacrificeSourceCost() + )); + } + + private CurseOfSilenceTriggeredAbility(final CurseOfSilenceTriggeredAbility ability) { + super(ability); + } + + @Override + public CurseOfSilenceTriggeredAbility copy() { + return new CurseOfSilenceTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent enchantment = getSourcePermanentIfItStillExists(game); + if (enchantment != null && event.getPlayerId().equals(enchantment.getAttachedTo())) { + Card card = game.getCard(event.getSourceId()); + String cardName = (String) game.getState().getValue(sourceId.toString() + ChooseACardNameEffect.INFO_KEY); + if (card != null && cardName != null && !cardName.isEmpty()) { + return CardUtil.haveSameNames(card, cardName, game); + } + } + return false; + } + + @Override + public String getTriggerPhrase() { + return "Whenever enchanted player casts a spell with the chosen name, "; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 0871dce77a..3313e744a6 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -49,6 +49,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Contortionist Troupe", 178, Rarity.UNCOMMON, mage.cards.c.ContortionistTroupe.class)); cards.add(new SetCardInfo("Croaking Counterpart", 215, Rarity.RARE, mage.cards.c.CroakingCounterpart.class)); cards.add(new SetCardInfo("Curse of Shaken Faith", 134, Rarity.RARE, mage.cards.c.CurseOfShakenFaith.class)); + cards.add(new SetCardInfo("Curse of Silence", 326, Rarity.RARE, mage.cards.c.CurseOfSilence.class)); cards.add(new SetCardInfo("Dawnhart Rejuvenator", 180, Rarity.COMMON, mage.cards.d.DawnhartRejuvenator.class)); cards.add(new SetCardInfo("Dawnhart Wardens", 308, Rarity.UNCOMMON, mage.cards.d.DawnhartWardens.class)); cards.add(new SetCardInfo("Defend the Celestus", 182, Rarity.UNCOMMON, mage.cards.d.DefendTheCelestus.class));