if (_boidMap.containsKey(creator.getOid())) {
throw new InvocationException(ALREADY_AT_TABLE);
}
// create a brand spanking new table
Table table;
try {
table = _tableClass.newInstance();
} catch (Exception e) {
log.warning("Table.newInstance() failed", "class", _tableClass, e);
throw new InvocationException(INTERNAL_ERROR);
}
table.init(_dobj.getOid(), tableConfig, config);
if (table.bodyOids != null && table.bodyOids.length > 0) {
// stick the creator into the first non-AI position
int cpos = (config.ais == null) ? 0 : config.ais.length;
String error = table.setPlayer(cpos, creator);
if (error != null) {
log.warning("Unable to add creator to position zero of table!?",
"table", table, "creator", creator, "error", error);
// bail out now and abort the table creation process
throw new InvocationException(error);
}
// make a mapping from the creator to this table
notePlayerAdded(table, creator);
}
// stick the table into our tables tables
_tables.put(table.tableId, table);
// if the table has only one seat, start the game immediately
if (table.shouldBeStarted()) {
createGame(table);
}
// wire our table into our bits
tableCreated(table);