Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Templates.js
/** | /** | ||||
* Loads history and gameplay data of all civs. | * Loads history and gameplay data of all civs. | ||||
* Can be used from GUI and rmgen (because the simulation functions differ currently). | |||||
* | * | ||||
* @param selectableOnly {boolean} - Only load civs that can be selected | * @param selectableOnly {boolean} - Only load civs that can be selected | ||||
* in the gamesetup. Scenario maps might set non-selectable civs. | * in the gamesetup. Scenario maps might set non-selectable civs. | ||||
*/ | */ | ||||
function loadCivFiles(selectableOnly) | function loadCivFiles(selectableOnly) | ||||
{ | { | ||||
let propertyNames = [ | let propertyNames = [ | ||||
"Code", "Culture", "Name", "Emblem", "History", "Music", "Factions", "CivBonuses", "TeamBonuses", | "Code", "Culture", "Name", "Emblem", "History", "Music", "Factions", "CivBonuses", "TeamBonuses", | ||||
"Structures", "StartEntities", "Formations", "AINames", "SkirmishReplacements", "SelectableInGameSetup"]; | "Structures", "StartEntities", "Formations", "AINames", "SkirmishReplacements", "SelectableInGameSetup"]; | ||||
let civData = {}; | let civData = {}; | ||||
for (let filename of Engine.BuildDirEntList("simulation/data/civs/", "*.json", false)) | for (let filename of Engine.ListDirectoryFiles("simulation/data/civs/", "*.json", false)) | ||||
{ | { | ||||
let data = Engine.ReadJSONFile(filename); | let data = Engine.ReadJSONFile(filename); | ||||
for (let prop of propertyNames) | for (let prop of propertyNames) | ||||
if (data[prop] === undefined) | if (data[prop] === undefined) | ||||
throw new Error(filename + " doesn't contain " + prop); | throw new Error(filename + " doesn't contain " + prop); | ||||
if (!selectableOnly || data.SelectableInGameSetup) | if (!selectableOnly || data.SelectableInGameSetup) | ||||
▲ Show 20 Lines • Show All 494 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator