Advertisement
Wyvern67

Make Idle Class play itself optimally

Oct 14th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function autoclicky(){
  2.     for (var i=0; i<100; i++) {
  3.         game.stats()[5].add(1);
  4.         game.stats()[6].add(1);
  5.         game.generalStats()[6].val(Date.now());
  6.         var toAdd = game.earnedPerClick.val();
  7.         if (game.isWindfall()) {
  8.             game.stats()[66].add(toAdd);
  9.         }
  10.         game.clickStats()[2].add(toAdd);
  11.         game.addClicks(toAdd);
  12.     }
  13.     setTimeout(autoclicky, 1);
  14. };
  15.  
  16. function investy(){
  17.     document.querySelector('button.investment-submit:nth-child(2)').click();
  18.     var investmentLimit = game.totalSimultaneousInvestmentsAllowed.val();
  19.     document.getElementById('investmentModal').style.display = "none";
  20.     var bd = document.querySelector('.modal-backdrop');
  21.     if (bd) bd.remove();
  22.  
  23.     if (game.activeInvestments === undefined) {
  24.         setTimeout(investy, 1500);
  25.         return;
  26.     }
  27.     for (var i = 0; i < investmentLimit; i++) {
  28.         if (game.activeInvestments()[i] === undefined) {
  29.             break;
  30.         }
  31.         game.activeInvestments()[i].timeRemaining(1);
  32.     }
  33.     setTimeout(function(){
  34.         document.querySelector('button.investment-btn:nth-child(3) > span:nth-child(1)').click();
  35.     }, 1000);
  36.     game.saveGame();
  37.     document.getElementById('investmentModal').style.display = "none";
  38.     setTimeout(investy, 1500);
  39. };
  40.  
  41. function trainy(){
  42.     game.finishAllTrainings();
  43.     game.multiTrain();
  44.     for(var i=0;i<12;i++) {
  45.         game.units()[i].timeRemaining(1);
  46.     }
  47.     game.finishAllTrainings();
  48.     setTimeout(trainy, 100);
  49. }
  50.  
  51. function potentialEarnings(unit) {
  52.     if (unit.num.val() === 0) {
  53.         var baseCPS = (parseFloat(unit.baseClick()) * Math.pow(2, unit.mod.val() + game.stats()[42].val())) * 1;
  54.         var baseMod = baseCPS * (game.stats()[15].val() / 100);
  55.         var quantityMod = (unit.numMod.val() * 1) / 100;
  56.         quantityMod = quantityMod > 1 ? quantityMod : 1;
  57.         return (baseCPS + baseMod) * game.stats()[38].val() * game.cashStats()[7].val() * quantityMod;
  58.     } else {
  59.         return 0;
  60.     }
  61. }
  62.  
  63. function smart_hiring_choice(){
  64.     var max = 0;
  65.     var index = -1;
  66.     var units = game.units();
  67.  
  68.     for (var i=0; i<12; i++) {
  69.         var cash = game.units()[i].cps.val() / game.units()[i].num.val();
  70.         if (cash === 0 || isNaN(cash)) {
  71.             cash = potentialEarnings(units[i]);
  72.         }
  73.         var investment = cash / units[i].price.val();
  74.         if (investment > max) {
  75.             max = investment;
  76.             index = i;
  77.         }
  78.     }
  79.  
  80.     return index;
  81. }
  82.  
  83. function smart_hire(n=1000000000000000000) {
  84.     var borne = Math.min(100, n);
  85.  
  86.     game.buyAllUpgrades()
  87.     var backlog = [0,0,0,0,0,0,0,0,0,0,0,0];
  88.     for (var i = 0; i < borne; i++) {
  89.         var index = smart_hiring_choice();
  90.  
  91.         if (game.units()[index].cantAfford()) {
  92.             console.log("Next to buy: " + game.units()[index].name());
  93.             break;
  94.         } else {
  95.             game.units()[index].buy(1);
  96.  
  97.             backlog[index]++;
  98.             console.log("Hired " + game.units()[index].name());
  99.         }
  100.     }
  101.  
  102.     n -= 100;
  103.     if (n > 0) {
  104.         setTimeout(function(){smart_hire(n-100)}, 250);
  105.     }
  106. }
  107.  
  108.  
  109. function maily() {
  110.     var emails = game.mail();
  111.     if (emails.length > 0){
  112.         for (var i = emails.length - 1; i >= 0; i--) {
  113.             var from = game.mail()[i].from;
  114.             var text = from + ", ROI B2B B2C KPI SEO EOD CTR BYOD ASAP brand sales agile pivot ideate client profit stocks shares market EBITDA action synergy clients profits disrupt startup mission hacking startup unicorn revenue downsize ideation innovate dynamism holistic paradigm branding customer leverage gamified overhead bandwidth customers evergreen analytics outsource marketing executive valuation marketing disruptive innovation millennial wheelhouse hyperlocal investment investment downsizing wunderkind actionable influencer outsourcing investments deliverable outsourcing stakeholders optimization shareholders gamification globalization advertainment. Thanks. Regards,".repeat(5000);
  115.             game.mail()[i].inputText(text);
  116.             game.mail()[i].respond();
  117.         }
  118.     }
  119.  
  120.     setTimeout(maily, 1000);
  121. }
  122.  
  123. autoclicky();
  124. maily();
  125. smart_hire();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement