Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Templates.js
Show First 20 Lines • Show All 303 Lines • ▼ Show 20 Lines | if (template.TrainingRestrictions) | ||||
}; | }; | ||||
if (template.TrainingRestrictions.MatchLimit) | if (template.TrainingRestrictions.MatchLimit) | ||||
ret.trainingRestrictions.matchLimit = +template.TrainingRestrictions.MatchLimit; | ret.trainingRestrictions.matchLimit = +template.TrainingRestrictions.MatchLimit; | ||||
} | } | ||||
if (template.Cost) | if (template.Cost) | ||||
{ | { | ||||
ret.cost = {}; | ret.cost = {}; | ||||
if (template.Cost.Resources) | |||||
{ | |||||
ret.cost.resources = {} | |||||
for (let resCode in template.Cost.Resources) | for (let resCode in template.Cost.Resources) | ||||
ret.cost[resCode] = getEntityValue("Cost/Resources/" + resCode); | ret.cost.resources[resCode] = getEntityValue("Cost/Resources/" + resCode); | ||||
} | |||||
if (template.Cost.Population) | if (template.Cost.Population) | ||||
ret.cost.population = getEntityValue("Cost/Population"); | ret.cost.population = getEntityValue("Cost/Population"); | ||||
if (template.Cost.BuildTime) | if (template.Cost.BuildTime) | ||||
ret.cost.time = getEntityValue("Cost/BuildTime"); | ret.cost.time = getEntityValue("Cost/BuildTime"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | for (const res in template.Researcher.TechCostMultiplier) | ||||
ret.techCostMultiplier[res] = getEntityValue("Researcher/TechCostMultiplier/" + res); | ret.techCostMultiplier[res] = getEntityValue("Researcher/TechCostMultiplier/" + res); | ||||
} | } | ||||
if (template.Trader) | if (template.Trader) | ||||
ret.trader = { | ret.trader = { | ||||
"GainMultiplier": getEntityValue("Trader/GainMultiplier") | "GainMultiplier": getEntityValue("Trader/GainMultiplier") | ||||
}; | }; | ||||
if (template.Technology) | |||||
ret.technology = { | |||||
"choice": template.Technology.Choice, | |||||
"choiceRoot": template.Technology.ChoiceRoot, | |||||
"ID": template.Technology.ID, | |||||
"modifications": template.Technology.Modifiers, | |||||
"supersedes": template.Technology.Supersedes | |||||
}; | |||||
if (template.Treasure) | if (template.Treasure) | ||||
{ | { | ||||
ret.treasure = { | ret.treasure = { | ||||
"collectTime": getEntityValue("Treasure/CollectTime"), | "collectTime": getEntityValue("Treasure/CollectTime"), | ||||
"resources": {} | "resources": {} | ||||
}; | }; | ||||
for (let resource in template.Treasure.Resources) | for (let resource in template.Treasure.Resources) | ||||
ret.treasure.resources[resource] = getEntityValue("Treasure/Resources/" + resource); | ret.treasure.resources[resource] = getEntityValue("Treasure/Resources/" + resource); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | ret.wallPiece = { | ||||
"indent": +(template.WallPiece.Indent || 0), | "indent": +(template.WallPiece.Indent || 0), | ||||
"bend": +(template.WallPiece.Bend || 0) * Math.PI | "bend": +(template.WallPiece.Bend || 0) * Math.PI | ||||
}; | }; | ||||
return ret; | return ret; | ||||
} | } | ||||
/** | /** | ||||
* Get basic information about a technology template. | |||||
* @param {Object} template - A valid template as obtained by loading the tech JSON file. | |||||
* @param {string} civ - Civilization for which the tech requirements should be calculated. | |||||
*/ | |||||
function GetTechnologyBasicDataHelper(template, civ) | |||||
{ | |||||
return { | |||||
"name": { | |||||
"generic": template.genericName | |||||
}, | |||||
"icon": template.icon ? "technologies/" + template.icon : undefined, | |||||
"description": template.description, | |||||
"reqs": DeriveTechnologyRequirements(template, civ), | |||||
"modifications": template.modifications, | |||||
"affects": template.affects, | |||||
"replaces": template.replaces | |||||
}; | |||||
} | |||||
/** | |||||
* Get information about a technology template. | |||||
* @param {Object} template - A valid template as obtained by loading the tech JSON file. | |||||
* @param {string} civ - Civilization for which the specific name and tech requirements should be returned. | |||||
*/ | |||||
function GetTechnologyDataHelper(template, civ, resources) | |||||
{ | |||||
let ret = GetTechnologyBasicDataHelper(template, civ); | |||||
if (template.specificName) | |||||
ret.name.specific = template.specificName[civ] || template.specificName.generic; | |||||
ret.cost = { "time": template.researchTime ? +template.researchTime : 0 }; | |||||
for (let type of resources.GetCodes()) | |||||
ret.cost[type] = +(template.cost && template.cost[type] || 0); | |||||
ret.tooltip = template.tooltip; | |||||
ret.requirementsTooltip = template.requirementsTooltip || ""; | |||||
return ret; | |||||
} | |||||
/** | |||||
* Get information about an aura template. | * Get information about an aura template. | ||||
* @param {object} template - A valid template as obtained by loading the aura JSON file. | * @param {object} template - A valid template as obtained by loading the aura JSON file. | ||||
*/ | */ | ||||
function GetAuraDataHelper(template) | function GetAuraDataHelper(template) | ||||
{ | { | ||||
return { | return { | ||||
"name": { | "name": { | ||||
"generic": template.auraName, | "generic": template.auraName, | ||||
Show All 34 Lines |
Wildfire Games · Phabricator