a couple a bugfixes

This was SVN commit r14881.
This commit is contained in:
mimo 2014-03-29 08:51:09 +00:00
parent b815fa8dd9
commit 120f71d944
4 changed files with 9 additions and 4 deletions

View File

@ -173,6 +173,8 @@ m.BaseManager.prototype.checkEvents = function (gameState, events, queues) {
for (var i in renameEvents)
{
var ent = gameState.getEntityById(renameEvents[i].newentity);
if (!ent)
continue;
var workerObject = ent.getMetadata(PlayerID, "worker-object");
if (workerObject)
workerObject.ent = ent;

View File

@ -1026,12 +1026,13 @@ m.HQ.prototype.tryBartering = function(gameState)
continue;
var barterRateMin = 70;
if (available > 1000)
if (available[sell] > 1000)
barterRateMin = 50;
if (sell === "food")
barterRateMin -= 40;
else if (buy === "food")
barterRateMin += 10;
barterRateMin += 20;
var barterRate = getBarterRate(prices, buy, sell);
if (barterRate > bestRate && barterRate > barterRateMin)
@ -1227,6 +1228,8 @@ m.HQ.prototype.buildMoreHouses = function(gameState,queues)
// checks the status of the territory expansion. If no new economic bases created, build some strategic ones.
m.HQ.prototype.checkBaseExpansion = function(gameState,queues)
{
if (queues.civilCentre.length() > 0)
return;
// first expand if we have not enough room available for buildings
if (this.stopBuilding.length > 1)
{

View File

@ -73,7 +73,7 @@ m.QueueManager.prototype.currentNeeds = function(gameState)
}
// get out current resources, not removing accounts.
var current = this.getAvailableResources(gameState, true);
for each (var ress in needed.type)
for each (var ress in needed.types)
needed[ress] = Math.max(0, needed[ress] - current[ress]);
return needed;

View File

@ -55,7 +55,7 @@ m.ConstructionPlan.prototype.start = function(gameState)
gameState.ai.HQ.stopBuilding.push(this.type);
return;
}
this.buildingsBuilt++;
gameState.buildingsBuilt++;
if (this.metadata === undefined)
this.metadata = { "base": pos.base };