updated implementation of Minion of the Wastes and Nameless Race

This commit is contained in:
Evan Kranzler 2019-01-26 09:41:48 -05:00
parent fd0292001e
commit e5f6980b2d
2 changed files with 56 additions and 30 deletions

View file

@ -4,6 +4,8 @@ import mage.MageInt;
import mage.abilities.Ability;
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.common.InfoEffect;
import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect;
@ -13,7 +15,9 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
@ -38,7 +42,7 @@ public final class MinionOfTheWastes extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("{this}'s power and toughness are each equal to the life paid as it entered the battlefield")));
}
public MinionOfTheWastes(final MinionOfTheWastes card) {
private MinionOfTheWastes(final MinionOfTheWastes card) {
super(card);
}
@ -50,12 +54,12 @@ public final class MinionOfTheWastes extends CardImpl {
class MinionOfTheWastesEffect extends OneShotEffect {
public MinionOfTheWastesEffect() {
MinionOfTheWastesEffect() {
super(Outcome.LoseLife);
staticText = "pay any amount of life";
}
public MinionOfTheWastesEffect(final MinionOfTheWastesEffect effect) {
private MinionOfTheWastesEffect(final MinionOfTheWastesEffect effect) {
super(effect);
}
@ -67,15 +71,22 @@ class MinionOfTheWastesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
controller.loseLife(payAmount, game, false);
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
return false;
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
Cost cost = new PayLifeCost(payAmount);
if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) {
return false;
}
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(
payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a
), source);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
}
}

View file

@ -5,6 +5,8 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.dynamicvalue.common.CardsInAllGraveyardsCount;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
@ -23,7 +25,9 @@ import mage.filter.predicate.other.OwnerPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.filter.predicate.permanent.TokenPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
@ -47,7 +51,7 @@ public final class NamelessRace extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("{this}'s power and toughness are each equal to the life paid as it entered the battlefield")));
}
public NamelessRace(final NamelessRace card) {
private NamelessRace(final NamelessRace card) {
super(card);
}
@ -59,8 +63,10 @@ public final class NamelessRace extends CardImpl {
class NamelessRaceEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterPermanent("white nontoken permanents your opponents control");
private static final FilterCard filter2 = new FilterCard("white cards in their graveyards");
private static final FilterPermanent filter
= new FilterPermanent("white nontoken permanents your opponents control");
private static final FilterCard filter2
= new FilterCard("white cards in their graveyards");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
@ -70,12 +76,14 @@ class NamelessRaceEffect extends OneShotEffect {
filter2.add(new OwnerPredicate(TargetController.OPPONENT));
}
public NamelessRaceEffect() {
NamelessRaceEffect() {
super(Outcome.LoseLife);
staticText = "pay any amount of life. The amount you pay can't be more than the total number of white nontoken permanents your opponents control plus the total number of white cards in their graveyards";
staticText = "pay any amount of life. The amount you pay can't be more than " +
"the total number of white nontoken permanents your opponents control " +
"plus the total number of white cards in their graveyards";
}
public NamelessRaceEffect(final NamelessRaceEffect effect) {
private NamelessRaceEffect(final NamelessRaceEffect effect) {
super(effect);
}
@ -87,18 +95,25 @@ class NamelessRaceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null);
int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null);
int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife());
int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game);
controller.loseLife(payAmount, game, false);
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.SetPT_7b), source);
return true;
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller == null || permanent == null) {
return false;
}
return false;
int permanentsInPlay = new PermanentsOnBattlefieldCount(filter).calculate(game, source, null);
int cardsInGraveyards = new CardsInAllGraveyardsCount(filter2).calculate(game, source, null);
int maxAmount = Math.min(permanentsInPlay + cardsInGraveyards, controller.getLife());
int payAmount = controller.getAmount(0, maxAmount, "Pay up to " + maxAmount + " life", game);
Cost cost = new PayLifeCost(payAmount);
if (!cost.pay(source, game, source.getSourceId(), source.getControllerId(), true)) {
return false;
}
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(
payAmount, payAmount, Duration.Custom, SubLayer.CharacteristicDefining_7a
), source);
permanent.addInfo("life paid", CardUtil.addToolTipMarkTags("Life paid: " + payAmount), game);
return true;
}
}