mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
fix Minion of the Wastes, add test
This commit is contained in:
parent
f00e86c47a
commit
f252525cb8
2 changed files with 56 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.common.PayLifeCost;
|
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.InfoEffect;
|
||||||
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
|
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
|
||||||
import mage.abilities.keyword.TrampleAbility;
|
import mage.abilities.keyword.TrampleAbility;
|
||||||
|
|
@ -15,6 +15,8 @@ import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.events.EntersTheBattlefieldEvent;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.CardUtil;
|
import mage.util.CardUtil;
|
||||||
|
|
@ -52,10 +54,10 @@ public final class MinionOfTheWastes extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MinionOfTheWastesEffect extends OneShotEffect {
|
class MinionOfTheWastesEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
MinionOfTheWastesEffect() {
|
MinionOfTheWastesEffect() {
|
||||||
super(Outcome.LoseLife);
|
super(Duration.EndOfGame, Outcome.LoseLife);
|
||||||
staticText = "pay any amount of life";
|
staticText = "pay any amount of life";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,10 +71,20 @@ class MinionOfTheWastesEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
if (creature == null || controller == null) {
|
||||||
if (controller == null || permanent == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
|
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() +
|
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
|
||||||
" pays " + payAmount + " life");
|
" pays " + payAmount + " life");
|
||||||
game.addEffect(new SetBasePowerToughnessSourceEffect(
|
game.addEffect(new SetBasePowerToughnessSourceEffect(
|
||||||
payAmount, payAmount, Duration.Custom
|
payAmount, payAmount, Duration.WhileOnBattlefield
|
||||||
), source);
|
), source);
|
||||||
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
|
creature.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 Wastes’s 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue