-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbond.js
136 lines (115 loc) · 3.47 KB
/
bond.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Bash script to help get all the possible familiars
//for i in {1..34}; do wget http://flightrising.com/main.php?p=bestiary\&tab=familiars\&page=$i ; done
//more main.php\?p\=bestiary\&tab\=familiars\&page\=* | grep "/images/cms/familiar/art/"
var familiars = [];
var moneyMade = 0;
var rustedTotal = 0;
var ironTotal = 0;
var gildedTotal = 0;
var totalBonded = 0;
var links = document.getElementsByClassName("clue");
for (var i = 0; i < links.length; i++) {
var id = links[i].rel.match(/(\d+)/)[0];
familiars.push(id);
}
var dragonID = window.location.href.split("did=")[1];
function detachFamiliar()
{
attachFamiliar('0');
}
function attachFamiliar(familiarID)
{
$(document).trigger('hideCluetip');
$.ajax({
data: {id: dragonID, itm: familiarID},
url: "includes/familiar_active.php",
async:false
}).done(function(msg){
$("#familiar").html(msg);
$.ajax({
url: "includes/familiar_inv.php",
async:false
}).done(function(msg){
$("#invwindow").html(msg);
});
});
}
function bondJamesbond(id)
{
$('body').append('<div id="bonding"></div>');
$("#bonding").html('<img src="/images/layout/loading.gif"> loading...');
$('#bonding').dialog({
autoOpen: false,
title: "Bond with Familiar",
width: 450,
height: "auto",
modal: true,
resizable: false,
draggable: false,
closeOnEscape: false,
open: function(event, ui) {
$(".ui-dialog-titlebar-close", ui.dialog).hide();
}
});
$('#bonding').dialog('open');
$.ajax({
type: "POST",
data: {id: id},
url: "includes/ol/fam_bonding.php",
cache:false,
async:false
}).done(function(stuff){
if (stuff.indexOf("You have already bonded with this familiar today.") > -1) {
console.log("Already bonded to: "+id);
} else if (stuff.indexOf("You've earned these rewards today:") > -1) {
console.log("Successfully bonded to: "+id);
moneyMade+=stuff.match(/\s([0-9][0-9])\s/)[1]*1;
totalBonded++;
} else if (stuff.indexOf("lair") > -1) {
alert("Failed to bond, manually bond with this familiar after the script ends, click okay to allow the script to contine");
} else {
alert("Something bad happened");
}
if (stuff.indexOf("574.png") > -1) {
rustedTotal++;
}
if (stuff.indexOf("575.png") > -1) {
ironTotal++;
}
if (stuff.indexOf("576.png") > -1) {
gildedTotal++;
}
$("#bonding").html(stuff.replace(/<button.*button>/g, ""));
});
}
function bondNext() {
var start = new Date();
fam = familiars[0];
detachFamiliar();
attachFamiliar(fam);
bondJamesbond(fam);
var end = new Date();
var time = end.getTime() - start.getTime();
console.log("Took: "+time);
familiars.shift();
if (familiars.length != 0) {
setTimeout('bondNext()', 50);
} else {
setTimeout('cleanUp()', 50);
}
}
function cleanUp() {
detachFamiliar();
var endAll = new Date();
var time = endAll.getTime() - startAll.getTime();
console.log("All bonding took: "+time);
$('#bonding').dialog('close');
alert("Bonded to "+totalBonded+" familiars, and earnt "+moneyMade+" gold. Got "+rustedTotal+" Rusted Chests, "+ironTotal+" Iron Chests and "+gildedTotal+" gilded Chests. Took "+time/1000+" seconds.");
}
if (dragonID == undefined) {
alert("You must be on a dragon page for this to work");
}
if (confirm("You have "+familiars.length+" familiars, this should take approximately "+familiars.length*2+" seconds to complete. Do not interrupt it. Press F12 and click the console tab to monitor the process. Are you sure you want to do this?")) {
var startAll = new Date();
setTimeout('bondNext()', 50);
}