-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprototype.flag.js
46 lines (45 loc) · 1.62 KB
/
prototype.flag.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
34
35
36
37
38
39
40
41
42
43
44
45
46
Flag.prototype.isRoadActive = function() {
var color_list = FLAG_TYPE_TO_COLORS_COLORS(FLAG_ROADDEST);
if (!color_list.length) {
return -1;
}
if (color_list[0] != this.color) {
return -2;
}
if (color_list[1] != this.secondaryColor) {
return -3;
}
var myexits = Game.map.describeExits(this.room.name);
var exnum = 0;
if (this.pos.x == 0) {
exnum = "7";
} else if (this.pos.x == 49) {
exnum = "3";
} else if (this.pos.y == 0) {
exnum = "1";
} else if (this.pos.y == 49) {
exnum = "5";
}
if (exnum === 0) {
return true;
}
var destr = myexits[exnum];
if (!destr) {
console.log("Flag.isRoadActive: " + this.name + " in " + this.room.name + ": not active because my pos " + this.pos.x + "/" + this.pos.y + " is not on an edge.");
return false;
}
if (!Game.rooms[destr]) {
console.log("Flag.isRoadActive: " + this.name + " in " + this.room.name + ": destination room " + destr + ": is not in Game.rooms");
return false;
}
if (Game.rooms[destr].isMine()) {
console.log("Flag.isRoadActive: " + this.name + " in " + this.room.name + ": destination room " + destr + ": isMine!");
return true;
}
if (Game.rooms[destr].isRemote()) {
console.log("Flag.isRoadActive: " + this.name + " in " + this.room.name + ": destination room " + destr + ": isRemote!");
return true;
}
console.log("Flag.isRoadActive: " + this.name + " in " + this.room.name + ": destination room " + destr + ": !isMine && !isRemote... fail");
return false;
}