[SPM] implement Mr. Negative

This commit is contained in:
jmlundeen 2025-09-05 10:08:04 -05:00
parent fec244c675
commit d5fa369e4d
3 changed files with 153 additions and 0 deletions

View file

@ -0,0 +1,89 @@
package mage.cards.m;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author Jmlundeen
*/
public final class MrNegative extends CardImpl {
public MrNegative(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{W}{B}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.VILLAIN);
this.power = new MageInt(5);
this.toughness = new MageInt(5);
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// Lifelink
this.addAbility(LifelinkAbility.getInstance());
// When Mr. Negative enters, you may exchange your life total with target opponent. If you lose life this way, draw that many cards.
Ability ability = new EntersBattlefieldTriggeredAbility(new MrNegativeEffect(), true);
ability.addTarget(new TargetOpponent());
this.addAbility(ability);
}
private MrNegative(final MrNegative card) {
super(card);
}
@Override
public MrNegative copy() {
return new MrNegative(this);
}
}
class MrNegativeEffect extends OneShotEffect {
public MrNegativeEffect() {
super(Outcome.Neutral);
staticText = "When {this} enters, you may exchange your life total with target opponent. If you lose life this way, draw that many cards.";
}
protected MrNegativeEffect(final MrNegativeEffect effect) {
super(effect);
}
@Override
public MrNegativeEffect copy() {
return new MrNegativeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (controller == null || player == null) {
return false;
}
int startingLife = controller.getLife();
controller.exchangeLife(player, source, game);
int lifeChange = startingLife - controller.getLife();
if (lifeChange > 0) {
controller.drawCards(lifeChange, source, game);
}
return true;
}
}

View file

@ -136,6 +136,7 @@ public final class MarvelsSpiderMan extends ExpansionSet {
cards.add(new SetCardInfo("Morlun, Devourer of Spiders", 59, Rarity.RARE, mage.cards.m.MorlunDevourerOfSpiders.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 192, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 197, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mr. Negative", 135, Rarity.MYTHIC, mage.cards.m.MrNegative.class));
cards.add(new SetCardInfo("Multiversal Passage", 180, Rarity.RARE, mage.cards.m.MultiversalPassage.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Multiversal Passage", 206, Rarity.RARE, mage.cards.m.MultiversalPassage.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mysterio's Phantasm", 38, Rarity.COMMON, mage.cards.m.MysteriosPhantasm.class));

View file

@ -0,0 +1,63 @@
package org.mage.test.cards.single.spm;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author Jmlundeen
*/
public class MrNegativeTest extends CardTestPlayerBase {
/*
Mr. Negative
{5}{W}{B}
Legendary Creature - Human Villain
Vigilance, lifelink
When Mr. Negative enters, you may exchange your life total with target opponent. If you lose life this way, draw that many cards.
5/5
*/
private static final String mrNegative = "Mr. Negative";
@Test
public void testMrNegative() {
setStrictChooseMode(true);
addCard(Zone.HAND, playerA, mrNegative);
addCard(Zone.BATTLEFIELD, playerA, "Scrubland", 7);
setLife(playerB, 15);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mrNegative);
addTarget(playerA, playerB);
setChoice(playerA, true);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertHandCount(playerA, 5);
assertLife(playerA, 15);
assertLife(playerB, 20);
}
@Test
public void testMrNegativeNoDraw() {
setStrictChooseMode(true);
addCard(Zone.HAND, playerA, mrNegative);
addCard(Zone.BATTLEFIELD, playerA, "Scrubland", 7);
setLife(playerB, 21);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, mrNegative);
addTarget(playerA, playerB);
setChoice(playerA, true);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertHandCount(playerA, 0);
assertLife(playerA, 21);
assertLife(playerB, 20);
}
}