mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
("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.
37 lines
902 B
JavaScript
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");
|