protected void performAutostart() {
DebugConfig debugConfig = client.getConfig().getDebug();
if (!autostartPerfomed && debugConfig != null && debugConfig.isAutostartEnabled()) {
autostartPerfomed = true; //apply autostart only once
AutostartConfig autostartConfig = debugConfig.getAutostart();
final PresetConfig presetCfg = client.getConfig().getPresets().get(autostartConfig.getPreset());
if (presetCfg == null) {
logger.warn("Autostart profile {} not found.", autostartConfig.getPreset());
return;
}
final List<String> players = autostartConfig.getPlayers() == null ? new ArrayList<String>() : autostartConfig.getPlayers();
if (players.isEmpty()) {
players.add("Player");
}
int i = 0;
for (String name: players) {
Class<?> clazz = null;;
PlayerSlot slot = ((CreateGamePhase) game.getPhase()).getPlayerSlots()[i];
try {
clazz = Class.forName(name);
slot.setAiClassName(name);
name = "AI-" + i + "-" + clazz.getSimpleName().replace("AiPlayer", "");
} catch (ClassNotFoundException e) {
//empty
}
TakeSlotMessage msg = new TakeSlotMessage(game.getGameId(), i, name);
if (slot.getAiClassName() != null) {
msg.setAiClassName(slot.getAiClassName());
}
conn.send(msg);
i++;
}
presetCfg.updateGameSetup(conn, game.getGameId());
conn.send(new StartGameMessage(game.getGameId()));
}
}