diff --git a/RestoolsBBWatchReloaded.js b/RestoolsBBWatchReloaded.js index ff008e9..d7fbc5a 100644 --- a/RestoolsBBWatchReloaded.js +++ b/RestoolsBBWatchReloaded.js @@ -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 = `
| Wave | -# of BBs | +# of BBs (volatiles) | % points RES | % points ENL | -# winner RES | -# winner ENL | +# winner RES (volatiles) | +# winner ENL (volatiles) |
|---|
BB SCORING ESTIMATE: RES ` + maxBeaconsWonRes/(maxBeaconsWonRes+maxBeaconsWonEnl) + `:` + maxBeaconsWonEnl/(maxBeaconsWonRes+maxBeaconsWonEnl)+ ` ENL
`; + + let htmlEnd = ` + + ` + bestScore + ` + Reset local storage + Refresh this window + +`; 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