public Table createTable (BodyObject creator, TableConfig tableConfig, GameConfig config)
throws InvocationException
{
// make sure the caller is not already in a table
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);
}