Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/common/TemplateParser.js
Show All 37 Lines | getAura(auraName) | ||||
parsed.affectsTeam = this.AuraTeamIndicators.some(indicator => affectedPlayers.includes(indicator)); | parsed.affectsTeam = this.AuraTeamIndicators.some(indicator => affectedPlayers.includes(indicator)); | ||||
parsed.affectsSelf = this.AuraSelfIndicators.some(indicator => affectedPlayers.includes(indicator)); | parsed.affectsSelf = this.AuraSelfIndicators.some(indicator => affectedPlayers.includes(indicator)); | ||||
this.auras[auraName] = parsed; | this.auras[auraName] = parsed; | ||||
return this.auras[auraName]; | return this.auras[auraName]; | ||||
} | } | ||||
/** | /** | ||||
* Replaces names of entities that have been promoted by auto-researched technology. | |||||
* | |||||
* In the Simulation, this is done by `ProductionQueue::CalculateEntitiesMap()` | |||||
* | |||||
* @param {array} productionArray | |||||
* @param {string} civCode | |||||
*/ | |||||
parseAutoPromotions (productionArray, civCode) | |||||
Lint: space-before-function-paren: Unexpected space before function parentheses. | |||||
{ | |||||
for (const idx in productionArray) | |||||
{ | |||||
const templateName = productionArray[idx]; | |||||
const entity = this.getEntity(templateName, civCode); | |||||
if (!entity.promotion || entity.promotion.requiredXp > 0) | |||||
continue; | |||||
productionArray.splice(idx, 1, entity.promotion.entity); | |||||
} | |||||
} | |||||
/** | |||||
* Load and parse a structure, unit, resource, etc from its entity template file. | * Load and parse a structure, unit, resource, etc from its entity template file. | ||||
* | * | ||||
* @param {string} templateName | * @param {string} templateName | ||||
* @param {string} civCode | * @param {string} civCode | ||||
* @return {(object|null)} Sanitized object about the requested template or null if entity template doesn't exist. | * @return {(object|null)} Sanitized object about the requested template or null if entity template doesn't exist. | ||||
*/ | */ | ||||
getEntity(templateName, civCode) | getEntity(templateName, civCode) | ||||
{ | { | ||||
if (!(civCode in this.entities)) | if (!(civCode in this.entities)) | ||||
this.entities[civCode] = {}; | this.entities[civCode] = {}; | ||||
else if (templateName in this.entities[civCode]) | else if (templateName in this.entities[civCode]) | ||||
return this.entities[civCode][templateName]; | return this.entities[civCode][templateName]; | ||||
if (!Engine.TemplateExists(templateName)) | if (!Engine.TemplateExists(templateName)) | ||||
return null; | return null; | ||||
let template = this.TemplateLoader.loadEntityTemplate(templateName, civCode); | let template = this.TemplateLoader.loadEntityTemplate(templateName, civCode); | ||||
let parsed = GetTemplateDataHelper(template, null, this.TemplateLoader.auraData, this.modifiers[civCode] || {}); | let parsed = GetTemplateDataHelper(template, null, this.TemplateLoader.auraData, this.modifiers[civCode] || {}); | ||||
parsed.name.internal = templateName; | parsed.name.internal = templateName; | ||||
parsed.history = template.Identity.History; | parsed.history = template.Identity.History; | ||||
parsed.production = this.TemplateLoader.deriveProductionQueue(template, civCode); | parsed.production = this.TemplateLoader.deriveProductionQueue(template, civCode); | ||||
this.parseAutoPromotions(parsed.production.units, 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.requiredTechnology) | if (!parsed.requiredTechnology) | ||||
parsed.phase = this.phaseList[0]; | parsed.phase = this.phaseList[0]; | ||||
else if (this.TemplateLoader.isPhaseTech(parsed.requiredTechnology)) | else if (this.TemplateLoader.isPhaseTech(parsed.requiredTechnology)) | ||||
parsed.phase = this.getActualPhase(parsed.requiredTechnology); | parsed.phase = this.getActualPhase(parsed.requiredTechnology); | ||||
else | else | ||||
parsed.phase = this.getPhaseOfTechnology(parsed.requiredTechnology, civCode); | parsed.phase = this.getPhaseOfTechnology(parsed.requiredTechnology, civCode); | ||||
if (template.Identity.Rank) | if (template.Identity.Rank) | ||||
parsed.promotion = { | { | ||||
"current_rank": template.Identity.Rank, | if (!template.Promotion) | ||||
"entity": template.Promotion && template.Promotion.Entity | parsed.promotion = {}; | ||||
}; | parsed.promotion.current_rank = template.Identity.Rank; | ||||
} | |||||
if (template.ResourceSupply) | if (template.ResourceSupply) | ||||
parsed.supply = { | parsed.supply = { | ||||
"type": template.ResourceSupply.Type.split("."), | "type": template.ResourceSupply.Type.split("."), | ||||
"amount": template.ResourceSupply.Max, | "amount": template.ResourceSupply.Max, | ||||
}; | }; | ||||
if (parsed.upgrades) | if (parsed.upgrades) | ||||
▲ Show 20 Lines • Show All 301 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Unexpected space before function parentheses.