40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
var roleBase = {
|
|
clearMemory: function(creep_name) {
|
|
var memory = Memory.creeps[creep_name];
|
|
console.log("Cleaning up memory for (late) creep " + creep_name);
|
|
|
|
if(memory.source_id) {
|
|
for(var room in Game.rooms) {
|
|
if(Memory.rooms[room].sources[memory.source_id] != undefined){
|
|
if(Memory.rooms[room].sources[memory.source_id] > 0){
|
|
Memory.rooms[room].sources[memory.source_id] -= 1;
|
|
}
|
|
}
|
|
}
|
|
delete memory.source_id;
|
|
}
|
|
|
|
if(memory.repairId) {
|
|
for(var room in Game.rooms) {
|
|
_.remove(Memory.rooms[room].repairs, (n) => n == memory.repairId);
|
|
delete memory.repairId;
|
|
delete memory.repairTarget;
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
@param {Creep} creep
|
|
@param {int} behaviourLevel
|
|
**/
|
|
run: function(creep, behaviourLevel) {
|
|
if(creep.ticksToLive <= 2) {
|
|
creep.say("Halp X.X!");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
module.exports = roleBase; |