Compare commits

..

9 Commits

Author SHA1 Message Date
914acb0a09 Updated with more recognised ornaments
Signed-off-by: vykend <mail@martinvylet.cz>
2025-03-09 21:55:14 +01:00
Martin Vylet
5fab2afa16 bump version 2024-02-13 09:10:11 +01:00
Martin Vylet
f4a6c08dd5 Merge branch 'main' of https://git.martinvylet.cz/vykend/ResTools-BB-Watch-Reloaded 2024-02-13 09:08:15 +01:00
Martin Vylet
2ff302571d Edited waves and timing for upcoming Cryptic Memories 2024-02-13 09:06:21 +01:00
963f0b7d1c Update 'RestoolsBBWatchReloaded.js' 2023-06-17 08:39:59 +02:00
0613b011a1 Update 'RestoolsBBWatchReloaded.js' 2023-06-17 07:48:14 +02:00
0cb93c4925 Update 'RestoolsBBWatchReloaded.js' 2023-06-16 09:44:32 +02:00
Martin Vylet
046348a71e Fixed calculations 2023-06-16 09:43:04 +02:00
Martin Vylet
d0e2ecfdea Fixed calculations 2023-06-16 09:40:53 +02:00

View File

@@ -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.2
// @version 0.9.1
// @description Scan window for BBs on ornamented portals, then check results
// @author vikend
// @icon
@@ -27,20 +27,19 @@ function wrapper(plugin_info)
window.plugin.restoolsBBWatchReloaded.LAYERS = {};
window.plugin.restoolsBBWatchReloaded.LAYERGROUP = null;
window.plugin.restoolsBBWatchReloaded.BB_STORAGE = 'plugin-restools-bbwatch-reloaded';
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = [[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]]];
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS = [[[],[]],[[],[]],[[],[]],[[],[]],[[],[]],[[],[]]];
window.plugin.restoolsBBWatchReloaded.timezone = 0;
//struct of WAVE_PORTALS: [ wave: [ ornamented[], results[] ] ]
//edit this with start times according to YOUR local times (ie. as seen in COMM)
window.plugin.restoolsBBWatchReloaded.TIMETABLE = {
wave1: "14:00",
wave2: "14:25",
wave3: "14:50",
wave4: "15:15",
wave5: "15:40",
wave6: "16:05",
wave7: "16:30",
wave8: "16:55" //needed for calculations, put there end of wave 7
wave2: "14:30",
wave3: "15:00",
wave4: "15:30",
wave5: "16:00",
wave6: "16:30",
wave7: "17:00", //needed for calculations, put there end of wave 6
};
@@ -86,7 +85,7 @@ function wrapper(plugin_info)
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', hour12: false });
const currentTimePlus5Minutes = (new Date(currentTimeWithOffset.getTime() + 5 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
const currentTimePlus5Minutes = (new Date(currentTimeWithOffset.getTime() + 10 * 60000)).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
let currentWave = 0;
let battleOver = false;
@@ -121,14 +120,14 @@ function wrapper(plugin_info)
{
let ornaments = portal.options.data.ornaments;
if (ornaments.indexOf("ap1") != -1 || ornaments.indexOf("peBN_RES_WINNER") != -1 || ornaments.indexOf("peBN_ENL_WINNER") != -1)
if (ornaments.indexOf("ap1") != -1 || ornaments.indexOf("ap2") != -1 || ornaments.indexOf("ap3") != -1 || ornaments.indexOf("ap1_v") != -1 || ornaments.indexOf("ap2_v") != -1 || ornaments.indexOf("ap3_v") != -1 || ornaments.indexOf("peBN_RES_WINNER-60") != -1 || ornaments.indexOf("peBN_ENL_WINNER-60") != -1)
{
let portalUpload = {
Guid: portal.options.guid,
IsOrnamented: (ornaments.indexOf("ap1") != -1),
IsVolatile: (ornaments.indexOf("ap1_v") != -1),
IsWinnerRes: (ornaments.indexOf("peBN_RES_WINNER") != -1),
IsWinnerEnl: (ornaments.indexOf("peBN_ENL_WINNER") != -1),
IsOrnamented: (ornaments.indexOf("ap1") != -1 || ornaments.indexOf("ap1_v") != -1 || ornaments.indexOf("ap2") != -1 || ornaments.indexOf("ap2_v") != -1 || ornaments.indexOf("ap3") != -1 || ornaments.indexOf("ap3_v") != -1),
IsVolatile: (ornaments.indexOf("ap1_v") != -1 ||ornaments.indexOf("ap2_v") != -1||ornaments.indexOf("ap3_v") != -1),
IsWinnerRes: (ornaments.indexOf("peBN_RES_WINNER-60") != -1),
IsWinnerEnl: (ornaments.indexOf("peBN_ENL_WINNER-60") != -1),
IsBeaconActive: (ornaments.indexOf("peBB_BATTLE_RARE") != -1),
Beacons: ornaments.join(','),
};
@@ -165,31 +164,35 @@ function wrapper(plugin_info)
//this should record all ornamented portals in each wave.
//plugin considers 5-minute-window at the end of each wave (or before start of the next one) as window where to check for BBs results
// = records ornamented portals to another array
if(portal.IsOrnamented) {
if (!(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][waveBattleOver].find((obj) => obj.Guid === portal.Guid))) {
portalsToBeAdded.push(portal);
}
}
//if ornaments disappear too quickly, it is needed to add 2nd check
//has the portal winners beacon?
//if yes, was it ornamented?
if(portal.IsWinnerRes || portal.IsWinnerEnl) {
//check if portal wasnt already added in previous waves
if (!(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][waveBattleOver].find((obj) => obj.Guid === portal.Guid))) {
//check if portal isn't already in portalsToBeAdded
if (!(portalsToBeAdded.find((obj) => obj.Guid === portal.Guid))) {
//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);
}
if (!waveBattleOver) {
if(portal.IsOrnamented) {
if (!(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][0].find((obj) => obj.Guid === portal.Guid))) {
portalsToBeAdded.push(portal);
}
}
}
else { //battle over
//if ornaments disappear too quickly, it is needed to add 2nd check
//has the portal winners beacon?
//if yes, was it ornamented?
if(portal.IsWinnerRes || portal.IsWinnerEnl) {
//check if portal wasnt already added in previous waves
if (!(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][1].find((obj) => obj.Guid === portal.Guid))) {
//check if portal isn't already in portalsToBeAdded
if (!(portalsToBeAdded.find((obj) => obj.Guid === portal.Guid))) {
//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);
}
}
}
}
}
}
window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][waveBattleOver] = window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS[waveNo][waveBattleOver].concat(portalsToBeAdded);
window.plugin.restoolsBBWatchReloaded.saveStorage(window.plugin.restoolsBBWatchReloaded.WAVE_PORTALS);
@@ -206,15 +209,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 +239,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,
@@ -320,16 +331,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>