-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (62 loc) · 2.53 KB
/
script.js
File metadata and controls
70 lines (62 loc) · 2.53 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function getDistance(x1, y1, x2, y2)
{
xDis = Math.abs(x1 - x2);
yDis = Math.abs(y1 - y2);
xPy = xDis * xDis;
yPy = yDis * yDis;
totalDis = Math.sqrt(xPy + yPy);
floatedDis = Math.round(100 * totalDis) / 100;
return floatedDis;
}
function existsCloserVillage(origin, dest, cluster)
{
startingDistance = getDistance(origin[0], origin[1], dest[0], dest[1]);
for (nums in document.getElementsByTagName('div'))
{
cell = document.getElementsByTagName('div')[nums];
if (cell.className == 'cox')
{
xCo = document.getElementsByTagName('div')[nums].innerHTML.substring(1);
yCo = document.getElementsByTagName('div')[nums * 1 + 2].innerHTML.substring(0, document.getElementsByTagName('div')[nums * 1 + 2].innerHTML.length - 1);
vilRoot = document.getElementsByTagName('div')[nums - 1];
vil = vilRoot.innerHTML.substring(vilRoot.innerHTML.indexOf('>'), vilRoot.length)
vil = vil.substring(1, vil.indexOf('<'))
if (getDistance(xCo, yCo, dest[0], dest[1]) < (startingDistance - cluster))
{
info = Array(xCo, yCo, vil);
return info;
}
}
}
return false;
}
troopTravel = 6;
goldRow = 1;
keepGoing = true;
while (keepGoing)
{
goldRow++;
if (document.getElementsByTagName('tr')[goldRow] == null || document.getElementsByTagName('tr')[goldRow].getChildren()[1].className != "vil")
{
keepGoing = false;
continue;
}
cell = document.getElementsByTagName('tr')[goldRow].innerHTML;
if (cell.indexOf('Unoccupied Oasis') > 1)
{
cell = cell.substr(cell.indexOf("(") + 1, cell.length)
$calcCoords = cell.substr(0, cell.indexOf(")")).split("|");
$startingCoords = document.title.toString().substring(document.title.toString().indexOf('(') + 1, document.title.toString().indexOf(')')).split('|');
$calcDist = getDistance($startingCoords[0], $startingCoords[1], $calcCoords[0], $calcCoords[1]);
$calcMins = ($calcDist / 7 * 60) / 60;
closerVillage = existsCloserVillage($startingCoords, $calcCoords, 3)
if (closerVillage == false)
{
document.getElementsByTagName('tr')[goldRow].getChildren()[1].getChildren()[0].innerHTML += ' <font color="red">!!</font> ';
} else {
document.getElementsByTagName('tr')[goldRow].getChildren()[1].getChildren()[0].innerHTML += ' <font style="color: red; font-weight: normal; text-variant: small-caps; font-size-adjust: 0.4">' + closerVillage[2] + '</font> ';
}
} else {
continue;
}
}