This commit is contained in:
Dan Hamik 2022-06-01 09:39:13 -05:00
parent 5c5b9003ad
commit 949f1d0e64
3 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,9 @@
let Phase0 = { let Phase0 = {
run: function(room) { run: function(room) {
require('assignsources').tick(room) require('assignsources').tick(room)
creepcounts = _.countBy(Game.rooms[room].find(FIND_MY_CREEPS), c => c.memory.role) let creepcounts = _.countBy(Game.rooms[room].find(FIND_MY_CREEPS), c => c.memory.role)
if(creepcounts===undefined){creepcounts['phase' + Game.rooms[room].memory.phase +'worker']=0}
Game.rooms[room].memory.creepcounts=creepcounts
let myspawns = Game.rooms[room].find(FIND_MY_SPAWNS) let myspawns = Game.rooms[room].find(FIND_MY_SPAWNS)
let sources = Game.rooms[room].find(FIND_SOURCES ) let sources = Game.rooms[room].find(FIND_SOURCES )
if(myspawns.length<1){ if(myspawns.length<1){
@ -24,8 +26,8 @@ let Phase0 = {
} else { } else {
let workerrolename = 'phase' + Game.rooms[room].memory.phase +'worker' let workerrolename = 'phase' + Game.rooms[room].memory.phase +'worker'
console.log(room) console.log(room)
console.log(workerrolename + " : " + creepcounts[workerrolename]) console.log("room.phase0.js "+workerrolename + " : " + creepcounts[workerrolename])
if(((creepcounts[workerrolename]< (sources.length * 1) || creepcounts[workerrolename]==undefined) && !myspawns[0].spawning && Game.rooms[room].energyAvailable == Game.rooms[room].energyCapacityAvailable) || (creepcounts[workerrolename] ==0 && Game.rooms[room].energyAvailable==300) ){ if(( creepcounts[workerrolename] == undefined ||(creepcounts[workerrolename]< (sources.length * 1) || creepcounts[workerrolename]==undefined) && !myspawns[0].spawning && Game.rooms[room].energyAvailable == Game.rooms[room].energyCapacityAvailable) || (creepcounts[workerrolename] ==0 && Game.rooms[room].energyAvailable==300) ){
if(Game.rooms[room].energyAvailable == Game.rooms[room].energyCapacityAvailable){ if(Game.rooms[room].energyAvailable == Game.rooms[room].energyCapacityAvailable){
require('proc.spawning').spawnworker(room) require('proc.spawning').spawnworker(room)
} }

View File

@ -25,7 +25,7 @@ module.exports.loop = function () {
try{ try{
require('Room.Phase' + myroom.memory.phase).run(name) require('Room.Phase' + myroom.memory.phase).run(name)
} catch(e){ } catch(e){
console.log(e) console.log(myroom.name + ": " + e)
} }
} }

View File

@ -30,7 +30,7 @@ let mover={
} }
if(creep.room.name != creep.memory.assignedroom){ if(creep.room.name != creep.memory.assignedroom){
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller) creep.moveTo(Game.rooms[creep.memory.assignedroom].controller)
Game.notify(creep.name + " Not in assigned room") //Game.notify(creep.name + " Not in assigned room")
} else { } else {
if(creep.memory.working){ if(creep.memory.working){
//let terminaltarget = creep.room.terminal //let terminaltarget = creep.room.terminal