petra: do no make a trade route between too nearby markets

This was SVN commit r17005.
This commit is contained in:
mimo 2015-09-11 18:06:26 +00:00
parent 8507a7bc27
commit 979ea476b7
2 changed files with 4 additions and 1 deletions

View file

@ -1078,7 +1078,7 @@ m.HQ.prototype.findMarketLocation = function(gameState, template)
if (this.Config.debug > 1)
API3.warn("this would give a trading gain of " + expectedGain);
// do not keep it if gain is too small, except if this is our first BarterMarket
if (expectedGain < 3 ||
if (expectedGain < this.tradeManager.minimalGain ||
(expectedGain < 8 && (!template.hasClass("BarterMarket") || gameState.getOwnEntitiesByClass("BarterMarket", true).length > 0)))
return false;

View file

@ -12,6 +12,7 @@ m.TradeManager = function(Config)
this.potentialTradeRoute = undefined;
this.routeProspection = false;
this.targetNumTraders = this.Config.Economy.targetNumTraders;
this.minimalGain = 3;
this.warnedAllies = {};
};
@ -408,6 +409,8 @@ m.TradeManager.prototype.checkRoutes = function(gameState, accessIndex)
if (!land && !sea)
continue;
var gain = Math.round(API3.SquareVectorDistance(m1.position(), m2.position()) / this.Config.distUnitGain);
if (gain < this.minimalGain)
continue;
if (m1.foundationProgress() === undefined && m2.foundationProgress() === undefined)
{
if (accessIndex)