-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclaim.js
More file actions
51 lines (47 loc) · 1.42 KB
/
claim.js
File metadata and controls
51 lines (47 loc) · 1.42 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
41
42
43
44
45
46
47
48
49
50
51
var claimRoom =
{
claim: function()
{
var canRun = true;
if(Memory.claimHome == null)
{
//Verify that a home room has been set (the room that will spawn any creeps needed to claim the room)
console.log("Error: No home room set. Please set home room using Memory.claimHome");
canRun = false;
}
if(Memory.claimTarget == null)
{
//Verify that a target room has been set (the room to be claimed)
console.log("Error: No target room set. Please set target room using Memory.claimTarget");
canRun = false;
}
//Set up myRooms list for extra error checking
var myRooms = [];
for(var thisRoomind in Game.rooms) if(Game.rooms[thisRoomind].controller.my) myRooms.push(Game.rooms[thisRoomind]);
if(Game.gcl.level <= myRooms.length)
{
//Verify that a room can be claimed (GCL is high enough to allow a new room)
console.log("Error: GCL is insufficient to claim a new room. Please wait until GCL increases or use the reserve function instead.");
canRun = false;
}
if(Memory.claimHome)
{
//Verify that the home room is owned by the user
var homeRoom = false;
for(var thisRoomind in myRooms)
{
var thisRoom = myRooms[thisRoomind];
if(thisRoom.name == Memory.claimHome)
{
homeRoom = true;
break;
}
}
if(!homeRoom)
{
console.log("Error: You do not own specified home room. Please reset home room using Memory.claimHome");
canRun = false;
}
}
}
};