-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole.claimer.js
More file actions
31 lines (25 loc) · 1.01 KB
/
Copy pathrole.claimer.js
File metadata and controls
31 lines (25 loc) · 1.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
var roleClaimer = {
/** @param {Creep} creep **/
run: function(creep) {
var claimFlag = Game.flags['ClaimFlag'];
var controller = creep.room.controller;
console.log(controller);
if(creep.memory.claiming && creep.room.name != claimFlag.pos.roomName){ // 占领状态 && 不在claimFlag房间
creep.memory.claiming = false;
creep.say('🔄 claim');
}
if(!creep.memory.claiming && creep.room.name == claimFlag.pos.roomName){ // 非占领状态 && 在claimFlag房间
creep.memory.claiming = true;
creep.say('🔫 attack');
}
if(creep.memory.claiming) { // 占领状态
if(creep.claimController(controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(controller, {visualizePathStyle: {stroke: '#ffffff'}});
}
}
else { // 非占领状态
creep.moveTo(claimFlag, {visualizePathStyle: {stroke: '#ff0000'}});
}
}
};
module.exports = roleClaimer;