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 = {
run: function(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 sources = Game.rooms[room].find(FIND_SOURCES )
if(myspawns.length<1){
@ -24,8 +26,8 @@ let Phase0 = {
} else {
let workerrolename = 'phase' + Game.rooms[room].memory.phase +'worker'
console.log(room)
console.log(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) ){
console.log("room.phase0.js "+workerrolename + " : " + creepcounts[workerrolename])
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){
require('proc.spawning').spawnworker(room)
}

View File

@ -25,7 +25,7 @@ module.exports.loop = function () {
try{
require('Room.Phase' + myroom.memory.phase).run(name)
} 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){
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 {
if(creep.memory.working){
//let terminaltarget = creep.room.terminal