From 98b606074241cb320236979c1514ea2a1673f6bc Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 8 Aug 2019 21:38:59 -0400 Subject: [PATCH] Implemented Thought Sponge --- .../src/mage/cards/t/TectonicHellion.java | 2 +- Mage.Sets/src/mage/cards/t/ThoughtSponge.java | 88 +++++++++++++++++++ .../src/mage/sets/Commander2019Edition.java | 1 + 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/t/ThoughtSponge.java diff --git a/Mage.Sets/src/mage/cards/t/TectonicHellion.java b/Mage.Sets/src/mage/cards/t/TectonicHellion.java index 0e08cc59daf..0bb8208f515 100644 --- a/Mage.Sets/src/mage/cards/t/TectonicHellion.java +++ b/Mage.Sets/src/mage/cards/t/TectonicHellion.java @@ -77,7 +77,7 @@ class TectonicHellionEffect extends OneShotEffect { int max = landMap .values() .stream() - .max(Math::max) + .max(Integer::compare) .get(); Effect effect = new SacrificeEffect(StaticFilters.FILTER_LANDS, 2, ""); game.getState() diff --git a/Mage.Sets/src/mage/cards/t/ThoughtSponge.java b/Mage.Sets/src/mage/cards/t/ThoughtSponge.java new file mode 100644 index 00000000000..6721f81d766 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/ThoughtSponge.java @@ -0,0 +1,88 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DiesTriggeredAbility; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.FlashAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.game.Game; +import mage.watchers.common.CardsDrawnThisTurnWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ThoughtSponge extends CardImpl { + + private static final DynamicValue xValue = new SourcePermanentPowerCount(); + + public ThoughtSponge(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}"); + + this.subtype.add(SubType.SPONGE); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // Thought Sponge enters the battlefield with a number of +1/+1 counters on it equal to the greatest number of cards an opponent has drawn this turn. + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect( + CounterType.P1P1.createInstance(), ThoughtSpongeValue.instance, false + ), "with a number of +1/+1 counters on it equal to " + + "the greatest number of cards an opponent has drawn this turn" + ), new CardsDrawnThisTurnWatcher()); + + // When Thought Sponge dies, draw cards equal to its power. + this.addAbility(new DiesTriggeredAbility( + new DrawCardSourceControllerEffect(xValue).setText("draw cards equal to its power") + )); + } + + private ThoughtSponge(final ThoughtSponge card) { + super(card); + } + + @Override + public ThoughtSponge copy() { + return new ThoughtSponge(this); + } +} + +enum ThoughtSpongeValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + CardsDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsDrawnThisTurnWatcher.class); + if (watcher == null) { + return 0; + } + return game.getOpponents(sourceAbility.getControllerId()) + .stream() + .map(watcher::getCardsDrawnThisTurn) + .max(Integer::compare) + .get(); + } + + @Override + public DynamicValue copy() { + return instance; + } + + @Override + public String getMessage() { + return ""; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Commander2019Edition.java b/Mage.Sets/src/mage/sets/Commander2019Edition.java index 7a1f8e122d8..d778aab58a7 100644 --- a/Mage.Sets/src/mage/sets/Commander2019Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2019Edition.java @@ -197,6 +197,7 @@ public final class Commander2019Edition extends ExpansionSet { cards.add(new SetCardInfo("Thespian's Stage", 282, Rarity.RARE, mage.cards.t.ThespiansStage.class)); cards.add(new SetCardInfo("Think Twice", 99, Rarity.COMMON, mage.cards.t.ThinkTwice.class)); cards.add(new SetCardInfo("Thornwood Falls", 283, Rarity.COMMON, mage.cards.t.ThornwoodFalls.class)); + cards.add(new SetCardInfo("Thought Sponge", 12, Rarity.RARE, mage.cards.t.ThoughtSponge.class)); cards.add(new SetCardInfo("Thousand Winds", 100, Rarity.RARE, mage.cards.t.ThousandWinds.class)); cards.add(new SetCardInfo("Thragtusk", 185, Rarity.RARE, mage.cards.t.Thragtusk.class)); cards.add(new SetCardInfo("Thran Dynamo", 225, Rarity.UNCOMMON, mage.cards.t.ThranDynamo.class));