Some formatting, NPE checking and log messages.

This commit is contained in:
LevelX2 2014-06-20 08:25:03 +02:00
parent e57aee7fcb
commit e51213a72a
3 changed files with 13 additions and 8 deletions

View file

@ -123,7 +123,7 @@ class BattlefieldThaumaturgeSpellsCostReductionEffect extends CostModificationEf
if ((abilityToModify instanceof SpellAbility) if ((abilityToModify instanceof SpellAbility)
&& abilityToModify.getControllerId().equals(source.getControllerId())) { && abilityToModify.getControllerId().equals(source.getControllerId())) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
return spell != null && this.filter.match(spell, game); return spell != null && BattlefieldThaumaturgeSpellsCostReductionEffect.filter.match(spell, game);
} }
return false; return false;
} }

View file

@ -204,7 +204,7 @@ public abstract class GameCommanderImpl extends GameImpl {
@Override @Override
public Set<UUID> getOpponents(UUID playerId) { public Set<UUID> getOpponents(UUID playerId) {
Set<UUID> opponents = new HashSet<UUID>(); Set<UUID> opponents = new HashSet<>();
for (UUID opponentId: this.getPlayer(playerId).getInRange()) { for (UUID opponentId: this.getPlayer(playerId).getInRange()) {
if (!opponentId.equals(playerId)) { if (!opponentId.equals(playerId)) {
opponents.add(opponentId); opponents.add(opponentId);

View file

@ -937,11 +937,16 @@ public abstract class GameImpl implements Game, Serializable {
@Override @Override
public synchronized void quit(UUID playerId) { public synchronized void quit(UUID playerId) {
Player player = state.getPlayer(playerId); if (state != null) {
if (player != null) { Player player = state.getPlayer(playerId);
player.quit(this); if (player != null) {
}else { logger.debug(player.getName() + " quits the game");
logger.error(new StringBuilder("quit - player not found - playerId: ").append(playerId)); player.quit(this);
}else {
logger.error(new StringBuilder("quit - player not found - playerId: ").append(playerId));
}
} else {
logger.error(new StringBuilder("quit - state not found - playerId: ").append(playerId));
} }
} }
@ -1841,7 +1846,7 @@ public abstract class GameImpl implements Game, Serializable {
@Override @Override
public void leave(UUID playerId) { public void leave(UUID playerId) {
Player player = getPlayer(playerId); Player player = getPlayer(playerId);
if (player.hasLeft()) { if (player == null || player.hasLeft()) {
return; return;
} }
player.leave(); player.leave();