Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/queueplanTraining.js
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | this.trainers.sort(function(a, b) { | ||||
bb++; | bb++; | ||||
} | } | ||||
return aa - bb; | return aa - bb; | ||||
}); | }); | ||||
} | } | ||||
if (this.metadata && this.metadata.base !== undefined && this.metadata.base === 0) | if (this.metadata && this.metadata.base !== undefined && this.metadata.base === 0) | ||||
this.metadata.base = this.trainers[0].getMetadata(PlayerID, "base"); | this.metadata.base = this.trainers[0].getMetadata(PlayerID, "base"); | ||||
this.trainers[0].train(gameState.getPlayerCiv(), this.type, this.number, this.metadata, this.promotedTypes(gameState)); | this.trainers[0].train(gameState.getPlayerCiv(), this.type, this.number, this.metadata); | ||||
this.onStart(gameState); | this.onStart(gameState); | ||||
}; | }; | ||||
PETRA.TrainingPlan.prototype.addItem = function(amount = 1) | PETRA.TrainingPlan.prototype.addItem = function(amount = 1) | ||||
{ | { | ||||
this.number += amount; | this.number += amount; | ||||
}; | }; | ||||
/** Find the promoted types corresponding to this.type */ | |||||
PETRA.TrainingPlan.prototype.promotedTypes = function(gameState) | |||||
{ | |||||
let types = []; | |||||
let promotion = this.template.promotion(); | |||||
let previous; | |||||
let template; | |||||
while (promotion) | |||||
{ | |||||
types.push(promotion); | |||||
previous = promotion; | |||||
template = gameState.getTemplate(promotion); | |||||
if (!template) | |||||
{ | |||||
if (gameState.ai.Config.debug > 0) | |||||
API3.warn(" promotion template " + promotion + " is not found"); | |||||
promotion = undefined; | |||||
break; | |||||
} | |||||
promotion = template.promotion(); | |||||
if (previous === promotion) | |||||
{ | |||||
if (gameState.ai.Config.debug > 0) | |||||
API3.warn(" unit " + promotion + " is its own promoted unit"); | |||||
promotion = undefined; | |||||
} | |||||
} | |||||
return types; | |||||
}; | |||||
PETRA.TrainingPlan.prototype.Serialize = function() | PETRA.TrainingPlan.prototype.Serialize = function() | ||||
{ | { | ||||
return { | return { | ||||
"category": this.category, | "category": this.category, | ||||
"type": this.type, | "type": this.type, | ||||
"ID": this.ID, | "ID": this.ID, | ||||
"metadata": this.metadata, | "metadata": this.metadata, | ||||
"cost": this.cost.Serialize(), | "cost": this.cost.Serialize(), | ||||
Show All 13 Lines |
Wildfire Games · Phabricator