mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
fixed various NPEs
This commit is contained in:
parent
d01c992f2e
commit
ad4b4e82c2
3 changed files with 19 additions and 9 deletions
|
@ -470,6 +470,8 @@ public class TableController {
|
|||
}
|
||||
|
||||
public boolean isOwner(UUID userId) {
|
||||
if (userId == null)
|
||||
return false;
|
||||
return userId.equals(this.userId);
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue