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