petra: fix an index access + some cleanup

This was SVN commit r21324.
This commit is contained in:
mimo
2018-02-22 18:42:45 +00:00
parent b38cf55ff5
commit fd14419bc0
2 changed files with 3 additions and 3 deletions
@@ -753,7 +753,7 @@ m.HQ.prototype.bulkPickWorkers = function(gameState, baseRef, number)
if (!accessIndex)
return false;
// sorting bases by whether they are on the same accessindex or not.
let baseBest = this.baseManagers.slice().sort(function (a,b) {
let baseBest = this.baseManagers.slice().sort((a,b) => {
if (a.accessIndex == accessIndex && b.accessIndex != accessIndex)
return -1;
else if (b.accessIndex == accessIndex && a.accessIndex != accessIndex)
@@ -765,7 +765,7 @@ m.HQ.prototype.bulkPickWorkers = function(gameState, baseRef, number)
let workers = new API3.EntityCollection(gameState.sharedScript);
for (let base of baseBest)
{
if (base.ID === baseRef.ID)
if (base.ID == baseRef.ID)
continue;
base.pickBuilders(gameState, workers, needed);
if (workers.length < number)
@@ -576,7 +576,7 @@ m.Worker.prototype.startGathering = function(gameState)
// Try to help building one if any accessible foundation available
let foundations = gameState.getOwnFoundations().toEntityArray();
let shouldBuild = this.ent.isBuilder() && foundations.some(function(foundation) {
if (!foundation || foundation.getMetadata(PlayerID, "access") !== access)
if (!foundation || m.getLandAccess(gameState, foundation) != access)
return false;
let structure = gameState.getBuiltTemplate(foundation.templateName());
if (structure.resourceDropsiteTypes() && structure.resourceDropsiteTypes().indexOf(resource) !== -1)