// configure the game config with the player names
config.players = new Name[_playerCount];
config.players[0] = _source.getVisibleName();
for (int ii = 1; ii < _playerCount; ii++) {
config.players[ii] = new Name("simulant" + ii);
}
_gmgr = (GameManager)_plreg.createPlace(config);
} catch (Exception e) {
log.warning("Unable to create game manager", "e", e, e);
return;
}
// cast the place to the game object for the game we're creating
_gobj = (GameObject)_gmgr.getPlaceObject();
// determine the AI player skill level
byte skill;
try {
skill = Byte.parseByte(System.getProperty("skill"));
} catch (NumberFormatException nfe) {
skill = DEFAULT_SKILL;
}
for (int ii = 1; ii < _playerCount; ii++) {
// mark all simulants as AI players
_gmgr.setAI(ii, new GameAI(0, skill));
}
// resolve the simulant body objects
ClientResolutionListener listener = new ClientResolutionListener() {
public void clientResolved (Name username, ClientObject clobj) {
// hold onto the body object for later game creation
_sims.add(clobj);
// create the game if we've received all body objects
if (_sims.size() == (_playerCount - 1)) {
createSimulants();
}
}
public void resolutionFailed (Name username, Exception cause) {
log.warning("Unable to create simulant body object", "error", cause);
}
};
// resolve client objects for all of our simulants
for (int ii = 1; ii < _playerCount; ii++) {
Name username = new Name("simulant" + ii);
_clmgr.resolveClientObject(username, listener);
}
}