petra: continuation of adaptation to capture
This was SVN commit r16578.
This commit is contained in:
parent
4d1dee171e
commit
632c8bd17e
@ -178,6 +178,7 @@ m.BaseManager.prototype.anchorLost = function (gameState, ent)
|
||||
bestbase.assignEntity(gameState, entity);
|
||||
for (let entity of this.buildings.values())
|
||||
bestbase.assignEntity(gameState, entity);
|
||||
gameState.ai.HQ.updateTerritories(gameState);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -195,6 +195,8 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
||||
else if (ent.hasTerritoryInfluence())
|
||||
this.updateTerritories(gameState);
|
||||
}
|
||||
else // TODO should be reassigned later if a better base is captured
|
||||
m.getBestBase(ent, gameState).assignEntity(gameState, ent);
|
||||
}
|
||||
|
||||
let captureEvents = events["OwnershipChanged"];
|
||||
@ -216,8 +218,15 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
||||
newbase.init(gameState, "captured");
|
||||
newbase.setAnchor(gameState, ent);
|
||||
this.baseManagers.push(newbase);
|
||||
this.updateTerritories(gameState);
|
||||
newbase.assignEntity(gameState, ent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO affect it to the nearest base
|
||||
if (ent.hasTerritoryInfluence())
|
||||
this.updateTerritories(gameState);
|
||||
}
|
||||
}
|
||||
|
||||
// deal with the different rally points of training units: the rally point is set when the training starts
|
||||
|
@ -322,14 +322,14 @@ m.TradeManager.prototype.checkEvents = function(gameState, events)
|
||||
}
|
||||
}
|
||||
|
||||
// if one market is destroyed or built (i.e. its foundation is destroyed), we should look for a better route
|
||||
// if one market is destroyed, we should look for a better route
|
||||
let destroyEvents = events["Destroy"];
|
||||
for (let evt of destroyEvents)
|
||||
{
|
||||
if (!evt.entityObj)
|
||||
continue;
|
||||
let ent = evt.entityObj;
|
||||
if (!ent || !ent.hasClass("Market") || !gameState.isPlayerAlly(ent.owner()))
|
||||
if (!ent || ent.foundationProgress() !== undefined || !ent.hasClass("Market") || !gameState.isPlayerAlly(ent.owner()))
|
||||
continue;
|
||||
this.routeProspection = true;
|
||||
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_market");
|
||||
@ -337,14 +337,28 @@ m.TradeManager.prototype.checkEvents = function(gameState, events)
|
||||
return true;
|
||||
}
|
||||
|
||||
// same thing for captured markets
|
||||
// same thing if one market is built
|
||||
let createEvents = events["Create"];
|
||||
for (let evt of createEvents)
|
||||
{
|
||||
let ent = gameState.getEntityById(evt.entity);
|
||||
if (!ent || ent.foundationProgress() !== undefined || !ent.hasClass("Market") || !gameState.isPlayerAlly(ent.owner()))
|
||||
continue;
|
||||
this.routeProspection = true;
|
||||
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_market");
|
||||
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_dock");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// and same thing for captured markets
|
||||
let capturedEvents = events["OwnershipChanged"];
|
||||
for (let evt of capturedEvents)
|
||||
{
|
||||
if (!gameState.isPlayerAlly(evt.from) && !gameState.isPlayerAlly(evt.to))
|
||||
continue;
|
||||
let ent = gameState.getEntityById(evt.entity);
|
||||
if (!ent || !ent.hasClass("Market"))
|
||||
if (!ent || ent.foundationProgress() !== undefined || !ent.hasClass("Market"))
|
||||
continue;
|
||||
this.routeProspection = true;
|
||||
gameState.ai.HQ.restartBuild(gameState, "structures/{civ}_market");
|
||||
|
Loading…
Reference in New Issue
Block a user