Scrib Nibblers checks for MagicCard.NONE and actually exiles the card if any. fixes issue 72

master
beholder 2011-10-08 17:52:59 +02:00
parent 6c59a6ee45
commit 33ab9eedd3
2 changed files with 15 additions and 5 deletions

View File

@ -2,12 +2,15 @@ package magic.card;
import magic.model.MagicCard;
import magic.model.MagicGame;
import magic.model.MagicLocationType;
import magic.model.MagicPayedCost;
import magic.model.MagicPermanent;
import magic.model.MagicPlayer;
import magic.model.MagicSource;
import magic.model.action.MagicChangeLifeAction;
import magic.model.action.MagicMoveCardAction;
import magic.model.action.MagicPlayerAction;
import magic.model.action.MagicRemoveCardAction;
import magic.model.action.MagicUntapAction;
import magic.model.choice.MagicMayChoice;
import magic.model.choice.MagicSimpleMayChoice;
@ -79,9 +82,13 @@ public class Scrib_Nibblers {
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choiceResults) {
event.processTargetPlayer(game,choiceResults,0,new MagicPlayerAction() {
public void doAction(final MagicPlayer player) {
final MagicCard card = player.getLibrary().removeCardAtTop();
if (card.getCardDefinition().isLand()) {
game.doAction(new MagicChangeLifeAction((MagicPlayer)data[0],1));
final MagicCard card = player.getLibrary().getCardAtTop();
if (card != MagicCard.NONE) {
game.doAction(new MagicRemoveCardAction(card,MagicLocationType.OwnersLibrary));
game.doAction(new MagicMoveCardAction(card,MagicLocationType.OwnersLibrary,MagicLocationType.Exile));
if (card.getCardDefinition().isLand()) {
game.doAction(new MagicChangeLifeAction((MagicPlayer)data[0],1));
}
}
}
});

View File

@ -53,8 +53,11 @@ public class MagicCardList extends ArrayList<MagicCard> {
return get(0);
}
private MagicCard getCardAtTop() {
return this.get(size()-1);
public MagicCard getCardAtTop() {
final int size = this.size();
return size > 0 ?
this.get(size()-1) :
MagicCard.NONE;
}
public MagicCard removeCardAtTop() {