3 Identity.prototype.Schema =
4 "<a:help>Specifies various names and values associated with the unit type, typically for GUI display to users.</a:help>" +
7 "<GenericName>Athenian Hoplite</GenericName>" +
8 "<SpecificName>Hoplī́tēs Athēnaïkós</SpecificName>" +
9 "<Icon>units/athen_infantry_spearman.png</Icon>" +
11 "<element name='Civ' a:help='Civilisation that this unit is primarily associated with, typically a 4-letter code. Choices include: gaia (world objects), athen (Athenians), brit (Britons), cart (Carthaginians), gaul (Gauls), iber (Iberians), mace (Macedonians), pers (Persians), ptol (Ptolemies), rome (Romans), sele (Seleucids), spart (Spartans)'>" +
15 "<element name='Lang' a:help='Unit language for voices'>" +
20 "<element name='Gender' a:help='Unit gender for voices. Choices includes male or female.'>" +
24 "<element name='GenericName' a:help='Generic English-language name for this class of unit'>" +
28 "<element name='SpecificName' a:help='Specific native-language name for this unit type'>" +
33 "<element name='SelectionGroupName' a:help='Name used to group ranked entities'>" +
38 "<element name='Tooltip'>" +
43 "<element name='Rollover'>" +
48 "<element name='History'>" +
53 "<element name='Rank'>" +
55 "<value>Basic</value>" +
56 "<value>Advanced</value>" +
57 "<value>Elite</value>" +
62 "<element name='Classes' a:help='Optional list of space-separated classes applying to this entity. Choices include: Unit, Infantry, Melee, Cavalry, Ranged, Mechanical, Ship, Siege, Champion, Hero, Elephant, Chariot, Mercenary, Spear, Sword, Bow, Javelin, Sling, Support, Animal, Domestic, Organic, Structure, Civic, CivCentre, Economic, Defensive, Gates, Wall, BarterMarket, Village, Town, City, ConquestCritical, Worker, Female, Healer, Slave, CitizenSoldier, Trade, Market, NavalMarket, Warship, SeaCreature, ForestPlant, DropsiteFood, DropsiteWood, DropsiteStone, DropsiteMetal, GarrisonTower, GarrisonFortress'>" +
63 "<attribute name='datatype'>" +
64 "<value>tokens</value>" +
70 "<element name='VisibleClasses' a:help='Optional list of space-separated classes applying to this entity. These classes will also be visible in various GUI elements, if the classes need spaces. Underscores will be replaced with spaces.'>" +
71 "<attribute name='datatype'>" +
72 "<value>tokens</value>" +
78 "<element name='Formations' a:help='Optional list of space-separated formations this unit is allowed to use. Choices include: Scatter, Box, ColumnClosed, LineClosed, ColumnOpen, LineOpen, Flank, Skirmish, Wedge, Testudo, Phalanx, Syntagma, BattleLine'>" +
79 "<attribute name='datatype'>" +
80 "<value>tokens</value>" +
86 "<element name='Icon'>" +
91 "<element name='RequiredTechnology' a:help='Optional name of a technology which must be researched before the entity can be produced'>" +
97 Identity.prototype.Init = function()
100 this.classesList = GetIdentityClasses(this.template);
101 this.visibleClassesList = GetVisibleIdentityClasses(this.template);
104 Identity.prototype.Deserialize = function ()
109 Identity.prototype.Serialize = null; // we have no dynamic state to save
111 Identity.prototype.GetCiv = function()
113 return this.template.Civ;
116 Identity.prototype.GetLang = function()
118 return this.template.Lang || "greek"; // ugly default
121 Identity.prototype.GetGender = function()
123 return this.template.Gender || "male"; // ugly default
126 Identity.prototype.GetRank = function()
128 return (this.template.Rank || "");
131 Identity.prototype.GetClassesList = function()
133 return this.classesList;
136 Identity.prototype.GetVisibleClassesList = function()
138 return this.visibleClassesList;
141 Identity.prototype.HasClass = function(name)
143 return this.GetClassesList().indexOf(name) != -1;
146 Identity.prototype.GetFormationsList = function()
148 if (this.template.Formations && "_string" in this.template.Formations)
150 var string = this.template.Formations._string;
151 return string.split(/\s+/);
156 Identity.prototype.CanUseFormation = function(template)
158 return this.GetFormationsList().indexOf(template) != -1;
161 Identity.prototype.GetSelectionGroupName = function()
163 return (this.template.SelectionGroupName || "");
166 Identity.prototype.GetGenericName = function()
168 return this.template.GenericName;
171 Engine.RegisterComponentType(IID_Identity, "Identity", Identity);