Skip to content

Commit

Permalink
Show more accurate time remaining in build queue
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Nov 26, 2023
1 parent 07e91c0 commit 3a7d9a7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion evolve/main.js

Large diffs are not rendered by default.

66 changes: 53 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9705,32 +9705,72 @@ function midLoop(){
checkAchievements();
}

if (global.tech['queue'] && global.queue.display){
if (global.tech.queue && global.queue.display) {
let idx = -1;
let c_action = false;
let stop = false;
let deepScan = ['space','interstellar','galaxy','portal','tauceti'];
let time = 0;
let spent = { t: {t:0,rt:0}, r: {}, rr: {}, id: {}};
let arpa = false;
for (let i=0; i<global.queue.queue.length; i++){
if (global.settings.qAny){
spent = { t: {t:0,rt:0}, r: {}, rr: {}, id: {}};
time = 0;
}
let struct = global.queue.queue[i];

let t_action = false;
const getAction = function (id) {
const struct = global.queue.queue[id];
if (deepScan.includes(struct.action)){
for (let region in actions[struct.action]) {
for (const region in actions[struct.action]) {
if (actions[struct.action][region][struct.type]){
t_action = actions[struct.action][region][struct.type];
break;
return actions[struct.action][region][struct.type];
}
}
}
else {
t_action = actions[struct.action][struct.type];
return actions[struct.action][struct.type];
};

for (let i = 0; i < global.queue.queue.length; i++) {
const struct = global.queue.queue[i];
const t_action = getAction(i);

if (global.settings.qAny) {
spent = {t: {t: 0, rt: 0}, r: {}, rr: {}, id: {}};

const queueItemsProcessed = [];
const spentClone = function () {
return JSON.parse(JSON.stringify(spent));
};

while (queueItemsProcessed.length < global.queue.queue.length) {
const otherItemsTimes = {};
for (let j = 0; j < global.queue.queue.length; j++) {
if (i === j) { continue; }
if (queueItemsProcessed.includes(j)) { continue; }
otherItemsTimes[j] = timeCheck(getAction(j), spentClone());
}

if (!Object.keys(otherItemsTimes).length) {
break;
}

const thisItemTime = timeCheck(t_action, spentClone());
const fastestItem = Object.keys(otherItemsTimes).reduce(function (acc, id) {
const time = otherItemsTimes[id];
if (time > thisItemTime) { return acc; }
id = parseInt(id, 10);
if (time === thisItemTime && id > i) { return acc; }
if (acc.id === -1 || time < acc.time) {
return { id, time };
}
return acc;
}, { id: -1 });

if (fastestItem.id === -1) {
break;
}

timeCheck(getAction(fastestItem.id), spent);
queueItemsProcessed.push(fastestItem.id);
}

time = spent.t.t;
}

if (struct.action === 'arpa'){
Expand Down

0 comments on commit 3a7d9a7

Please sign in to comment.