Differential D4333 Diff 19020 ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateLoader.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateLoader.js
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | class TemplateLoader | ||||
{ | { | ||||
let template = this.loadTechnologyTemplate(templateName); | let template = this.loadTechnologyTemplate(templateName); | ||||
return { | return { | ||||
"techs": [template.top, template.bottom], | "techs": [template.top, template.bottom], | ||||
"reqs": DeriveTechnologyRequirements(template, civCode) | "reqs": DeriveTechnologyRequirements(template, civCode) | ||||
}; | }; | ||||
} | } | ||||
deriveProductionQueue(template, civCode) | deriveProduction(template, civCode) | ||||
{ | { | ||||
let production = { | const production = { | ||||
"techs": [], | "techs": [], | ||||
"units": [] | "units": [] | ||||
}; | }; | ||||
if (!template.ProductionQueue) | if (!template.Researcher && !template.Trainer) | ||||
return production; | return production; | ||||
if (template.ProductionQueue.Entities && template.ProductionQueue.Entities._string) | if (template.Trainer?.Entities?._string) | ||||
for (let templateName of template.ProductionQueue.Entities._string.split(" ")) | for (let templateName of template.Trainer.Entities._string.split(" ")) | ||||
{ | { | ||||
templateName = templateName.replace(/\{(civ|native)\}/g, civCode); | templateName = templateName.replace(/\{(civ|native)\}/g, civCode); | ||||
if (Engine.TemplateExists(templateName)) | if (Engine.TemplateExists(templateName)) | ||||
production.units.push(templateName); | production.units.push(templateName); | ||||
} | } | ||||
let appendTechnology = (technologyName) => { | const appendTechnology = (technologyName) => { | ||||
let technology = this.loadTechnologyTemplate(technologyName, civCode); | const technology = this.loadTechnologyTemplate(technologyName, civCode); | ||||
if (DeriveTechnologyRequirements(technology, civCode)) | if (DeriveTechnologyRequirements(technology, civCode)) | ||||
production.techs.push(technologyName); | production.techs.push(technologyName); | ||||
}; | }; | ||||
if (template.ProductionQueue.Technologies && template.ProductionQueue.Technologies._string) | if (template.Researcher?.Technologies?._string) | ||||
for (let technologyName of template.ProductionQueue.Technologies._string.split(" ")) | for (let technologyName of template.Researcher.Technologies._string.split(" ")) | ||||
{ | { | ||||
if (technologyName.indexOf("{civ}") != -1) | if (technologyName.indexOf("{civ}") != -1) | ||||
{ | { | ||||
let civTechName = technologyName.replace("{civ}", civCode); | const civTechName = technologyName.replace("{civ}", civCode); | ||||
technologyName = TechnologyTemplateExists(civTechName) ? civTechName : technologyName.replace("{civ}", "generic"); | technologyName = TechnologyTemplateExists(civTechName) ? civTechName : technologyName.replace("{civ}", "generic"); | ||||
} | } | ||||
if (this.isPairTech(technologyName)) | if (this.isPairTech(technologyName)) | ||||
{ | { | ||||
let technologyPair = this.loadTechnologyPairTemplate(technologyName, civCode); | let technologyPair = this.loadTechnologyPairTemplate(technologyName, civCode); | ||||
if (technologyPair.reqs) | if (technologyPair.reqs) | ||||
for (technologyName of technologyPair.techs) | for (technologyName of technologyPair.techs) | ||||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator