forked from mirrors/0ad
[Petra/AI] Handle permadeaths for heroes hotfix
caused bya79a47effeandde3ed2cd19petra will be blocked by not being able to train hero again as she does not do rotations. add check for matchlimits reached for permadeaths more propper solution to handle training with numbers greater than 1 will be needed in the future. Differential revision: D3559 Accepted by: @Freagarach This was SVN commit r24897.
This commit is contained in:
@@ -52,6 +52,12 @@ m.Template = m.Class({
|
||||
|
||||
"civ": function() { return this.get("Identity/Civ"); },
|
||||
|
||||
"matchLimit": function() {
|
||||
if (!this.get("TrainingRestrictions"))
|
||||
return undefined;
|
||||
return this.get("TrainingRestrictions/MatchLimit");
|
||||
},
|
||||
|
||||
"classes": function() {
|
||||
let template = this.get("Identity");
|
||||
if (!template)
|
||||
|
||||
@@ -718,6 +718,7 @@ m.GameState.prototype.findTrainableUnits = function(classes, anticlasses)
|
||||
let ret = [];
|
||||
let limits = this.getEntityLimits();
|
||||
let current = this.getEntityCounts();
|
||||
let matchCounts = this.getEntityMatchCounts();
|
||||
for (let trainable of allTrainable)
|
||||
{
|
||||
if (this.isTemplateDisabled(trainable))
|
||||
@@ -725,6 +726,9 @@ m.GameState.prototype.findTrainableUnits = function(classes, anticlasses)
|
||||
let template = this.getTemplate(trainable);
|
||||
if (!template || !template.available(this))
|
||||
continue;
|
||||
let limit = template.matchLimit();
|
||||
if (matchCounts && limit && matchCounts[trainable] >= limit)
|
||||
continue;
|
||||
if (classes.some(c => !template.hasClass(c)))
|
||||
continue;
|
||||
if (anticlasses.some(c => template.hasClass(c)))
|
||||
@@ -888,6 +892,11 @@ m.GameState.prototype.getEntityLimits = function()
|
||||
return this.playerData.entityLimits;
|
||||
};
|
||||
|
||||
m.GameState.prototype.getEntityMatchCounts = function()
|
||||
{
|
||||
return this.playerData.matchEntityCounts;
|
||||
};
|
||||
|
||||
m.GameState.prototype.getEntityCounts = function()
|
||||
{
|
||||
return this.playerData.entityCounts;
|
||||
|
||||
Reference in New Issue
Block a user