Add AI safety guard. I had a game with an undefined template, but that shouldn't happen at that point.

This was SVN commit r16535.
This commit is contained in:
sanderd17
2015-04-13 10:10:38 +00:00
parent b6bcfdbb2e
commit 71fb9ef162
@@ -124,11 +124,20 @@ m.TrainingPlan.prototype.promotedTypes = function(gameState)
var types = [];
var promotion = this.template.promotion();
var previous;
var template;
while (promotion)
{
types.push(promotion);
previous = promotion;
promotion = gameState.getTemplate(promotion).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)