Differential D4833 Diff 21224 ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateParser.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateParser.js
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | getEntity(templateName, civCode) | ||||
parsed.history = template.Identity.History; | parsed.history = template.Identity.History; | ||||
parsed.production = this.TemplateLoader.deriveProduction(template, civCode); | parsed.production = this.TemplateLoader.deriveProduction(template, civCode); | ||||
if (template.Builder) | if (template.Builder) | ||||
parsed.builder = this.TemplateLoader.deriveBuildQueue(template, civCode); | parsed.builder = this.TemplateLoader.deriveBuildQueue(template, civCode); | ||||
// Set the minimum phase that this entity is available. | // Set the minimum phase that this entity is available. | ||||
// For gaia objects, this is meaningless. | // For gaia objects, this is meaningless. | ||||
if (!parsed.requirements) | // Complex requirements are too difficult to process for now, so assume the first phase. | ||||
if (!parsed.requirements?.Techs) | |||||
parsed.phase = this.phaseList[0]; | parsed.phase = this.phaseList[0]; | ||||
else if (this.TemplateLoader.isPhaseTech(parsed.requirements.Techs)) | |||||
parsed.phase = this.getActualPhase(parsed.requirements.Techs); | |||||
else | else | ||||
parsed.phase = this.getPhaseOfTechnology(parsed.requirements.Techs, civCode); | { | ||||
let highestPhaseIndex = 0; | |||||
for (const tech of parsed.requirements.Techs.split(" ")) | |||||
{ | |||||
if (tech[0] === "!") | |||||
continue; | |||||
const phaseIndex = this.phaseList.indexOf( | |||||
this.TemplateLoader.isPhaseTech(tech) ? this.getActualPhase(tech) : | |||||
this.getPhaseOfTechnology(tech, civCode)); | |||||
if (phaseIndex > highestPhaseIndex) | |||||
highestPhaseIndex = phaseIndex; | |||||
} | |||||
parsed.phase = this.phaseList[highestPhaseIndex]; | |||||
} | |||||
if (template.Identity.Rank) | if (template.Identity.Rank) | ||||
parsed.promotion = { | parsed.promotion = { | ||||
"current_rank": template.Identity.Rank, | "current_rank": template.Identity.Rank, | ||||
"entity": template.Promotion && template.Promotion.Entity | "entity": template.Promotion && template.Promotion.Entity | ||||
}; | }; | ||||
if (template.ResourceSupply) | if (template.ResourceSupply) | ||||
▲ Show 20 Lines • Show All 307 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator