implement [PIP] C.A.M.P.

This commit is contained in:
Susucre 2024-05-01 17:58:06 +02:00
parent 7d431671a3
commit 2c6bb21a9c
3 changed files with 211 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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));

View file

@ -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. (Its 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);
}
}