-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag.claim.js
29 lines (28 loc) · 1.24 KB
/
flag.claim.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let claim = {
run: function() {
if(Game.flags.claim.room==undefined){} else {
let creepcount = Game.flags.claim.room.find(FIND_MY_CREEPS).length
let totallife = _.sum(Game.flags.claim.room.find(FIND_MY_CREEPS), c => c.ticksToLive)
let avglife = totallife/creepcount
if(creepcount<3||(avglife<700 && creepcount < 4 )){
if(Game.flags.claim.memory.requesttime==undefined){
Game.flags.claim.memory.requesttime=Game.time
Game.notify('Spawning additional new room workers')
require('Empire').spawnnrworker()
} else {
if(Game.time - Game.flags.claim.memory.requesttime > 500){
console.log('ticks have passed, trying agin.')
Game.flags.claim.memory.requesttime=undefined
}
}
} else {
Game.flags.claim.memory.requesttime=undefined
}
if(!Game.flags.claim.room.controller.my){
//console.log('not my controller')
}
console.log("Room: " + Game.flags.claim.room + "CreepCount:"+creepcount+"| Lifetime:" + avglife + "|Request Time:" + Game.flags.claim.memory.requesttime )
}
}
};
module.exports = claim;