From 2c6bb21a9c2b928d02dc2f993984a90f7f25ced8 Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Wed, 1 May 2024 17:58:06 +0200 Subject: [PATCH] implement [PIP] C.A.M.P. --- Mage.Sets/src/mage/cards/c/CAMP.java | 135 ++++++++++++++++++ Mage.Sets/src/mage/sets/Fallout.java | 1 + .../mage/test/cards/single/pip/CAMPTest.java | 75 ++++++++++ 3 files changed, 211 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CAMP.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/pip/CAMPTest.java diff --git a/Mage.Sets/src/mage/cards/c/CAMP.java b/Mage.Sets/src/mage/cards/c/CAMP.java new file mode 100644 index 00000000000..501a168bf6c --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CAMP.java @@ -0,0 +1,135 @@ +package mage.cards.c; + +import mage.Mana; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.keyword.FortifyAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.TappedForManaEvent; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.JunkToken; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author Susucr + */ +public final class CAMP extends CardImpl { + + public CAMP(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); + + this.subtype.add(SubType.FORTIFICATION); + + // Whenever fortified land is tapped for mana, put a +1/+1 counter on target creature you control. If that creature shares a color with the mana that land produced, create a Junk token. + this.addAbility(new CAMPTriggeredAbility()); + + // Fortify {3} + this.addAbility(new FortifyAbility(3)); + } + + private CAMP(final CAMP card) { + super(card); + } + + @Override + public CAMP copy() { + return new CAMP(this); + } +} + + +class CAMPTriggeredAbility extends TriggeredAbilityImpl { + + CAMPTriggeredAbility() { + super(Zone.BATTLEFIELD, null); + addTarget(new TargetControlledCreaturePermanent()); + } + + private CAMPTriggeredAbility(final CAMPTriggeredAbility ability) { + super(ability); + } + + @Override + public CAMPTriggeredAbility copy() { + return new CAMPTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.TAPPED_FOR_MANA; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent fortification = game.getPermanent(getSourceId()); + if (fortification == null || !event.getSourceId().equals(fortification.getAttachedTo())) { + return false; + } + TappedForManaEvent mEvent = (TappedForManaEvent) event; + Mana mana = mEvent.getMana(); + getEffects().clear(); + getEffects().add(new AddCountersTargetEffect(CounterType.P1P1.createInstance())); + getEffects().add(new CAMPEffect(mana)); + return true; + } + + @Override + public String getRule() { + return "Whenever fortified land is tapped for mana, put a +1/+1 counter on target creature you control. " + + "If that creature shares a color with the mana that land produced, create a Junk token."; + } +} + +class CAMPEffect extends OneShotEffect { + + private final Mana mana; + + CAMPEffect(Mana mana) { + super(Outcome.Benefit); + this.mana = mana.copy(); + } + + private CAMPEffect(final CAMPEffect effect) { + super(effect); + this.mana = effect.mana; + } + + @Override + public CAMPEffect copy() { + return new CAMPEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); + if (target == null) { + return false; + } + ObjectColor targetColor = target.getColor(game); + if (mana.getWhite() > 0 && targetColor.isWhite() + || (mana.getBlue() > 0 && targetColor.isBlue()) + || (mana.getBlack() > 0 && targetColor.isBlack()) + || (mana.getRed() > 0 && targetColor.isRed()) + || (mana.getGreen() > 0 && targetColor.isGreen()) + ) { + return new CreateTokenEffect(new JunkToken()) + .apply(game, source); + } + return false; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Fallout.java b/Mage.Sets/src/mage/sets/Fallout.java index 35daa8339be..47d3901089c 100644 --- a/Mage.Sets/src/mage/sets/Fallout.java +++ b/Mage.Sets/src/mage/sets/Fallout.java @@ -68,6 +68,7 @@ public final class Fallout extends ExpansionSet { cards.add(new SetCardInfo("Brotherhood Vertibird", 128, Rarity.RARE, mage.cards.b.BrotherhoodVertibird.class)); cards.add(new SetCardInfo("Buried Ruin", 254, Rarity.UNCOMMON, mage.cards.b.BuriedRuin.class)); cards.add(new SetCardInfo("Butch DeLoria, Tunnel Snake", 43, Rarity.UNCOMMON, mage.cards.b.ButchDeLoriaTunnelSnake.class)); + cards.add(new SetCardInfo("C.A.M.P.", 129, Rarity.UNCOMMON, mage.cards.c.CAMP.class)); cards.add(new SetCardInfo("Caesar, Legion's Emperor", 1, Rarity.MYTHIC, mage.cards.c.CaesarLegionsEmperor.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Caesar, Legion's Emperor", 339, Rarity.MYTHIC, mage.cards.c.CaesarLegionsEmperor.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Caesar, Legion's Emperor", 529, Rarity.MYTHIC, mage.cards.c.CaesarLegionsEmperor.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/pip/CAMPTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/pip/CAMPTest.java new file mode 100644 index 00000000000..42d25bb42b4 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/pip/CAMPTest.java @@ -0,0 +1,75 @@ +package org.mage.test.cards.single.pip; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.counters.CounterType; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author Susucr + */ +public class CAMPTest extends CardTestPlayerBase { + + /** + * {@link mage.cards.c.CAMP C.A.M.P.} {3} + * Artifact β€” Fortification + * Whenever fortified land is tapped for mana, put a +1/+1 counter on target creature you control. If that creature shares a color with the mana that land produced, create a Junk token. (It’s an artifact with β€œ{T}, Sacrifice this artifact: Exile the top card of your library. You may play that card this turn. Activate only as a sorcery.”) + * Fortify {3} ({3}: Attach to target land you control. Fortify only as a sorcery.) + */ + private static final String camp = "C.A.M.P."; + + @Test + public void test_ShareColor() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, camp); + addCard(Zone.BATTLEFIELD, playerA, "Coiling Oracle"); // UG creature + addCard(Zone.BATTLEFIELD, playerA, "Wastes", 3); + addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 1); + + // Make sure mana from Wastes is used first. + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C}", 3); + + // Fortify the Volcanic Island + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fortify {3}", "Volcanic Island"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); + + // Tap the fortified Volcanic Island for {U} + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {U}"); + addTarget(playerA, "Coiling Oracle"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertCounterCount(playerA, "Coiling Oracle", CounterType.P1P1, 1); + assertPermanentCount(playerA, "Junk Token", 1); + } + + @Test + public void test_DontShareColor() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, camp); + addCard(Zone.BATTLEFIELD, playerA, "Coiling Oracle"); // UG creature + addCard(Zone.BATTLEFIELD, playerA, "Wastes", 3); + addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 1); + + // Make sure mana from Wastes is used first. + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {C}", 3); + + // Fortify the Volcanic Island + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Fortify {3}", "Volcanic Island"); + waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA); + + // Tap the fortified Volcanic Island for {R} + activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}"); + addTarget(playerA, "Coiling Oracle"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertCounterCount(playerA, "Coiling Oracle", CounterType.P1P1, 1); + assertPermanentCount(playerA, "Junk Token", 0); + } +}