try {
if (seatId == null) {
try {
seatId = serverTable.addPlayer(player);
} catch (PlayerListFullException e) {
throw new IllegalActionException("Joining table " + mediatingTable.getTableId().toString()
+ " failed: " + e.getMessage());
}
}else{
serverTable.addPlayer(seatId, player);
}
} catch (SeatTakenException e) {
throw new IllegalActionException("Joining table " + mediatingTable.getTableId().toString()
+ " is not a valid action." + e.getMessage());
} catch (IllegalActionException e) {
throw new IllegalActionException("Joining table " + mediatingTable.getTableId().toString()
+ " is not a valid action." + e.getMessage());
}
player.setSittingIn(true);
mediatingTable.publishSitInEvent(new SitInEvent(player.getMemento()));
return new HoldemPlayerContextImpl(player, mediatingTable);