From e4831aa8e8fd758dfdb3df8ca7442762b7a7a227 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 18 Nov 2020 09:04:06 -0600 Subject: [PATCH] Fix miner spawn bug and add check for how many positions are usable when mining. increase miner spawns to match this number, add Empire function to init all rooms with this data. --- Empire.js | 14 ++++++++++++++ Room.Phase1.js | 4 ++-- RoomInit.js | 9 +++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Empire.js b/Empire.js index b593bd2..fcc5e78 100644 --- a/Empire.js +++ b/Empire.js @@ -96,6 +96,20 @@ module.exports = { Game.rooms[name].memory.minablepositions = minablepositions } }, + computeMineralAccess: function(){ + for(let myroom of _.filter(Game.rooms, 'controller.my')) { + let name = myroom.name + let mineralminablepositions = 0 + let minerals = Game.rooms[name].find(FIND_MINERALS); + for(let i = 0;i 0)&&(creepcounts["miner"] < 1 || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){ - if(Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration < 1000){ + if((Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}).length > 0)&&(creepcounts["miner"] < Game.rooms[room].memory.mineralminablepositions || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){ + if(Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration == undefined || Game.rooms[room].find(FIND_MINERALS)[0].ticksToRegeneration < 1000 ){ console.log("Spawning Miner in " + room) require('proc.spawning').spawnminer(room) } else { if(Game.flags.debug && Game.flags.debug.room == Game.rooms[room]){console.log("Not spawning miner in " + room + ", waiting for regen")}} diff --git a/RoomInit.js b/RoomInit.js index bcd5aa6..1a983a2 100644 --- a/RoomInit.js +++ b/RoomInit.js @@ -10,6 +10,15 @@ let initroom = { Game.rooms[name].memory.tickssofar=0 Game.rooms[name].memory.maphits={} //Game.rooms[name].memory.minablepositions= this.checkminablepositions(name) + let mineralminablepositions = 0 + let minerals = Game.rooms[name].find(FIND_MINERALS); + for(let i = 0;i