Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let ships;
- let counts, maxes, buildAmount, buildCost, incomes, nextMultiplier, incEach, incomeChange, buildEfficency = [];
- let removeStrings = ["Build +", "/", ",", "x "];
- let newCount, newIncome;
- ele = document.createElement('div');
- ele.id = "myInfo";
- document.getElementById("__nuxt").appendChild(ele);
- function cleanUp(str){
- removeStrings.forEach(rString => {
- str = str.replace(rString, "");
- });
- return str;
- }
- function round(n) {
- n = Math.floor(n*1000)/1000;
- return n;
- }
- function formatSeconds(n){
- rawminutes = Math.floor(n/60);
- hours = Math.floor(n/3600);
- minutes = Math.floor(n%3600/60);
- seconds = Math.floor(n%3600%60);
- return hours + ":" + minutes + ":" + seconds;
- }
- function updateStats(){
- currentIncome = document.getElementById("wrapper").children[0].children[0].children[0].children[2].children[0].children[1].children[1].innerText.replace("e","").split(" ");
- currentCredits = document.getElementById("wrapper").children[0].children[0].children[0].children[2].children[0].children[0].children[1].innerText.replace("e","").split(" ");
- //console.log(currentIncome);
- //console.log(currentCredits);
- shipData = [];
- str = '<div style="position:fixed; right: 5px; top: 35px; background-color: black; width: 15%;"><table><tr> <td>SHIP</td> <td>CHANGE</td> <td>EFFICIENCY</td> <td>~NEW INC</td> </tr>';
- for (i=0; i <= 9; i++) {
- obj = {}
- obj.name = ships.children[i].children[0].children[0].children[1].children[0].children[0].children[0].children[0].innerText;
- obj.count = Number(cleanUp(ships.children[i].children[0].children[0].children[1].children[0].children[0].children[1].children[1].innerText));
- obj.max = Number(cleanUp(ships.children[i].children[0].children[0].children[1].children[0].children[0].children[1].children[2].innerText));
- obj.buildAmount = Number(cleanUp(ships.children[i].children[0].children[0].children[2].children[0].children[0].innerText));
- obj.buildCost = (ships.children[i].children[0].children[0].children[2].children[0].children[1].children[1].innerText.replace("e","").split(" "));
- obj.income = (ships.children[i].children[0].children[0].children[1].children[1].children[0].children[0].children[1].innerText.replace("e","").split(" "));
- obj.nextMultiplier = Number(cleanUp(ships.children[i].children[0].children[0].children[0].children[1].children[0].children[2].children[0].innerText));
- newCount = obj.buildAmount + obj.count;
- obj.incEach = [];
- obj.incEach[0] = obj.income[0]/obj.count;
- if (newCount >= obj.max) {
- obj.incEach[1] = obj.incEach[0] * obj.nextMultiplier;
- //console.log("Multiplier applied for " + obj.name);
- } else {
- obj.incEach[1] = obj.incEach[0];
- }
- //calculate change
- obj.incomeChange = ((obj.incEach[1] - obj.incEach[0]) * obj.count) + (obj.buildAmount * obj.incEach[1]);
- //normalize to same exponential
- while (obj.buildCost[1] > obj.income[1]) {
- obj.buildCost[1] -= 3;
- obj.buildCost[0] = obj.buildCost[0]*1000;
- }
- while (obj.buildCost[1] < obj.income[1]){
- obj.buildCost[1] += 3;
- obj.buildCost[0] = obj.buildCost[0]/1000;
- }
- obj.buildEfficency = obj.incomeChange / obj.buildCost[0];
- obj.buildEfficencyE = 0;
- while (obj.buildEfficency >= 1000) {
- obj.buildEfficencyE += 3;
- obj.buildEfficency = obj.buildEfficency/1000;
- }
- while (obj.buildEfficency < 1){
- obj.buildEfficencyE -= 3;
- obj.buildEfficency = obj.buildEfficency*1000;
- }
- while (currentCredits[1] > obj.income[1]) {
- currentCredits[1] -= 3;
- currentCredits[0] = currentCredits[0]*1000;
- }
- while (currentCredits[1] < obj.income[1]){
- currentCredits[1] += 3;
- currentCredits[0] = currentCredits[0]/1000;
- }
- while (currentIncome[1] > obj.income[1]) {
- currentIncome[1] -= 3;
- currentIncome[0] = currentIncome[0]*1000;
- }
- while (currentIncome[1] < obj.income[1]){
- currentIncome[1] += 3;
- currentIncome[0] = currentIncome[0]/1000;
- }
- neededCreds = obj.buildCost[0] - currentCredits[0];
- if (neededCreds > 0) {
- obj.neededCreds = neededCreds;
- obj.eta = (neededCreds[0]/currentIncome[0]) / 5;
- } else {
- obj.neededCreds = 0;
- obj.eta = 0;
- }
- shipData.push(obj);
- //console.log(obj.name + " Increase: " + round(obj.incomeChange) + " E" +obj.income[1] + " Efficiency: " + round(obj.buildEfficency) + " New Value: " + round(newCount * obj.incEach[1]) + " E" + obj.income[1]);
- tstring = "<tr> <td>%1</td> <td>%2</td> <td>%3</td> <td>%4</td> <td>%5</td> </tr>";
- tstring = tstring.replace("%1",obj.name).replace("%2",round(obj.incomeChange) + " E" +obj.income[1]).replace("%3",round(obj.buildEfficency) + " E" + obj.buildEfficencyE).replace("%4",round(newCount * obj.incEach[1]) + " E" + obj.income[1]).replace("%5",formatSeconds(obj.eta));
- str += tstring;
- }
- str += "</table></div>";
- ele.innerHTML = str;
- console.log(shipData);
- }
- var loaded = false;
- var autoClickerLoop = setInterval(function () {
- element = document.getElementById("ships");
- if(typeof(element) != 'undefined' && element != null){
- if (loaded != true) {
- ships = document.getElementById("ships").children[0].children[2].children[0];
- loaded = true;
- }
- updateStats();
- }
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment