Fixed possible NPE problems.

This commit is contained in:
LevelX2 2014-09-24 12:40:49 +02:00
parent 371ee4014c
commit 74edb0f0ef
2 changed files with 2 additions and 2 deletions

View file

@ -60,7 +60,7 @@ public class PayLoyaltyCost extends CostImpl {
@Override @Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Permanent planeswalker = game.getPermanent(sourceId); Permanent planeswalker = game.getPermanent(sourceId);
return planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game); return planeswalker != null && planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game);
} }
@Override @Override

View file

@ -63,7 +63,7 @@ public class RemoveCountersSourceCost extends CostImpl {
@Override @Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Permanent permanent = game.getPermanent(sourceId); Permanent permanent = game.getPermanent(sourceId);
if (permanent.getCounters().getCount(name) >= amount) { if (permanent != null && permanent.getCounters().getCount(name) >= amount) {
return true; return true;
} }
return false; return false;