From 8b9c77e129187652103464a8ec7da3ca670fe191 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 8 Sep 2021 19:10:21 -0500 Subject: [PATCH] [MID] Implemented Curse of Surveillance --- .../src/mage/cards/c/CurseOfSurveillance.java | 108 ++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + ...nningOfUpkeepAttachedTriggeredAbility.java | 13 ++- 3 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java diff --git a/Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java b/Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java new file mode 100644 index 0000000000..f95f7fa7ce --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CurseOfSurveillance.java @@ -0,0 +1,108 @@ +package mage.cards.c; + +import java.util.UUID; + +import mage.abilities.common.BeginningOfUpkeepAttachedTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardTargetEffect; +import mage.constants.SubType; +import mage.abilities.Ability; +import mage.abilities.effects.common.AttachEffect; +import mage.constants.Outcome; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.filter.FilterPlayer; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.other.PlayerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPlayer; +import mage.target.targetadjustment.TargetAdjuster; + +/** + * + * @author weirddan455 + */ +public final class CurseOfSurveillance extends CardImpl { + + public CurseOfSurveillance(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}"); + + 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); + + // At the beginning of enchanted player's upkeep, any number of target players other than that player each draw cards equal to the number of Curses attached to that player. + ability = new BeginningOfUpkeepAttachedTriggeredAbility( + new DrawCardTargetEffect(CurseOfSurveillanceValue.instance).setText( + "any number of target players other than that player each draw cards equal to the number of Curses attached to that player" + ), + false, false + ); + ability.setTargetAdjuster(CurseOfSurveillanceTargetAdjuster.instance); + ability.addTarget(new TargetPlayer(0, Integer.MAX_VALUE, false)); + this.addAbility(ability); + } + + private CurseOfSurveillance(final CurseOfSurveillance card) { + super(card); + } + + @Override + public CurseOfSurveillance copy() { + return new CurseOfSurveillance(this); + } +} + +enum CurseOfSurveillanceValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + UUID enchantedPlayerId = (UUID) effect.getValue("enchantedPlayer"); + int curses = 0; + if (enchantedPlayerId != null) { + for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) { + if (permanent != null && permanent.hasSubtype(SubType.CURSE, game) && permanent.isAttachedTo(enchantedPlayerId)) { + curses++; + } + } + } + return curses; + } + + @Override + public CurseOfSurveillanceValue copy() { + return instance; + } + + @Override + public String getMessage() { + return "number of Curses attached to that player"; + } +} + +enum CurseOfSurveillanceTargetAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(ability.getSourceId()); + if (enchantment != null) { + FilterPlayer filter = new FilterPlayer(); + filter.add(Predicates.not(new PlayerIdPredicate(enchantment.getAttachedTo()))); + TargetPlayer target = new TargetPlayer(0, Integer.MAX_VALUE, false, filter); + ability.getTargets().clear(); + ability.addTarget(target); + } + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 3313e744a6..f8a591056e 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -50,6 +50,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { 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("Curse of Surveillance", 46, Rarity.RARE, mage.cards.c.CurseOfSurveillance.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)); diff --git a/Mage/src/main/java/mage/abilities/common/BeginningOfUpkeepAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BeginningOfUpkeepAttachedTriggeredAbility.java index 29c53f06aa..ed24f7e994 100644 --- a/Mage/src/main/java/mage/abilities/common/BeginningOfUpkeepAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BeginningOfUpkeepAttachedTriggeredAbility.java @@ -13,16 +13,24 @@ import mage.target.targetpointer.FixedTarget; */ public class BeginningOfUpkeepAttachedTriggeredAbility extends TriggeredAbilityImpl { + private final boolean setTargetPointer; + public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect) { this(effect, false); } public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional) { + this(effect, optional, true); + } + + public BeginningOfUpkeepAttachedTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { super(Zone.BATTLEFIELD, effect, optional); + this.setTargetPointer = setTargetPointer; } private BeginningOfUpkeepAttachedTriggeredAbility(final BeginningOfUpkeepAttachedTriggeredAbility ability) { super(ability); + this.setTargetPointer = ability.setTargetPointer; } @Override @@ -41,7 +49,10 @@ public class BeginningOfUpkeepAttachedTriggeredAbility extends TriggeredAbilityI if (enchantment == null || !game.isActivePlayer(enchantment.getAttachedTo())) { return false; } - this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo())); + if (setTargetPointer) { + this.getEffects().setTargetPointer(new FixedTarget(enchantment.getAttachedTo())); + } + this.getEffects().setValue("enchantedPlayer", enchantment.getAttachedTo()); return true; }