-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole.colonizer.js
33 lines (32 loc) · 948 Bytes
/
role.colonizer.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
30
31
32
33
/*
* Module code goes here. Use 'module.exports' to export things:
* module.exports.thing = 'a thing';
*
* You can import it from another modules like this:
* var mod = require('role.colonizer');
* mod.thing == 'a thing'; // true
*/
module.exports = {
claim: function(creep) {
var dest = Game.flags['colonize'];
if(creep.pos.roomName != dest.pos.roomName) {
creep.moveTo(dest);
}
else {
var target = creep.room.controller;
creep.moveTo(target);
var result = creep.claimController(target);
}
},
reserve: function(creep) {
let dest = Game.flags[creep.memory.flag];
if(creep.pos.roomName != dest.pos.roomName) {
creep.moveTo(dest);
}
else {
let target = creep.room.controller;
creep.moveTo(target);
let result = creep.reserveController(target);
}
}
}