diff --git a/Mage.Sets/src/mage/cards/s/ScarletSpiderBenReilly.java b/Mage.Sets/src/mage/cards/s/ScarletSpiderBenReilly.java new file mode 100644 index 00000000000..dbe63994f49 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/ScarletSpiderBenReilly.java @@ -0,0 +1,100 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.condition.common.WebSlingingCondition; +import mage.abilities.costs.common.ReturnToHandChosenControlledPermanentCost; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.keyword.TrampleAbility; +import mage.abilities.keyword.WebSlingingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.stack.Spell; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * + * @author Jmlundeen + */ +public final class ScarletSpiderBenReilly extends CardImpl { + + public ScarletSpiderBenReilly(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{G}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.SPIDER); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.HERO); + this.power = new MageInt(4); + this.toughness = new MageInt(3); + + // Web-slinging {R}{G} + this.addAbility(new WebSlingingAbility(this, "{R}{G}")); + + // Trample + this.addAbility(TrampleAbility.getInstance()); + + // Sensational Save -- If Scarlet Spider was cast using web-slinging, he enters with X +1/+1 counters on him, where X is the mana value of the returned creature. + String ruleText = CardUtil.italicizeWithEmDash("Sensational Save") + "If {this} was cast using web-slinging, " + + "he enters with X +1/+1 counters on him, where X is the mana value of the returned creature."; + this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(), + ScarletSpiderBenReillyValue.instance, false), + WebSlingingCondition.THIS, ruleText, "")); + } + + private ScarletSpiderBenReilly(final ScarletSpiderBenReilly card) { + super(card); + } + + @Override + public ScarletSpiderBenReilly copy() { + return new ScarletSpiderBenReilly(this); + } +} +enum ScarletSpiderBenReillyValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + + Spell spell = game.getSpellOrLKIStack(sourceAbility.getSourceId()); + if (spell == null || spell.getSpellAbility() == null) { + return 0; + } + + ReturnToHandChosenControlledPermanentCost returnCost = (ReturnToHandChosenControlledPermanentCost) spell.getSpellAbility().getCosts().stream() + .filter(cost -> cost instanceof ReturnToHandChosenControlledPermanentCost) + .findFirst() + .orElse(null); + if (returnCost == null || returnCost.getPermanents().isEmpty()) { + return 0; + } + + return returnCost.getPermanents().get(0).getManaValue(); + } + + @Override + public ScarletSpiderBenReillyValue copy() { + return this; + } + + @Override + public String toString() { + return "X"; + } + + @Override + public String getMessage() { + return ""; + } +} diff --git a/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java b/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java index 5b8333368ed..c0d9be25cb1 100644 --- a/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java +++ b/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java @@ -168,6 +168,8 @@ public final class MarvelsSpiderMan extends ExpansionSet { cards.add(new SetCardInfo("Sandman's Quicksand", 63, Rarity.UNCOMMON, mage.cards.s.SandmansQuicksand.class)); cards.add(new SetCardInfo("Sandman, Shifting Scoundrel", 112, Rarity.RARE, mage.cards.s.SandmanShiftingScoundrel.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Sandman, Shifting Scoundrel", 266, Rarity.RARE, mage.cards.s.SandmanShiftingScoundrel.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Scarlet Spider, Ben Reilly", 142, Rarity.RARE, mage.cards.s.ScarletSpiderBenReilly.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Scarlet Spider, Ben Reilly", 214, Rarity.RARE, mage.cards.s.ScarletSpiderBenReilly.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Scarlet Spider, Kaine", 143, Rarity.UNCOMMON, mage.cards.s.ScarletSpiderKaine.class)); cards.add(new SetCardInfo("School Daze", 42, Rarity.UNCOMMON, mage.cards.s.SchoolDaze.class)); cards.add(new SetCardInfo("Scorpion's Sting", 65, Rarity.COMMON, mage.cards.s.ScorpionsSting.class)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/ScarletSpiderBenReillyTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/ScarletSpiderBenReillyTest.java new file mode 100644 index 00000000000..c2e7afe3c97 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/ScarletSpiderBenReillyTest.java @@ -0,0 +1,65 @@ +package org.mage.test.cards.single.spm; + +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.TapAllEffect; +import mage.constants.PhaseStep; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author Jmlundeen + */ +public class ScarletSpiderBenReillyTest extends CardTestPlayerBase { + + /* + Scarlet Spider, Ben Reilly + {1}{R}{G} + Legendary Creature - Spider Human Hero + Web-slinging {R}{G} + Trample + Sensational Save -- If Scarlet Spider was cast using web-slinging, he enters with X +1/+1 counters on him, where X is the mana value of the returned creature. + 4/3 + */ + private static final String scarletSpiderBenReilly = "Scarlet Spider, Ben Reilly"; + + /* + Bear Cub + {1}{G} + Creature - Bear + + 2/2 + */ + private static final String bearCub = "Bear Cub"; + + @Test + public void testScarletSpiderBenReilly() { + setStrictChooseMode(true); + + addCustomCardWithAbility("tap all creatures", playerA, new SimpleActivatedAbility( + new TapAllEffect(new FilterCreaturePermanent(SubType.BEAR, "bears")), + new ManaCostsImpl<>("") + )); + + addCard(Zone.HAND, playerA, scarletSpiderBenReilly); + addCard(Zone.BATTLEFIELD, playerA, bearCub, 1); + addCard(Zone.BATTLEFIELD, playerA, "Taiga", 3); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "tap all"); // tap bears, addCard command isn't working to set tapped + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, scarletSpiderBenReilly + " with Web-slinging"); + setChoice(playerA, bearCub); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertCounterCount(playerA, scarletSpiderBenReilly, CounterType.P1P1, 2); + assertHandCount(playerA, bearCub, 1); + } +} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/condition/common/WebSlingingCondition.java b/Mage/src/main/java/mage/abilities/condition/common/WebSlingingCondition.java index 40ff1847254..e47a5184363 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/WebSlingingCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/WebSlingingCondition.java @@ -10,7 +10,8 @@ import mage.util.CardUtil; * @author TheElk801 */ public enum WebSlingingCondition implements Condition { - THEY("they were"); + THEY("they were"), + THIS("{this}"); private final String message; WebSlingingCondition(String message) {