Index: binaries/data/mods/public/globalscripts/ModificationTemplates.js
===================================================================
--- binaries/data/mods/public/globalscripts/ModificationTemplates.js
+++ binaries/data/mods/public/globalscripts/ModificationTemplates.js
@@ -17,11 +17,6 @@
deepfreeze(this.templates);
}
-ModificationTemplates.prototype.GetNames = function()
-{
- return this.names;
-};
-
ModificationTemplates.prototype.Has = function(name)
{
return this.names.indexOf(name) != -1;
@@ -37,11 +32,35 @@
return this.templates;
};
+function ModificationsTemplates(path)
+{
+ this.templates = {};
+ for (const templateName of listFiles("simulation/templates/" + path, ".xml", true))
+ this.templates[templateName] =
+ GetTemplateDataHelper(Engine.GetTemplate(templateName), null, null));
+
+ deepfreeze(this.templates);
+};
+
+ModificationsTemplates.prototype.Has = function(path)
+{
+ return path in this.templates;
+};
+
+ModificationsTemplates.prototype.Get = function(path)
+{
+ return this.templates[path];
+};
+
+ModificationsTemplates.prototype.GetAll = function()
+{
+ return this.templates;
+};
function LoadModificationTemplates()
{
global.AuraTemplates = new ModificationTemplates("simulation/data/auras/");
- global.TechnologyTemplates = new ModificationTemplates("simulation/data/technologies/");
+ global.TechnologyTemplates = new ModificationsTemplates("technologies/");
}
/**
Index: binaries/data/mods/public/globalscripts/Templates.js
===================================================================
--- binaries/data/mods/public/globalscripts/Templates.js
+++ binaries/data/mods/public/globalscripts/Templates.js
@@ -490,6 +490,14 @@
"GainMultiplier": getEntityValue("Trader/GainMultiplier")
};
+ if (template.Technology)
+ ret.technology = {
+ "choice": template.Technology.Choice,
+ "ID": template.Technology.ID,
+ "modifications": template.Technology.Modifiers,
+ "supersedes": template.Technology.Supersedes
+ };
+
if (template.Treasure)
{
ret.treasure = {
@@ -547,48 +555,6 @@
}
/**
- * 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.
* @param {object} template - A valid template as obtained by loading the aura JSON file.
*/
Index: binaries/data/mods/public/simulation/components/Technology.js
===================================================================
--- /dev/null
+++ binaries/data/mods/public/simulation/components/Technology.js
@@ -0,0 +1,29 @@
+function Technology() {}
+
+Technology.prototype.Schema =
+ "Specifies the effects of a technology." +
+ "" +
+ "phase_town" +
+ "phase_village" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ ModificationsSchema +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "";
Index: binaries/data/mods/public/simulation/components/tests/test_Technology.js
===================================================================
--- /dev/null
+++ binaries/data/mods/public/simulation/components/tests/test_Technology.js
@@ -0,0 +1 @@
+Engine.LoadComponentScript("Technology.js");