petra: some more adjustements for lastManStanding games

This was SVN commit r18955.
This commit is contained in:
mimo 2016-11-16 19:35:12 +00:00
parent 65fae7f965
commit 6efd5ea505
4 changed files with 22 additions and 4 deletions

View file

@ -31,18 +31,19 @@ m.DiplomacyManager.prototype.tributes = function(gameState)
{
if (i === PlayerID || !gameState.isPlayerAlly(i) || gameState.ai.HQ.attackManager.defeated[i])
continue;
let donor = gameState.getAlliedVictory() || gameState.getEntities(i).length < gameState.getOwnEntities().length;
let allyResources = gameState.sharedScript.playersData[i].resourceCounts;
let allyPop = gameState.sharedScript.playersData[i].popCount;
let tribute = {};
let toSend = false;
for (let res in allyResources)
{
if (availableResources[res] > 200 && allyResources[res] < 0.2 * availableResources[res])
if (donor && availableResources[res] > 200 && allyResources[res] < 0.2 * availableResources[res])
{
tribute[res] = Math.floor(0.3*availableResources[res] - allyResources[res]);
toSend = true;
}
else if (allyPop < Math.min(30, 0.5*gameState.getPopulation()) && totalResources[res] > 500 && allyResources[res] < 100)
else if (donor && allyPop < Math.min(30, 0.5*gameState.getPopulation()) && totalResources[res] > 500 && allyResources[res] < 100)
{
tribute[res] = 100;
toSend = true;

View file

@ -1155,6 +1155,9 @@ m.HQ.prototype.findDefensiveLocation = function(gameState, template)
{
enemyStructures = gameState.getNeutralStructures().filter(API3.Filters.not(API3.Filters.byOwner(0))).
filter(API3.Filters.byClassesOr(["CivCentre", "Fortress", "Tower"]));
if (!enemyStructures.hasEntities() && !gameState.getAlliedVictory())
enemyStructures = gameState.getAllyStructures().filter(API3.Filters.not(API3.Filters.byOwner(PlayerID))).
filter(API3.Filters.byClassesOr(["CivCentre", "Fortress", "Tower"]));
if (!enemyStructures.hasEntities())
return undefined;
}

View file

@ -179,6 +179,7 @@ m.createBorderMap = function(gameState)
/** map of our frontier : 2 means narrow border, 1 means large border */
m.createFrontierMap = function(gameState)
{
let alliedVictory = gameState.getAlliedVictory();
let territoryMap = gameState.ai.HQ.territoryMap;
let borderMap = gameState.ai.HQ.borderMap;
const around = [ [-0.7,0.7], [0,1], [0.7,0.7], [1,0], [0.7,-0.7], [0,-1], [-0.7,-0.7], [-1,0] ];
@ -204,7 +205,9 @@ m.createFrontierMap = function(gameState)
continue;
if (borderMap.map[jx+width*jz] > 1)
continue;
if (!gameState.isPlayerAlly(territoryMap.getOwnerIndex(jx+width*jz)))
let territoryOwner = territoryMap.getOwnerIndex(jx+width*jz);
let safe = (alliedVictory && gameState.isPlayerAlly(territoryOwner)) || territoryOwner === PlayerID;
if (!safe)
{
map.map[j] = 2;
break;
@ -217,7 +220,9 @@ m.createFrontierMap = function(gameState)
continue;
if (borderMap.map[jx+width*jz] > 1)
continue;
if (!gameState.isPlayerAlly(territoryMap.getOwnerIndex(jx+width*jz)))
territoryOwner = territoryMap.getOwnerIndex(jx+width*jz);
safe = (alliedVictory && gameState.isPlayerAlly(territoryOwner)) || territoryOwner === PlayerID;
if (!safe)
map.map[j] = 1;
}
}

View file

@ -372,6 +372,15 @@ m.TradeManager.prototype.checkEvents = function(gameState, events)
return true;
}
// or if diplomacy changed
if (events.DiplomacyChanged.length)
{
this.routeProspection = true;
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_market");
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_dock");
return true;
}
return false;
};