fixed various NPEs

This commit is contained in:
BetaSteward 2011-09-12 21:15:54 -04:00
parent d01c992f2e
commit ad4b4e82c2
3 changed files with 19 additions and 9 deletions

View file

@ -470,6 +470,8 @@ public class TableController {
}
public boolean isOwner(UUID userId) {
if (userId == null)
return false;
return userId.equals(this.userId);
}

View file

@ -57,14 +57,20 @@ public class PlayerFactory {
Player player;
Constructor<?> con;
try {
con = playerTypes.get(playerType).getConstructor(new Class[]{String.class, RangeOfInfluence.class, int.class});
player = (Player)con.newInstance(new Object[] {name, range, skill});
Class playerTypeClass = playerTypes.get(playerType);
if (playerTypeClass != null) {
con = playerTypeClass.getConstructor(new Class[]{String.class, RangeOfInfluence.class, int.class});
player = (Player)con.newInstance(new Object[] {name, range, skill});
logger.info("Player created: " + name + "-" + player.getId().toString());
return player;
}
else {
logger.fatal("Unknown player type: " + playerType);
}
} catch (Exception ex) {
logger.fatal("PlayerFactory error ", ex);
return null;
}
logger.info("Player created: " + name + "-" + player.getId().toString());
return player;
return null;
}
public Set<String> getPlayerTypes() {

View file

@ -74,10 +74,12 @@ public class PutOnLibraryTargetEffect extends OneShotEffect<PutOnLibraryTargetEf
}
case GRAVEYARD:
Card card = game.getCard(id);
for (Player player : game.getPlayers().values()) {
if (player.getGraveyard().contains(card.getId())) {
player.getGraveyard().remove(card);
result |= card.moveToZone(Zone.LIBRARY, source.getId(), game, onTop);
if (card != null) {
for (Player player : game.getPlayers().values()) {
if (player.getGraveyard().contains(card.getId())) {
player.getGraveyard().remove(card);
result |= card.moveToZone(Zone.LIBRARY, source.getId(), game, onTop);
}
}
}
}