Added score estimation, cosmetic upgrades, fixed addNewPortals
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name IITC plugin: ResTools BB Watch Reloaded
|
||||
// @namespace https://github.com/restools/BBWatchReloaded
|
||||
// @version 0.2
|
||||
// @version 0.3
|
||||
// @description Scan window for BBs on ornamented portals, then check results
|
||||
// @author vikend
|
||||
// @icon
|
||||
@@ -146,7 +146,7 @@ function wrapper(plugin_info)
|
||||
let waveNo = wave[0] -1;
|
||||
|
||||
if (waveNo < 0) {
|
||||
console.log("According to timetable anomaly haven't started yet, skipping");
|
||||
console.log("BBWatchReloaded: According to timetable anomaly haven't started yet, skipping");
|
||||
return;
|
||||
}
|
||||
let portalsToBeAdded = [];
|
||||
@@ -169,6 +169,10 @@ function wrapper(plugin_info)
|
||||
if(portal.IsWinnerRes || portal.IsWinnerEnl) {
|
||||
//check if portal wasnt already added
|
||||
if (!(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][waveBattleOver].find((obj) => obj.Guid === portal.Guid))) {
|
||||
|
||||
//check if portal isnt already in portalsToBeAdded
|
||||
|
||||
|
||||
//check if portal was added as ornamented before
|
||||
if ((window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][0].find((obj) => obj.Guid === portal.Guid))) {
|
||||
portalsToBeAdded.push(portal);
|
||||
@@ -186,19 +190,34 @@ function wrapper(plugin_info)
|
||||
let ornamented = window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[wave][0];
|
||||
let results = window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[wave][1];
|
||||
let resWin = 0;
|
||||
let resVolatiles = 0;
|
||||
let enlWin = 0;
|
||||
let enlVolatiles = 0;
|
||||
for (let i in results) {
|
||||
let portal = results[i];
|
||||
if (ornamented.find((obj) => obj.Guid === portal.Guid)) {
|
||||
if (portal.IsWinnerRes) {
|
||||
resWin++;
|
||||
if (portal.IsVolatile) {
|
||||
resVolatiles++;
|
||||
}
|
||||
}
|
||||
else if (portal.IsWinnerEnl) {
|
||||
enlWin++;
|
||||
if (portal.IsVolatile) {
|
||||
enlVolatiles++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [resWin, enlWin];
|
||||
}
|
||||
let objResults = {
|
||||
resWin: resWin,
|
||||
enlWin: enlWin,
|
||||
resVolatiles: resVolatiles,
|
||||
enlVolatiles: enlVolatiles
|
||||
}
|
||||
|
||||
return objResults;
|
||||
|
||||
}
|
||||
|
||||
@@ -209,11 +228,14 @@ function wrapper(plugin_info)
|
||||
let results = window.plugin.restoolsBBWatchReloaded.computeBeacons(i);
|
||||
let wave = {
|
||||
WaveNumber: Number(i) +1,
|
||||
volatilesCount: 0,
|
||||
beaconCount: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length,
|
||||
PercentageRes: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results[0],
|
||||
PercentageEnl: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results[1],
|
||||
BeaconsWonRes: results[0],
|
||||
BeaconsWonEnl: results[1]
|
||||
PercentageRes: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results.resWin,
|
||||
PercentageEnl: window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[i][0].length/results.enlWin,
|
||||
BeaconsWonRes: results.resWin,
|
||||
BeaconsWonResVolatiles: results.resVolatiles,
|
||||
BeaconsWonEnl: results.enlWin,
|
||||
BeaconsWonEnlVolatiles: results.enlVolatiles
|
||||
};
|
||||
waves.push(wave);
|
||||
}
|
||||
@@ -242,45 +264,58 @@ function wrapper(plugin_info)
|
||||
// --- DIALOG
|
||||
window.plugin.restoolsBBWatchReloaded.showDialog = function(waves)
|
||||
{
|
||||
let maxBeaconsWonRes = -Infinity; // Initialize with a very small value
|
||||
let maxBeaconsWonEnl = -Infinity;
|
||||
|
||||
let htmlBegin = `
|
||||
<div class="restoolsBBWatchReloadedDialog">
|
||||
<table class="styled-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Wave</th>
|
||||
<th># of BBs</th>
|
||||
<th># of BBs (volatiles)</th>
|
||||
<th>% points RES</th>
|
||||
<th>% points ENL</th>
|
||||
<th># winner RES</th>
|
||||
<th># winner ENL</th>
|
||||
<th># winner RES (volatiles)</th>
|
||||
<th># winner ENL (volatiles)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
`;
|
||||
let htmlEnd = `
|
||||
</tbody>
|
||||
</table>
|
||||
<a onclick="window.plugin.restoolsBBWatchReloaded.resetStorage()" title="Reset local storage (deletes data saved in your browser, do this prior to anomaly)">Reset local storage</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
let htmlBody = ``;
|
||||
|
||||
for (let waveIndex in waves)
|
||||
{
|
||||
let wave = waves[waveIndex];
|
||||
if (wave.BeaconsWonRes > maxBeaconsWonRes) {
|
||||
maxBeaconsWonRes = wave.BeaconsWonRes;
|
||||
}
|
||||
if (wave.BeaconsWonEnl > maxBeaconsWonEnl) {
|
||||
maxBeaconsWonEnl = wave.BeaconsWonEnl;
|
||||
}
|
||||
|
||||
htmlBody += `
|
||||
<tr>
|
||||
<td>`+ wave.WaveNumber +`</td>
|
||||
<td>`+ wave.beaconCount +`</td>
|
||||
<td>`+ wave.beaconCount + " (" + wave.volatilesCount + ")" + `</td>
|
||||
<td>`+ wave.PercentageRes +`</td>
|
||||
<td>`+ wave.PercentageEnl +`</td>
|
||||
<td>`+ wave.BeaconsWonRes +`</td>
|
||||
<td>`+ wave.BeaconsWonEnl +`</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 htmlEnd = `
|
||||
</tbody>
|
||||
</table>` + bestScore + `
|
||||
<a onclick="window.plugin.restoolsBBWatchReloaded.resetStorage()" title="Reset local storage (deletes data saved in your browser, do this prior to anomaly)">Reset local storage</a>
|
||||
<a style="float: right;" onclick="window.plugin.restoolsBBWatchReloaded.getCurrentState()" title="Refresh this dialog window">Refresh this window</a>
|
||||
</div>
|
||||
`;
|
||||
let html = htmlBegin + htmlBody + htmlEnd;
|
||||
|
||||
dialog({
|
||||
@@ -302,7 +337,6 @@ function wrapper(plugin_info)
|
||||
setTimeout(window.plugin.restoolsBBWatchReloaded.updateCurrentState, 10 * 1000);
|
||||
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = window.plugin.restoolsBBWatchReloaded.loadStorage();
|
||||
console.log("BBWatchReloaded: Loaded previous state");
|
||||
//console.log(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS);
|
||||
|
||||
|
||||
// Toolbox
|
||||
|
||||
Reference in New Issue
Block a user