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