This commit is contained in:
Jeff 2019-03-14 11:34:56 -05:00
parent a969fc8470
commit 9aae8c8db7

View file

@ -1,6 +1,5 @@
package mage.cards.l; package mage.cards.l;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -13,7 +12,6 @@ import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerList;
import mage.watchers.common.PlayerLostLifeWatcher; import mage.watchers.common.PlayerLostLifeWatcher;
/** /**
@ -32,8 +30,12 @@ public final class LudevicNecroAlchemist extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// At the beginning of each player's end step, that player may draw a card if a player other than you lost life this turn. // At the beginning of each player's end step, that player may draw a card if a player other than you lost life this turn.
this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, this.addAbility(new BeginningOfEndStepTriggeredAbility(
new LudevicNecroAlchemistEffect(), TargetController.EACH_PLAYER, new LudevicNecroAlchemistCondition(), false)); Zone.BATTLEFIELD,
new LudevicNecroAlchemistEffect(),
TargetController.EACH_PLAYER,
new LudevicNecroAlchemistCondition(),
false));
// Partner // Partner
this.addAbility(PartnerAbility.getInstance()); this.addAbility(PartnerAbility.getInstance());
@ -54,24 +56,15 @@ class LudevicNecroAlchemistCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
PlayerList playerList = game.getState().getPlayerList().copy(); Player controller = game.getPlayer(source.getControllerId());
Player currentPlayer; if (controller != null
UUID sourcePlayerId = source.getControllerId(); && watcher != null
Player firstPlayer; && watcher.getLifeLost(controller.getId()) == 0) {
if (playerList == null) { for (UUID playerId : controller.getInRange()) {
return false; if (watcher.getLifeLost(playerId) > 0) {
}
firstPlayer = playerList.getCurrent(game);
currentPlayer = playerList.getNext(game);
while (watcher != null && currentPlayer != null) {
if (!Objects.equals(currentPlayer.getId(), sourcePlayerId) && watcher.getLifeLost(currentPlayer.getId()) > 0) {
return true; return true;
} }
if (Objects.equals(currentPlayer, firstPlayer)) {
return false;
} }
currentPlayer = playerList.getNext(game);
} }
return false; return false;
} }
@ -100,14 +93,12 @@ class LudevicNecroAlchemistEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UUID playerId = game.getActivePlayerId(); Player player = game.getPlayer(game.getActivePlayerId());
if (playerId != null) { if (player != null
Player player = game.getPlayer(playerId); && player.chooseUse(Outcome.DrawCard, "Draw a card?", source, game)) {
if (player != null && player.chooseUse(outcome, "Draw a card?", source, game)) {
player.drawCards(1, game); player.drawCards(1, game);
return true; return true;
} }
}
return false; return false;
} }
} }