1
0
forked from 0ad/0ad

fix the AIs broken after b55b6a9cf1

This was SVN commit r15204.
This commit is contained in:
mimo 2014-05-22 20:40:14 +00:00
parent 27104a4f33
commit 84b53933ff
2 changed files with 20 additions and 2 deletions

View File

@ -51,9 +51,9 @@ m.Template = m.Class({
},
classes: function() {
if (!this.get("Identity") || !this.get("Identity/Classes") || !this.get("Identity/Classes/_string"))
if (!this.get("Identity"))
return undefined;
return this.get("Identity/Classes/_string").split(/\s+/);
return m.GetIdentityClasses(this._template.Identity);
},
requiredTech: function() {

View File

@ -85,6 +85,24 @@ m.PickRandom = function(list){
return list[Math.floor(Math.random()*list.length)];
}
/**
* Gets an array of all classes for this identity template
* (temporarily duplicated from helpers/templates.js)
*/
m.GetIdentityClasses = function(template)
{
var classList = [];
if (template.Classes && template.Classes._string)
classList = classList.concat(template.Classes._string.split(/\s+/));
if (template.VisibleClasses && template.VisibleClasses._string)
classList = classList.concat(template.VisibleClasses._string.split(/\s+/));
if (template.Rank)
classList = classList.concat(template.Rank);
return classList;
}
return m;
}(API3);