-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreep.cycle.js
More file actions
40 lines (39 loc) · 2.01 KB
/
Creep.cycle.js
File metadata and controls
40 lines (39 loc) · 2.01 KB
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
30
31
32
33
34
35
36
37
38
39
40
var CreepCycle = function() {
var stateRecycle = require('state.recycle');
var creepCount = require('creepCount');
var numberOfSick = _.filter(Game.creeps, (creep) => creep.memory.sick);
if(!this.memory.sick) {
if(this.memory.role != 'spawnKeeper') {
if(this.ticksToLive < 200) {
this.memory.recycle = true;
//this.memory.sick = true;
}
} else {
if(this.ticksToLive < 200) {
this.memory.sick = true;
}
}/* else {
//this.memory.sick = false;
}*/
}
if(this.memory.sick) {
try {this.sick();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.sick()");}
} else if(this.memory.recycle) {
try {stateRecycle.run(this);} catch(err) {console.log(err+" "+this+": Creep.cycle.js stateRecycle.run(this)");}
} else if(this.memory.role == 'harvester') {
try {this.roleHarvester();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleHarvester()");}
} else if(this.memory.role == 'builder') {
try {this.roleBuilder();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleBuilder()");}
} else if(this.memory.role == 'upgrader') {
try {this.roleUpgrader();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleUpgrader()");}
} else if(this.memory.role == 'fighter') {
try {this.roleFighter();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleFighter()");}
} else if(this.memory.role == 'courier') {
try {this.roleCourier();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleCourier()");}
} else if(this.memory.role == 'spawnKeeper') {
try {this.roleSpawnKeeper();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleSpawnKeeper()");}
} else if(this.memory.role == 'claimer') {
try {this.roleClaimer();} catch(err) {console.log(err+" "+this+": Creep.cycle.js this.roleClaimer()");}
}
};
module.exports = CreepCycle;