forked from screepers/screeps-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroomDescribe.js
More file actions
32 lines (30 loc) · 701 Bytes
/
Copy pathroomDescribe.js
File metadata and controls
32 lines (30 loc) · 701 Bytes
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
/*
* Posted 20 June 2019 by @engineeryo
* Get type of room from name
*
* @author engineeryo
* @co-author warinternal
*/
global.ROOM_STANDARD = 'room'
global.ROOM_SOURCE_KEEPER = 'source_keeper'
global.ROOM_CENTER = 'center'
global.ROOM_HIGHWAY = 'highway'
global.ROOM_CROSSROAD = 'highway_portal'
Room.describe = function(name) {
const [EW, NS] = name.match(/\d+/g)
if (EW%10 == 0 && NS%10 == 0) {
return ROOM_CROSSROAD
}
else if (EW%10 == 0 || NS%10 == 0) {
return ROOM_HIGHWAY
}
else if (EW%5 == 0 && NS%5 == 0) {
return ROOM_CENTER
}
else if (Math.abs(5 - EW%10) <= 1 && Math.abs(5 - NS%10) <= 1) {
return ROOM_SOURCE_KEEPER
}
else {
return ROOM_STANDARD
}
}