diff --git a/Mage.Sets/src/mage/cards/c/CheeringCrowd.java b/Mage.Sets/src/mage/cards/c/CheeringCrowd.java new file mode 100644 index 00000000000..9ecc86cc0ca --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CheeringCrowd.java @@ -0,0 +1,100 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.Mana; +import mage.abilities.Ability; +import mage.abilities.costs.common.PutCountersSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.triggers.BeginningOfFirstMainTriggeredAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +import java.util.UUID; + +/** + * + * @author Jmlundeen + */ +public final class CheeringCrowd extends CardImpl { + + public CheeringCrowd(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R/G}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.CITIZEN); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // At the beginning of each player's first main phase, that player may put a +1/+1 counter on this creature. If they do, they add {C} for each counter on it. + this.addAbility(new BeginningOfFirstMainTriggeredAbility(TargetController.EACH_PLAYER, new CheeringCrowdDoIfPaidEffect(), false)); + } + + private CheeringCrowd(final CheeringCrowd card) { + super(card); + } + + @Override + public CheeringCrowd copy() { + return new CheeringCrowd(this); + } +} +class CheeringCrowdDoIfPaidEffect extends DoIfCostPaid { + + public CheeringCrowdDoIfPaidEffect() { + super(new CheeringCrowdEffect(), new PutCountersSourceCost(CounterType.P1P1.createInstance()), + "Put a +1/+1 counter on Cheering Crowd and add {C} for each counter on it?", true); + staticText = "that player may put a +1/+1 counter on this creature. If they do, they add {C} for each counter on it"; + } + + private CheeringCrowdDoIfPaidEffect(final CheeringCrowdDoIfPaidEffect effect) { + super(effect); + } + + @Override + public CheeringCrowdDoIfPaidEffect copy() { + return new CheeringCrowdDoIfPaidEffect(this); + } + + @Override + protected Player getPayingPlayer(Game game, Ability source) { + return game.getPlayer(getTargetPointer().getFirst(game, source)); + } +} + +class CheeringCrowdEffect extends OneShotEffect { + + public CheeringCrowdEffect() { + super(Outcome.PutManaInPool); + staticText = "they add {C} for each counter on it"; + } + + protected CheeringCrowdEffect(final CheeringCrowdEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + Permanent permanent = source.getSourcePermanentOrLKI(game); + if (player == null || permanent == null) { + return false; + } + int counterCounter = permanent.getCounters(game).getCount(CounterType.P1P1); + player.getManaPool().addMana(Mana.ColorlessMana(counterCounter), game, source); + return true; + } + + @Override + public CheeringCrowdEffect copy() { + return new CheeringCrowdEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java b/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java index 5450313e72a..1a75370d5f0 100644 --- a/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java +++ b/Mage.Sets/src/mage/sets/MarvelsSpiderMan.java @@ -41,6 +41,7 @@ public final class MarvelsSpiderMan extends ExpansionSet { cards.add(new SetCardInfo("Carnage, Crimson Chaos", 125, Rarity.RARE, mage.cards.c.CarnageCrimsonChaos.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Carnage, Crimson Chaos", 227, Rarity.RARE, mage.cards.c.CarnageCrimsonChaos.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Chameleon, Master of Disguise", 27, Rarity.UNCOMMON, mage.cards.c.ChameleonMasterOfDisguise.class)); + cards.add(new SetCardInfo("Cheering Crowd", 126, Rarity.RARE, mage.cards.c.CheeringCrowd.class)); cards.add(new SetCardInfo("City Pigeon", 4, Rarity.COMMON, mage.cards.c.CityPigeon.class)); cards.add(new SetCardInfo("Common Crook", 53, Rarity.COMMON, mage.cards.c.CommonCrook.class)); cards.add(new SetCardInfo("Cosmic Spider-Man", 127, Rarity.MYTHIC, mage.cards.c.CosmicSpiderMan.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/CheeringCrowdTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/CheeringCrowdTest.java new file mode 100644 index 00000000000..b8a551de14d --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/spm/CheeringCrowdTest.java @@ -0,0 +1,49 @@ +package org.mage.test.cards.single.spm; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestCommander4Players; + +/** + * + * @author Jmlundeen + */ +public class CheeringCrowdTest extends CardTestCommander4Players { + + /* + Cheering Crowd + {1}{R/G} + Creature - Human Citizen + At the beginning of each player's first main phase, that player may put a +1/+1 counter on this creature. If they do, they add {C} for each counter on it. + 2/2 + */ + private static final String cheeringCrowd = "Cheering Crowd"; + + @Test + public void testCheeringCrowd() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, cheeringCrowd); + + setChoice(playerA, true); + setChoice(playerB, true); + setChoice(playerC, true); + setChoice(playerD, true); + + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); + checkManaPool("PlayerA should have 1 Mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "C", 1); + waitStackResolved(2, PhaseStep.PRECOMBAT_MAIN, playerD); + checkManaPool("PlayerD should have 2 Mana", 2, PhaseStep.PRECOMBAT_MAIN, playerD, "C", 2); + waitStackResolved(3, PhaseStep.PRECOMBAT_MAIN, playerC); + checkManaPool("PlayerC should have 3 Mana", 3, PhaseStep.PRECOMBAT_MAIN, playerC, "C", 3); + waitStackResolved(4, PhaseStep.PRECOMBAT_MAIN, playerB); + checkManaPool("PlayerB should have 4 Mana", 4, PhaseStep.PRECOMBAT_MAIN, playerB, "C", 4); + + setStopAt(4, PhaseStep.PRECOMBAT_MAIN); + execute(); + + assertCounterCount(playerA, cheeringCrowd, CounterType.P1P1, 4); + } +} \ No newline at end of file