some cleaning of petra code
This was SVN commit r15596.
This commit is contained in:
parent
2b0af756f6
commit
7dbbb4e419
@ -236,13 +236,16 @@ m.AttackPlan.prototype.getEnemyPlayer = function(gameState)
|
||||
return enemyWonder.owner();
|
||||
}
|
||||
|
||||
// then let's find our prefered target enemy, basically counting our enemies units.
|
||||
// then let's find our prefered target enemy, basically counting our enemies units
|
||||
// with priority to enemies with civ center
|
||||
var enemyCount = {};
|
||||
var enemyDefense = {};
|
||||
var enemyCivCentre = {};
|
||||
for (var i = 1; i < gameState.sharedScript.playersData.length; ++i)
|
||||
{
|
||||
enemyCount[i] = 0;
|
||||
enemyDefense[i] = 0;
|
||||
enemyCivCentre[i] = false;
|
||||
}
|
||||
gameState.getEntities().forEach(function(ent) {
|
||||
if (gameState.isEntityEnemy(ent) && ent.owner() !== 0)
|
||||
@ -250,6 +253,8 @@ m.AttackPlan.prototype.getEnemyPlayer = function(gameState)
|
||||
enemyCount[ent.owner()]++;
|
||||
if (ent.hasClass("Tower") || ent.hasClass("Fortress"))
|
||||
enemyDefense[ent.owner()]++;
|
||||
if (ent.hasClass("CivCentre"))
|
||||
enemyCivCentre[ent.owner()] = true;
|
||||
}
|
||||
});
|
||||
var max = 0;
|
||||
@ -257,10 +262,13 @@ m.AttackPlan.prototype.getEnemyPlayer = function(gameState)
|
||||
{
|
||||
if (this.type === "Rush" && enemyDefense[i] > 6) // No rush if enemy too well defended (iberians)
|
||||
continue;
|
||||
if (enemyCount[i] > max)
|
||||
var count = enemyCount[i];
|
||||
if (enemyCivCentre[i])
|
||||
count += 500;
|
||||
if (count > max)
|
||||
{
|
||||
enemyPlayer = +i;
|
||||
max = enemyCount[i];
|
||||
max = count;
|
||||
}
|
||||
}
|
||||
return enemyPlayer;
|
||||
@ -996,7 +1004,7 @@ m.AttackPlan.prototype.StartAttack = function(gameState)
|
||||
else
|
||||
{
|
||||
gameState.ai.gameFinished = true;
|
||||
m.debug ("I do not have any target. So I'll just assume I won the game.");
|
||||
API3.warn("I do not have any target. So I'll just assume I won the game.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -115,26 +115,5 @@ m.DefenseArmy.prototype.update = function (gameState)
|
||||
return breakaways;
|
||||
};
|
||||
|
||||
m.DefenseArmy.prototype.debug = function (gameState)
|
||||
{
|
||||
m.debug(" ");
|
||||
m.debug ("Army " + this.ID)
|
||||
// m.debug ("Entities " + this.foeEntities.length);
|
||||
// m.debug ("Strength " + this.foeStrength);
|
||||
// debug (gameState.getEntityById(ent)._templateName + ", ID " + ent);
|
||||
//debug ("Defenders " + this.ownEntities.length);
|
||||
for (var ent of this.foeEntities)
|
||||
{
|
||||
if (gameState.getEntityById(ent) !== undefined)
|
||||
{
|
||||
warn(gameState.getEntityById(ent)._templateName + ", ID " + ent);
|
||||
Engine.PostCommand(PlayerID,{"type": "set-shading-color", "entities": [ent], "rgb": [0.5,0,0]});
|
||||
}
|
||||
else
|
||||
warn("ent " + ent);
|
||||
}
|
||||
m.debug ("");
|
||||
};
|
||||
|
||||
return m;
|
||||
}(PETRA);
|
||||
|
@ -27,7 +27,7 @@ m.GarrisonManager.prototype.update = function(gameState, queues)
|
||||
for (var entId of this.holders[id])
|
||||
{
|
||||
var ent = gameState.getEntityById(entId);
|
||||
if (ent && ent.getMetadata(PlayerID, "garrisonHolder") === id)
|
||||
if (ent && ent.getMetadata(PlayerID, "garrisonHolder") == +id)
|
||||
this.leaveGarrison(ent);
|
||||
}
|
||||
this.holders[id] = undefined;
|
||||
|
@ -849,15 +849,6 @@ m.HQ.prototype.findEconomicCCLocation = function(gameState, template, resource,
|
||||
|
||||
Engine.ProfileStop();
|
||||
|
||||
/* if (m.DebugEnabled())
|
||||
{
|
||||
gameState.sharedScript.CCResourceMaps["wood"].dumpIm("woodMap.png", 300);
|
||||
gameState.sharedScript.CCResourceMaps["stone"].dumpIm("stoneMap.png", 300);
|
||||
gameState.sharedScript.CCResourceMaps["metal"].dumpIm("metalMap.png", 300);
|
||||
locateMap.dumpIm("cc_placement_base_" + best[1] + ".png",300);
|
||||
obstructions.dumpIm("cc_placement_base_" + best[1] + "_obs.png", 20);
|
||||
} */
|
||||
|
||||
var cut = 60;
|
||||
if (fromStrategic) // be less restrictive
|
||||
cut = 30;
|
||||
|
Loading…
Reference in New Issue
Block a user