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) { public boolean isOwner(UUID userId) {
if (userId == null)
return false;
return userId.equals(this.userId); return userId.equals(this.userId);
} }

View file

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

View file

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