Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Upgrade.js
Show All 34 Lines | "<element>" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
"<choice>" + | "<choice>" + | ||||
Resources.BuildSchema("nonNegativeInteger") + | Resources.BuildSchema("nonNegativeInteger") + | ||||
"</choice>" + | "</choice>" + | ||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='RequiredTechnology' a:help='Define what technology is required for this upgrade'>" + | RequirementsHelper.BuildSchema() + | ||||
"<choice>" + | |||||
"<text/>" + | |||||
"<empty/>" + | |||||
"</choice>" + | |||||
"</element>" + | |||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='CheckPlacementRestrictions' a:help='Upgrading will check for placement restrictions (nb:GUI only)'><empty/></element>" + | "<element name='CheckPlacementRestrictions' a:help='Upgrading will check for placement restrictions (nb:GUI only)'><empty/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</oneOrMore>"; | "</oneOrMore>"; | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | if (choice.Time) | ||||
cost.time = this.GetUpgradeTime(templateName); | cost.time = this.GetUpgradeTime(templateName); | ||||
let hasCost = choice.Cost || choice.Time; | let hasCost = choice.Cost || choice.Time; | ||||
ret.push({ | ret.push({ | ||||
"entity": templateName, | "entity": templateName, | ||||
"icon": choice.Icon || undefined, | "icon": choice.Icon || undefined, | ||||
"cost": hasCost ? cost : undefined, | "cost": hasCost ? cost : undefined, | ||||
"tooltip": choice.Tooltip || undefined, | "tooltip": choice.Tooltip || undefined, | ||||
"requiredTechnology": this.GetRequiredTechnology(option), | "requirements": this.GetRequirements(option), | ||||
}); | }); | ||||
} | } | ||||
return ret; | return ret; | ||||
}; | }; | ||||
Upgrade.prototype.CancelTimer = function() | Upgrade.prototype.CancelTimer = function() | ||||
{ | { | ||||
Show All 19 Lines | |||||
{ | { | ||||
if (!this.upgradeTemplates[template]) | if (!this.upgradeTemplates[template]) | ||||
return undefined; | return undefined; | ||||
// is undefined by default so use X in Y | // is undefined by default so use X in Y | ||||
return "CheckPlacementRestrictions" in this.template[this.upgradeTemplates[template]]; | return "CheckPlacementRestrictions" in this.template[this.upgradeTemplates[template]]; | ||||
}; | }; | ||||
Upgrade.prototype.GetRequiredTechnology = function(templateArg) | Upgrade.prototype.GetRequirements = function(templateArg) | ||||
{ | { | ||||
let choice = this.upgradeTemplates[templateArg] || templateArg; | let choice = this.upgradeTemplates[templateArg] || templateArg; | ||||
if (this.template[choice].RequiredTechnology) | if (this.template[choice].Requirements) | ||||
return this.template[choice].RequiredTechnology; | return this.template[choice].Requirements; | ||||
if (!("RequiredTechnology" in this.template[choice])) | if (!("Requirements" in this.template[choice])) | ||||
return undefined; | return undefined; | ||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | ||||
let entType = this.template[choice].Entity; | let entType = this.template[choice].Entity; | ||||
if (cmpIdentity) | if (cmpIdentity) | ||||
entType = entType.replace(/\{civ\}/g, cmpIdentity.GetCiv()); | entType = entType.replace(/\{civ\}/g, cmpIdentity.GetCiv()); | ||||
let template = cmpTemplateManager.GetTemplate(entType); | let template = cmpTemplateManager.GetTemplate(entType); | ||||
return template.Identity.RequiredTechnology || undefined; | return template.Identity.Requirements || undefined; | ||||
}; | }; | ||||
Upgrade.prototype.GetResourceCosts = function(template) | Upgrade.prototype.GetResourceCosts = function(template) | ||||
{ | { | ||||
if (!this.upgradeTemplates[template]) | if (!this.upgradeTemplates[template]) | ||||
return undefined; | return undefined; | ||||
if (this.IsUpgrading() && template == this.GetUpgradingTo()) | if (this.IsUpgrading() && template == this.GetUpgradingTo()) | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator