String sCheck = p.getProperty("MMSVersion");
if (sCheck == null) {
throw new Exception("Not a valid MMS file. No MMSVersion.");
}
Game g = new Game();
// build the board
g.board = createBoard(p);
// build the faction players
Player[] players = createPlayers(p);
for (int x = 0; x < players.length; x++) {
g.addPlayer(x, players[x]);
}
// build the entities
int nIndex = 0;
for (int x = 0; x < players.length; x++) {
Entity[] entities = buildFactionEntities(p, players[x]);
for (int y = 0; y < entities.length; y++) {
entities[y].setOwner(players[x]);
entities[y].setId(nIndex++);
g.addEntity(entities[y].getId(), entities[y]);
}
}
// game's ready
g.getOptions().initialize();
String optionFile = p.getProperty("GameOptionsFile");
if (optionFile == null) {
g.getOptions().loadOptions();
} else {
g.getOptions().loadOptions(
new File(m_scenFile.getParentFile(), optionFile));
}
// set wind
g.getPlanetaryConditions().determineWind();
// Set up the teams (for initiative)
g.setupTeams();
g.setPhase(IGame.Phase.PHASE_STARTING_SCENARIO);
g.setupRoundDeployment();
// Read the external game id from the scenario file
g.setExternalGameId(parseExternalGameId(p));
g.setVictoryContext(new HashMap<String, Object>());
g.createVictoryConditions();
return g;
}