mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Some fixes to prevent null pointer exceptions.
This commit is contained in:
parent
ad2f5a4d46
commit
1ccd2a1b04
3 changed files with 20 additions and 20 deletions
|
@ -45,7 +45,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.players.PlayerList;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -103,31 +102,30 @@ class ZursWeirdingReplacementEffect extends ReplacementEffectImpl {
|
|||
Card card = player.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
// reveals it instead
|
||||
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum()+"|"+game.getPhase().getType() +")", new CardsImpl(card), game);
|
||||
player.revealCards(sourceObject.getIdName() + " next draw of " + player.getName() + " (" + game.getTurnNum() + "|" + game.getPhase().getType() + ")", new CardsImpl(card), game);
|
||||
|
||||
// Then any other player may pay 2 life. If a player does, put that card into its owner's graveyard
|
||||
PlayerList playerList = game.getPlayerList().copy();
|
||||
playerList.setCurrent(player.getId());
|
||||
Player currentPlayer = playerList.getNext(game);
|
||||
String message = new StringBuilder("Pay 2 life to put ").append(card.getLogName()).append(" into graveyard?").toString();
|
||||
while (!currentPlayer.getId().equals(player.getId())) {
|
||||
if (currentPlayer.canPayLifeCost() &&
|
||||
currentPlayer.getLife() >= 2 &&
|
||||
currentPlayer.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
currentPlayer.loseLife(2, game);
|
||||
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
// game.getState().getRevealed().reset();
|
||||
return true;
|
||||
String message = "Pay 2 life to put " + card.getLogName() + " into graveyard?";
|
||||
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
|
||||
if (playerId.equals(player.getId())) {
|
||||
continue;
|
||||
}
|
||||
Player otherPlayer = game.getPlayer(playerId);
|
||||
if (otherPlayer.canPayLifeCost()
|
||||
&& otherPlayer.getLife() >= 2
|
||||
&& otherPlayer.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
otherPlayer.loseLife(2, game);
|
||||
player.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
break;
|
||||
}
|
||||
|
||||
currentPlayer = playerList.getNext(game);
|
||||
}
|
||||
|
||||
// game.getState().getRevealed().reset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_CARD;
|
||||
|
|
|
@ -93,7 +93,7 @@ class DeadlockTrapCantActivateEffect extends RestrictionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||
return getTargetPointer().getFirst(game, source).equals(permanent.getId());
|
||||
return permanent.getId().equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,8 +100,10 @@ class ForkInTheRoadEffect extends OneShotEffect {
|
|||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = controller.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null) {
|
||||
revealed.add(card);
|
||||
}
|
||||
}
|
||||
controller.revealCards(sourceObject.getIdName(), revealed, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
|
|
Loading…
Reference in a new issue