-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.js
278 lines (245 loc) · 9.12 KB
/
function.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
function xpForNext(curLvl) {
if (curLvl <= 59)
return 7200000 + 1440000 * curLvl;
else if (curLvl <= 69)
return 95040000 + 2880000 * (curLvl - 60);
else if (curLvl <= 72)
return 126000000 + 5040000 * (curLvl - 70);
else if (curLvl == 73)
return 139740000;
else if (curLvl <= 148)
return 140760000 + 1020000 * (curLvl - 74);
else if (curLvl <= 249)
return 218280000 + 2040000 * (curLvl - 149);
else if (curLvl <= 349)
return 426360000 + 4080000 * (curLvl - 250);
else if (curLvl <= 448)
return 836400000 + 6120000 * (curLvl - 350);
else if (curLvl <= 499)
return 1444320000 + 8160000 * (curLvl - 449);
else if (curLvl <= 549)
return 1872720000 + 20400000 * (curLvl - 500);
else if (curLvl <= 599)
return 2913120000 + 40800000 * (curLvl - 550);
else if (curLvl <= 649)
return 4973520000 + 61200000 * (curLvl - 600);
else if (curLvl <= 699)
return 8053920000 + 81600000 * (curLvl - 650);
else if (curLvl <= 749)
return 12154320000 + 102000000 * (curLvl - 700);
else if (curLvl <= 2249)
return 17274720000 + 122400000 * (curLvl - 750);
else if (curLvl == 2250)
return 200981922000;
else if (curLvl >= 2251) {
var xp = 200981922000;
for (var i = curLvl - 2250; i > 0; i--)
xp += 229602000 + 102000 * (i);
return xp;
}
}
function sumPara(currLvl, goalLvl) {
var sum = 0;
for (var i = currLvl; i < goalLvl; i++) {
sum += xpForNext(i);
}
return sum;
}
function xpFromClosingGR(grLvl) {
return Math.round(_xpFromClosingGR(grLvl));
}
function _xpFromClosingGR(grLvl) {
if (grLvl == 1)
return 15660001;
else if (grLvl <= 25)
return xpFromClosingGR(grLvl - 1) * 1.1270304;
else if (grLvl <= 70)
return xpFromClosingGR(grLvl - 1) * 1.08;
else
return xpFromClosingGR(grLvl - 1) * 1.05;
}
function computePercentageRatio(everageEliteKill) {
var baseM = 0.535; // 53.5%
var baseR = 0.465; // 46.5%
var step = baseM * (1 - everageEliteKill * 3.5 * 0.0115); //3.5 average orb amount per elite pack; 1.15 progression from orb
var tot = step + baseR;
return {
monsterRatio: step / tot,
closingRatio: baseR / tot
};
}
function computeBaseXpReward(grLvl, collectOrb, everageEliteKill) {
if (collectOrb)
var ratios = computePercentageRatio(everageEliteKill);
else
var ratios = {
monsterRatio: 0.535,
closingRatio: 0.465
}
var xpFromGr = xpFromClosingGR(grLvl);
return {
monster: 1 / ratios.closingRatio * xpFromClosingGR(grLvl) - xpFromGr,
closing: xpFromGr
};
}
function addBonusXp(xp, poolClosing, poolMonster, itemBonusXp, nbPlayer) {
var bonusPlayer = 1 + (nbPlayer - 1) * 0.10;
var bonusItemXp = 1 + itemBonusXp / nbPlayer;
return {
monster: xp.monster * bonusItemXp * bonusPlayer * (poolMonster ? 1.25 : 1),
closing: xp.closing * (poolClosing ? 1.5625 : 1)
}
}
function parseTime(time) {
var tmp = time.split(":");
return parseInt(tmp[0]) * 60 * 60 + parseInt(tmp[1]) * 60 + (tmp[2] == null ? 0 : parseInt(tmp[2]));
}
function getAverageRiftTime() {
return parseTime($('#timeRift').val()) / $('#nbRift').val();
}
function formatTime(seconds, formatForValue) {
var days = Math.trunc(seconds / 86400);
seconds -= days * 86400;
var hours = Math.trunc(seconds / 3600);
seconds -= hours * 3600;
var minutes = Math.trunc(seconds / 60);
seconds -= minutes * 60;
seconds = Math.trunc(seconds);
if (!formatForValue) {
var result = "";
if (days > 0)
result += days + " day" + (days > 1 ? "s " : " ");
if (hours > 0)
result += hours + " hour" + (hours > 1 ? "s" : "");
result += " and " + minutes + " minute" + (minutes > 1 ? "s" : "");
return (result == "" ? "Too Few Time" : result);
} else {
return (hours.toString().length == 1 ? "0" : "") + hours + ":" + (minutes.toString().length == 1 ? "0" : "") + minutes + ":" + (seconds.toString().length == 1 ? "0" : "") + seconds;
}
}
$(document).ready(function () {
var showToolTipXp = false;
$('#resultXp').on("mouseenter", function (e) {
if (showToolTipXp) {
$('#xpDetailTooltip').css({
left: e.pageX + 10,
top: e.pageY + 10
});
$('#xpDetailTooltip').show();
}
});
$('#resultXp').on("mousemove", function (e) {
if (showToolTipXp) {
$('#xpDetailTooltip').css({
left: e.pageX + 10,
top: e.pageY + 10
});
}
});
$('#resultXp').on("mouseleave", function (e) {
if (showToolTipXp) {
$('#xpDetailTooltip').hide();
}
});
$('#hintTime').on("click", function (e) {
$('#hintTimeBox').css({
left: e.pageX,
top: e.pageY
});
$('#closeFrame').show();
$('#hintTimeBox').show();
});
$('#closeFrame').on("click", function () {
$('#hintTimeBox').hide();
$('#closeFrame').hide();
});
$('#validateHint').on("click", function () {
if ($('#hintTimeGR').val() != "" && $('#hintTimeGR').val() != "00:00:00") {
var averageSeconde = parseTime($('#hintTimeGR').val()) / parseInt($('#hintAmountGR').val());
$('#timeRift').val(formatTime(averageSeconde, true));
}
});
$('#currentPara').on("keypress change", function (e) {
if (e.type == "keypress") {
if (!isFinite(e.key))
e.preventDefault();
} else if (e.type == "change") {
if ($('#currentPara').val() != "") {
var newValue = parseInt($('#currentPara').val());
if (newValue >= parseInt($('#goalPara').val()))
$('#goalPara').val(newValue + 1);
} else {
$('#currentPara').val(0);
}
}
});
$('#goalPara').on("keypress change", function (e) {
if (e.type == "keypress") {
if (!isFinite(e.key))
e.preventDefault();
} else if (e.type == "change") {
if ($('#goalPara').val() != "" && parseInt($('#goalPara').val()) > 1) {
var newValue = parseInt($('#goalPara').val());
if (newValue <= parseInt($('#currentPara').val()))
$('#currentPara').val(newValue - 1);
} else {
$('#goalPara').val(1);
}
}
});
$('#grLevel,#hintAmountGR').on("keypress change", function (e) {
if (e.type == "keypress") {
if (!isFinite(e.key))
e.preventDefault();
} else if (e.type == "change") {
if ($(e.target).val() == "")
$(e.target).val(0);
}
});
$('#bonusXp').on("keypress change", function (e) {
if (e.type == "keypress") {
if (e.key == "-" || e.key == ",")
e.preventDefault();
} else if (e.type == "change") {
if ($('#bonusXp').val() == "")
$('#bonusXp').val(0);
else
$('#bonusXp').val(parseFloat($('#bonusXp').val()));
}
});
$('#xpFromMonster').on("change", function (e) {
if (!e.target.checked)
$('#poolMonster, #bonusXp').prop("disabled", "disabled")
else
$('#poolMonster, #bonusXp').removeAttr("disabled");
});
$('#compute').on("click", function (e) {
$('#result').show();
var currentPara = parseInt($('#currentPara').val());
var goalPara = parseInt($('#goalPara').val());
var grLevel = parseInt($('#grLevel').val());
var timeRift = parseTime($('#timeRift').val());
var numberPlayer = parseInt($('#numberPlayer').val());
var bonusXp = parseInt($('#bonusXp').val()) / 100;
var xpFromGR = addBonusXp(computeBaseXpReward(grLevel, true, 9), $('#poolClosing').is(":checked"), $('#poolMonster').is(":checked"), bonusXp, numberPlayer);
var averageXpFromGR = xpFromGR.closing + ($('#xpFromMonster').is(":checked") ? xpFromGR.monster : 0);
var xpHour = averageXpFromGR / timeRift * 3600;
var needXp = sumPara(currentPara, goalPara);
var grNeeded = Math.ceil(needXp / (averageXpFromGR));
var totalTime = formatTime(timeRift * grNeeded);
$('#resultXp').text(Math.round(averageXpFromGR).toLocaleString());
$('#resultGR').text(grLevel);
$('#resultCurrentPara').text(currentPara);
$('#resultGoalPara').text(goalPara);
$('#resultTime').text(totalTime);
$('#resultNbGR').text(grNeeded);
$('#resultXpHour').text(Math.round(xpHour).toLocaleString());
showToolTipXp = $('#xpFromMonster').is(":checked");
if (showToolTipXp) {
$('#resultXp').addClass("underlined");
$('#resultXpClosing').text(Math.round(xpFromGR.closing).toLocaleString());
$('#resulXpMonster').text(Math.round(xpFromGR.monster).toLocaleString());
} else
$('#resultXp').removeClass("underlined");
});
});