Differential D4912 Diff 21475 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 71 Lines • ▼ Show 20 Lines | getEntity(templateName, 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. | ||||
// Complex requirements are too difficult to process for now, so assume the first phase. | // Complex requirements are too difficult to process for now, so assume the first phase. | ||||
if (!parsed.requirements?.Techs) | if (!parsed.requirements?.Techs) | ||||
parsed.phase = this.phaseList[0]; | parsed.phase = this.phaseList[0]; | ||||
else | else | ||||
{ | { | ||||
let highestPhaseIndex = 0; | let highestPhaseIndex = 0; | ||||
for (const tech of parsed.requirements.Techs.split(" ")) | for (const tech of parsed.requirements.Techs._string.split(" ")) | ||||
{ | { | ||||
if (tech[0] === "!") | if (tech[0] === "!") | ||||
continue; | continue; | ||||
const phaseIndex = this.phaseList.indexOf( | const phaseIndex = this.phaseList.indexOf( | ||||
this.TemplateLoader.isPhaseTech(tech) ? this.getActualPhase(tech) : | this.TemplateLoader.isPhaseTech(tech) ? this.getActualPhase(tech) : | ||||
this.getPhaseOfTechnology(tech, civCode)); | this.getPhaseOfTechnology(tech, civCode)); | ||||
if (phaseIndex > highestPhaseIndex) | if (phaseIndex > highestPhaseIndex) | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | for (let upgrade of upgradesInfo) | ||||
const data = GetTemplateDataHelper(this.TemplateLoader.loadEntityTemplate(upgrade.entity, civCode), null, this.TemplateLoader.auraData, g_ResourceData, this.modifiers[civCode] || {}); | const data = GetTemplateDataHelper(this.TemplateLoader.loadEntityTemplate(upgrade.entity, civCode), null, this.TemplateLoader.auraData, g_ResourceData, this.modifiers[civCode] || {}); | ||||
data.name.internal = upgrade.entity; | data.name.internal = upgrade.entity; | ||||
data.cost = upgrade.cost; | data.cost = upgrade.cost; | ||||
data.icon = upgrade.icon || data.icon; | data.icon = upgrade.icon || data.icon; | ||||
data.tooltip = upgrade.tooltip || data.tooltip; | data.tooltip = upgrade.tooltip || data.tooltip; | ||||
data.requirements = upgrade.requirements || data.requirements; | data.requirements = upgrade.requirements || data.requirements; | ||||
if (!data.requirements) | if (!data.requirements?.Techs) | ||||
data.phase = this.phaseList[0]; | data.phase = this.phaseList[0]; | ||||
else if (this.TemplateLoader.isPhaseTech(data.requirements.Techs)) | |||||
data.phase = this.getActualPhase(data.requirements.Techs); | |||||
else | else | ||||
data.phase = this.getPhaseOfTechnology(data.requirements.Techs, civCode); | { | ||||
let highestPhaseIndex = 0; | |||||
for (const tech of data.requirements.Techs._string.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; | |||||
} | |||||
data.phase = this.phaseList[highestPhaseIndex]; | |||||
} | |||||
newUpgrades.push(data); | newUpgrades.push(data); | ||||
} | } | ||||
return newUpgrades; | return newUpgrades; | ||||
} | } | ||||
/** | /** | ||||
* Determines and returns the phase in which a given technology can be | * Determines and returns the phase in which a given technology can be | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator