Fixed calculations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name IITC plugin: ResTools BB Watch Reloaded
|
||||
// @namespace https://git.martinvylet.cz/vykend/ResTools-BB-Watch-Reloaded
|
||||
// @version 0.5
|
||||
// @version 0.6
|
||||
// @description Scan window for BBs on ornamented portals, then check results
|
||||
// @author vikend
|
||||
// @icon
|
||||
@@ -85,8 +85,8 @@ function wrapper(plugin_info)
|
||||
const timezoneOffsetHours = window.plugin.restoolsBBWatchReloaded.timezone; // Assuming the offset is stored in hours
|
||||
const offsetMilliseconds = timezoneOffsetHours * 60 * 60 * 1000; // Convert offset to milliseconds
|
||||
const currentTimeWithOffset = new Date(currentTime.getTime() + offsetMilliseconds);
|
||||
const currentTimeString = currentTimeWithOffset.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
const currentTimePlus5Minutes = (new Date(currentTimeWithOffset.getTime() + 5 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
const currentTimeString = currentTimeWithOffset.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
|
||||
const currentTimePlus5Minutes = (new Date(currentTimeWithOffset.getTime() + 5 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
|
||||
|
||||
let currentWave = 0;
|
||||
let battleOver = false;
|
||||
@@ -154,7 +154,7 @@ function wrapper(plugin_info)
|
||||
console.log("BBWatchReloaded: According to timetable anomaly haven't started yet, skipping");
|
||||
return;
|
||||
}
|
||||
if (waveNo > 7) {
|
||||
if (waveNo >= 7) {
|
||||
console.log("BBWatchReloaded: According to timetable anomaly already ended, skipping");
|
||||
return;
|
||||
}
|
||||
@@ -206,15 +206,16 @@ function wrapper(plugin_info)
|
||||
for (let i in results) {
|
||||
let portal = results[i];
|
||||
if (ornamented.find((obj) => obj.Guid === portal.Guid)) {
|
||||
var foundObj = ornamented.find((obj) => obj.Guid === portal.Guid);
|
||||
if (portal.IsWinnerRes) {
|
||||
resWin++;
|
||||
if (portal.IsVolatile) {
|
||||
if (foundObj.IsVolatile) {
|
||||
resVolatiles++;
|
||||
}
|
||||
}
|
||||
else if (portal.IsWinnerEnl) {
|
||||
enlWin++;
|
||||
if (portal.IsVolatile) {
|
||||
if (foundObj.IsVolatile) {
|
||||
enlVolatiles++;
|
||||
}
|
||||
}
|
||||
@@ -235,13 +236,20 @@ function wrapper(plugin_info)
|
||||
{
|
||||
let waves = [];
|
||||
for (let i in window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS) {
|
||||
var volatiles = 0;
|
||||
|
||||
for (var j = 0; j < window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length; j++) {
|
||||
if (window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0][j].IsVolatile === true) {
|
||||
volatiles++;
|
||||
}
|
||||
}
|
||||
let results = window.plugin.restoolsBBWatchReloaded.computeBeacons(i);
|
||||
let wave = {
|
||||
WaveNumber: Number(i) +1,
|
||||
volatilesCount: 0,
|
||||
volatilesCount: volatiles,
|
||||
beaconCount: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length,
|
||||
PercentageRes: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results.resWin,
|
||||
PercentageEnl: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results.enlWin,
|
||||
PercentageRes: (results.resWin/window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length)*100,
|
||||
PercentageEnl: (results.enlWin/window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length)*100,
|
||||
BeaconsWonRes: results.resWin,
|
||||
BeaconsWonResVolatiles: results.resVolatiles,
|
||||
BeaconsWonEnl: results.enlWin,
|
||||
@@ -260,7 +268,12 @@ function wrapper(plugin_info)
|
||||
|
||||
window.plugin.restoolsBBWatchReloaded.loadStorage = function() {
|
||||
if (localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE] != undefined) {
|
||||
return JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]);
|
||||
if (JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]) != null) {
|
||||
return JSON.parse(localStorage[window.plugin.restoolsBBWatchReloaded.BB_STORAGE]);
|
||||
}
|
||||
else {
|
||||
return window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS;
|
||||
@@ -315,16 +328,16 @@ function wrapper(plugin_info)
|
||||
<tr>
|
||||
<td>`+ wave.WaveNumber +`</td>
|
||||
<td>`+ wave.beaconCount + " (" + wave.volatilesCount + ")" + `</td>
|
||||
<td>`+ wave.PercentageRes +`</td>
|
||||
<td>`+ wave.PercentageEnl +`</td>
|
||||
<td>`+ wave.PercentageRes.toFixed(2) +`</td>
|
||||
<td>`+ wave.PercentageEnl.toFixed(2) +`</td>
|
||||
<td>`+ wave.BeaconsWonRes + " (" + wave.BeaconsWonResVolatiles + ")" + `</td>
|
||||
<td>`+ wave.BeaconsWonEnl + " (" + wave.BeaconsWonEnlVolatiles + ")" + `</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
|
||||
let bestScore = `<p style="font-weight: bold;">BB SCORING ESTIMATE: RES ` + maxBeaconsWonRes/(maxBeaconsWonRes+maxBeaconsWonEnl) + `:` + maxBeaconsWonEnl/(maxBeaconsWonRes+maxBeaconsWonEnl)+ ` ENL</p>`;
|
||||
let bestScoreVolatiles = `<p style="font-weight: bold;">BB SCORING ESTIMATE (including volatiles, speculative): RES ` + (maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)/((maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)+(maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave)) + `:` + (maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave)/((maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)+(maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave))+ ` ENL</p>`;
|
||||
let bestScore = `<p style="font-weight: bold;">BB SCORING ESTIMATE: RES ` + (maxBeaconsWonRes/(maxBeaconsWonRes+maxBeaconsWonEnl)*100).toFixed(2) + `:` + (maxBeaconsWonEnl/(maxBeaconsWonRes+maxBeaconsWonEnl)*100).toFixed(2) + ` ENL</p>`;
|
||||
let bestScoreVolatiles = `<p style="font-weight: bold;">BB SCORING ESTIMATE (including volatiles, speculative): RES ` + ((maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)/((maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)+(maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave))*100).toFixed(2) + `:` + ((maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave)/((maxBeaconsWonRes+ 2*volatilesBeaconsWonResInBestWave)+(maxBeaconsWonEnl+ 2*volatilesBeaconsWonEnlInBestWave))*100).toFixed(2)+ ` ENL</p>`;
|
||||
|
||||
let htmlEnd = `
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user