0ad/binaries/data/mods/public/gui/reference/common/TemplateVariant.js
s0600204 f57ac432e8 Show correct cost/phase of template-variants in structree whilst maintaining correct build lists in viewer
("Variant" in this case means a template that is functionally the same
as its
base template - but is a different promotion level, requires a
technology to
unlock (that the base template doesn't), is an upgrade of its base, or
is a
trainable version.)

Should fix concern raised on b2842e8021.

Accepted by: Angen
Differential Revision: https://code.wildfiregames.com/D3347
This was SVN commit r25260.
2021-04-14 20:05:26 +00:00

37 lines
902 B
JavaScript

/**
* Enum-type class that defines various template variant types.
*/
class TemplateVariant
{
/**
* @param passthru Signifies if we should pass though to the base template when generating build lists.
*/
constructor(name, passthru=true)
{
this.name = name;
this.passthru = passthru;
TemplateVariant[name] = this;
}
static registerType(name, passthru=true)
{
TemplateVariant[name] = new TemplateVariant(name, passthru);
}
toString()
{
return this.constructor.name + "." + this.name;
}
}
/**
* Registered Template Variants.
* New variants add themselves as static properties to the main class.
*/
TemplateVariant.registerType("base");
TemplateVariant.registerType("unknown");
TemplateVariant.registerType("upgrade", false);
TemplateVariant.registerType("promotion", false);
TemplateVariant.registerType("unlockedByTechnology");
TemplateVariant.registerType("trainable");