Class: TemplateLoader

TemplateLoader()

This class handles the loading of files.

Constructor

new TemplateLoader()

Source:

Members

auraData

Raw Data Caches.
Source:

AuraPath

Paths to certain files. It might be nice if we could get these from somewhere, instead of having them hardcoded here.
Source:

AuraTranslateKeys

Keys of template values that are to be translated on load.
Source:

autoResearchTechList

Partly-composed data.
Source:

PlayerTemplatePrefix

Expected prefix for player templates, and the file to use if a civ doesn't have its own.
Source:

Methods

buildPlayerTemplateName()

If a civ doesn't have its own civ-specific player template, this returns the name of the generic player template.
Source:
See:
  • simulation/helpers/Player.js GetPlayerTemplateName() (Which can't be combined with this due to different Engine contexts)

findAllAutoResearchedTechs() → {array}

Crudely iterates through every tech JSON file and identifies those that are auto-researched.
Source:
Returns:
List of techs that are researched automatically
Type
array

getVariantBaseAndType()

A template may be a variant of another template, eg. `*_house`, `*_trireme`, or a promotion. This method returns an array containing: [0] - The template's basename [1] - The variant type [2] - Further information (if available) e.g.: units/athen/infantry_swordsman_e -> ["units/athen/infantry_swordsman_b", TemplateVariant.promotion, "elite"] units/brit/support_female_citizen_house -> ["units/brit/support_female_citizen", TemplateVariant.unlockedByTechnology, "unlock_female_house"]
Source:

loadAuraTemplate(templateName) → {Object}

Loads raw aura template. Loads from local cache if available, else from file system.
Parameters:
Name Type Description
templateName string
Source:
Returns:
Object containing raw template data.
Type
Object

loadEntityTemplate(templateName, civCode) → {Object}

Loads raw entity template. Loads from local cache if data present, else from file system.
Parameters:
Name Type Description
templateName string
civCode string
Source:
Returns:
Object containing raw template data.
Type
Object

loadPlayerTemplate(civCode) → {Object}

Loads raw player template. Loads from local cache if data present, else from file system. If a civ doesn't have their own civ-specific template, then we return the generic template.
Parameters:
Name Type Description
civCode string
Source:
Returns:
Object containing raw template data.
Type
Object

loadTechnologyPairTemplate(templateName, civCode) → {Object}

Parameters:
Name Type Description
templateName string
civCode string
Source:
Returns:
Contains a list and the requirements of the techs in the pair
Type
Object

loadTechnologyTemplate(templateName) → {Object}

Loads raw technology template. Loads from local cache if available, else from file system.
Parameters:
Name Type Description
templateName string
Source:
Returns:
Object containing raw template data.
Type
Object