Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/structree/helper.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (!(templateName in g_AuraData)) | ||||
g_AuraData[templateName] = data; | g_AuraData[templateName] = data; | ||||
} | } | ||||
return g_AuraData[templateName]; | return g_AuraData[templateName]; | ||||
} | } | ||||
/** | /** | ||||
* Provided with an array containing basic information about possible | |||||
* upgrades, such as that generated by globalscript's GetTemplateDataHelper, | |||||
* this function loads the actual template data of the upgrades, overwrites | |||||
* certain values within, then passes an array containing the template data | |||||
elexis: Changes required: The two uses of this function look duplicate, can't you just pass a third… | |||||
* back to caller. | |||||
*/ | |||||
function getActualUpgradeData(upgradesInfo) | |||||
{ | |||||
let newUpgrades = []; | |||||
for (let upgrade of upgradesInfo) | |||||
Not Done Inline ActionsAs to is an object, it is passed by reference, the code modifies the properties of to. Hence it appears that the return is unneeded/misleading. elexis: As `to` is an object, it is passed by reference, the code modifies the properties of `to`. | |||||
{ | |||||
upgrade.entity = upgrade.entity.replace("{civ}", g_SelectedCiv); | |||||
bbUnsubmitted Not Done Inline ActionsIs this new upgrade.entity not used only once, so can be inlined? bb: Is this new upgrade.entity not used only once, so can be inlined? | |||||
s0600204AuthorUnsubmitted Not Done Inline ActionsSo as to avoid making the line overly long, I'd rather not. s0600204: So as to avoid making the line overly long, I'd rather not. | |||||
let data = GetTemplateDataHelper(loadTemplate(upgrade.entity), null, g_AuraData, g_ResourceData); | |||||
data.cost = upgrade.cost | |||||
data.icon = upgrade.icon || data.icon; | |||||
data.tooltip = upgrade.tooltip || data.tooltip; | |||||
data.requiredTechnology = upgrade.requiredTechnology || data.requiredTechnology; | |||||
newUpgrades.push(data); | |||||
} | |||||
return newUpgrades; | |||||
} | |||||
/** | |||||
* This is needed because getEntityCostTooltip in tooltip.js needs to get | * This is needed because getEntityCostTooltip in tooltip.js needs to get | ||||
* the template data of the different wallSet pieces. In the session this | * the template data of the different wallSet pieces. In the session this | ||||
* function does some caching, but here we do that in loadTemplate already. | * function does some caching, but here we do that in loadTemplate already. | ||||
*/ | */ | ||||
function GetTemplateData(templateName) | function GetTemplateData(templateName) | ||||
{ | { | ||||
var template = loadTemplate(templateName); | var template = loadTemplate(templateName); | ||||
return GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData); | return GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData); | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Changes required: The two uses of this function look duplicate, can't you just pass a third argument structure/ unit and absorb the code?