2016-09-28 08:37:28 -05:00
|
|
|
'use strict';
|
2017-06-06 13:17:26 -05:00
|
|
|
global.Empire = require("Empire")
|
2020-11-09 19:31:39 -06:00
|
|
|
let Traveler = require("Traveler")
|
2017-07-13 23:24:42 -05:00
|
|
|
global.verbosity=0
|
2016-09-15 00:30:24 -05:00
|
|
|
module.exports.loop = function () {
|
2020-11-09 19:31:39 -06:00
|
|
|
for(let name in Game.rooms){
|
|
|
|
let myroom=Game.rooms[name]
|
|
|
|
|
|
|
|
let towers = Game.rooms[name].find(FIND_MY_STRUCTURES, {filter: { structureType: STRUCTURE_TOWER }})
|
|
|
|
//console.log(towers.length)
|
|
|
|
if(towers.length>0){
|
|
|
|
// console.log('running towers in ' + name)
|
|
|
|
require('Run.Tower').tick(name)
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!myroom.memory.hasbeeninited && (myroom.controller!==undefined)){
|
|
|
|
require('RoomInit').run(name)
|
|
|
|
}
|
|
|
|
if(myroom.controller!==undefined){
|
|
|
|
myroom.memory.tickssofar++
|
|
|
|
require('Room.Phase' + myroom.memory.phase).run(name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-28 08:37:28 -05:00
|
|
|
for(let name in Memory.creeps) {
|
2016-09-15 00:30:24 -05:00
|
|
|
if(!Game.creeps[name]) {
|
|
|
|
delete Memory.creeps[name];
|
2017-07-13 23:24:42 -05:00
|
|
|
if(global.verbosity>0){
|
2016-09-15 00:30:24 -05:00
|
|
|
console.log('Clearing non-existing creep memory:', name);
|
2017-07-13 23:24:42 -05:00
|
|
|
}
|
2020-11-09 19:31:39 -06:00
|
|
|
} else {
|
|
|
|
try{
|
|
|
|
let creep = Game.creeps[name]
|
|
|
|
if(creep.spawning) return;
|
|
|
|
if(creep.fatigue>0){
|
|
|
|
creep.say('fatigued')
|
|
|
|
creep.room.createConstructionSite(creep.pos.x,creep.pos.y,STRUCTURE_ROAD)
|
|
|
|
}
|
|
|
|
|
|
|
|
require('role.' + creep.memory.role).run(creep)
|
|
|
|
//creep.say("TRYING")
|
|
|
|
} catch (e) {}
|
2016-09-15 00:30:24 -05:00
|
|
|
}
|
|
|
|
}
|
2020-11-09 19:31:39 -06:00
|
|
|
let flags = Game.flags
|
|
|
|
for(let flag in flags){
|
|
|
|
require('flag.' + flag ).run()
|
2017-06-06 13:17:26 -05:00
|
|
|
}
|
2020-11-09 19:31:39 -06:00
|
|
|
for(let name in Memory.rooms) {
|
|
|
|
let myroom = Game.rooms[name]
|
|
|
|
if(!Game.rooms[name]){delete Memory.rooms[name]}
|
|
|
|
}
|
|
|
|
|
2017-07-13 23:24:42 -05:00
|
|
|
}
|