fix Minion of the Wastes, add test

This commit is contained in:
xenohedron 2025-03-15 16:33:37 -04:00
parent f00e86c47a
commit f252525cb8
2 changed files with 56 additions and 9 deletions

View file

@ -6,7 +6,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
import mage.abilities.keyword.TrampleAbility;
@ -15,6 +15,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
@ -52,10 +54,10 @@ public final class MinionOfTheWastes extends CardImpl {
}
}
class MinionOfTheWastesEffect extends OneShotEffect {
class MinionOfTheWastesEffect extends ReplacementEffectImpl {
MinionOfTheWastesEffect() {
super(Outcome.LoseLife);
super(Duration.EndOfGame, Outcome.LoseLife);
staticText = "pay any amount of life";
}
@ -69,10 +71,20 @@ class MinionOfTheWastesEffect extends OneShotEffect {
}
@Override
public boolean apply(Game game, Ability source) {
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getTargetId().equals(source.getSourceId());
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent creature = ((EntersTheBattlefieldEvent) event).getTarget();
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
if (creature == null || controller == null) {
return false;
}
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
@ -84,9 +96,9 @@ class MinionOfTheWastesEffect extends OneShotEffect {
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetBasePowerToughnessSourceEffect(
payAmount, payAmount, Duration.Custom
payAmount, payAmount, Duration.WhileOnBattlefield
), source);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
creature.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return false;
}
}

View file

@ -0,0 +1,35 @@
package org.mage.test.cards.single.tmp;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class MinionOfTheWastesTest extends CardTestPlayerBase {
private static final String minion = "Minion of the Wastes";
/* Trample
* As this creature enters, pay any amount of life.
* Minion of the Wastess power and toughness are each equal to the life paid as it entered.
*/
@Test
public void testSimple() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 6);
addCard(Zone.HAND, playerA, minion);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, minion);
setChoice(playerA, "X=3");
setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN);
execute();
assertLife(playerA, 17);
assertPowerToughness(playerA, minion, 3, 3);
}
}