diff --git a/Mage.Sets/src/mage/cards/d/DelightfulDiscovery.java b/Mage.Sets/src/mage/cards/d/DelightfulDiscovery.java new file mode 100644 index 00000000000..b88a9ea5cb5 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DelightfulDiscovery.java @@ -0,0 +1,83 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.cost.SpellCostReductionForEachSourceEffect; +import mage.abilities.effects.keyword.ScryEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.watchers.common.SpellsCastWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DelightfulDiscovery extends CardImpl { + + public DelightfulDiscovery(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{U}"); + + // This spell costs {1} less to cast for each spell your opponents have cast this turn. + this.addAbility(new SimpleStaticAbility( + Zone.ALL, + new SpellCostReductionForEachSourceEffect( + 1, DelightfulDiscoveryValue.instance + ).setCanWorksOnStackOnly(true) + ).setRuleAtTheTop(true).addHint(DelightfulDiscoveryValue.getHint()), new SpellsCastWatcher()); + + // Scry 2, then draw two cards. + this.getSpellAbility().addEffect(new ScryEffect(2, false)); + this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(2).concatBy(", then")); + } + + private DelightfulDiscovery(final DelightfulDiscovery card) { + super(card); + } + + @Override + public DelightfulDiscovery copy() { + return new DelightfulDiscovery(this); + } +} + +enum DelightfulDiscoveryValue implements DynamicValue { + instance; + private static final Hint hint = new ValueHint("Spells your opponents cast this turn", instance); + + static Hint getHint() { + return hint; + } + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return game + .getOpponents(sourceAbility.getControllerId()) + .stream() + .mapToInt(game.getState().getWatcher(SpellsCastWatcher.class)::getCount) + .sum(); + } + + @Override + public DelightfulDiscoveryValue copy() { + return this; + } + + @Override + public String getMessage() { + return "1"; + } + + @Override + public String toString() { + return "spell your opponents have cast this turn"; + } +} diff --git a/Mage.Sets/src/mage/sets/FoundationsJumpstart.java b/Mage.Sets/src/mage/sets/FoundationsJumpstart.java index 86c89dc26c6..b5c3efb8d5d 100644 --- a/Mage.Sets/src/mage/sets/FoundationsJumpstart.java +++ b/Mage.Sets/src/mage/sets/FoundationsJumpstart.java @@ -186,6 +186,7 @@ public final class FoundationsJumpstart extends ExpansionSet { cards.add(new SetCardInfo("Defend the Celestus", 649, Rarity.UNCOMMON, mage.cards.d.DefendTheCelestus.class)); cards.add(new SetCardInfo("Defenestrate", 420, Rarity.COMMON, mage.cards.d.Defenestrate.class)); cards.add(new SetCardInfo("Defiant Strike", 187, Rarity.COMMON, mage.cards.d.DefiantStrike.class)); + cards.add(new SetCardInfo("Delightful Discovery", 6, Rarity.UNCOMMON, mage.cards.d.DelightfulDiscovery.class)); cards.add(new SetCardInfo("Desert of the Fervent", 764, Rarity.COMMON, mage.cards.d.DesertOfTheFervent.class)); cards.add(new SetCardInfo("Desperate Lunge", 188, Rarity.COMMON, mage.cards.d.DesperateLunge.class)); cards.add(new SetCardInfo("Destroy Evil", 189, Rarity.COMMON, mage.cards.d.DestroyEvil.class)); diff --git a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java index fd07dc2b62d..d97285e86dc 100644 --- a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java @@ -94,7 +94,7 @@ public class SpellsCastWatcher extends Watcher { } public int getCount(UUID playerId) { - return spellsCast.getOrDefault(playerId, new ArrayList<>()).size(); + return spellsCast.getOrDefault(playerId, Collections.emptyList()).size(); } }