mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Fixed NPE in TopLibraryCardTypeCondition (fixes #300).
This commit is contained in:
parent
655dcea56d
commit
90a41a10e7
1 changed files with 17 additions and 13 deletions
|
@ -31,6 +31,7 @@ import mage.constants.CardType;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.condition.Condition;
|
import mage.abilities.condition.Condition;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jeffwadsworth
|
* @author jeffwadsworth
|
||||||
|
@ -50,19 +51,22 @@ public class TopLibraryCardTypeCondition implements Condition {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
boolean conditionApplies = false;
|
boolean conditionApplies = false;
|
||||||
switch (this.type) {
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
case CREATURE:
|
if (controller != null && controller.getLibrary().size() > 0) {
|
||||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLibrary().getFromTop(game).getCardType().contains(CardType.CREATURE);
|
switch (this.type) {
|
||||||
break;
|
case CREATURE:
|
||||||
case LAND:
|
conditionApplies |= controller.getLibrary().getFromTop(game).getCardType().contains(CardType.CREATURE);
|
||||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLibrary().getFromTop(game).getCardType().contains(CardType.LAND);
|
break;
|
||||||
break;
|
case LAND:
|
||||||
case SORCERY:
|
conditionApplies |= controller.getLibrary().getFromTop(game).getCardType().contains(CardType.LAND);
|
||||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLibrary().getFromTop(game).getCardType().contains(CardType.SORCERY);
|
break;
|
||||||
break;
|
case SORCERY:
|
||||||
case INSTANT:
|
conditionApplies |= controller.getLibrary().getFromTop(game).getCardType().contains(CardType.SORCERY);
|
||||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLibrary().getFromTop(game).getCardType().contains(CardType.INSTANT);
|
break;
|
||||||
break;
|
case INSTANT:
|
||||||
|
conditionApplies |= controller.getLibrary().getFromTop(game).getCardType().contains(CardType.INSTANT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return conditionApplies;
|
return conditionApplies;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue