Advertisement
Guest User

Cookie Clicker Garden Tool

a guest
Oct 16th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(global) {
  2.   /* for setting */
  3.   var refleshInterval = 1000;
  4.   /* internal variables */
  5.   var randCounter = 0;
  6.   var M = (Game.Objects['Wizard tower'] || Game.ObjectsById[7]).minigame;
  7.   var localMath = Object.create(Math);
  8.   /* functions */
  9.   var choose = function(arr) {
  10.     return arr[localMath.floor(localMath.random() * arr.length)];
  11.   };
  12.   var succeeds = function(spell, failChanceMax = 0, goldenCookies = 0) {
  13.     var failChance = Math.max(M.getFailChance(spell) + 0.15 * goldenCookies, failChanceMax);
  14.     return !spell.fail || localMath.random() < 1 - failChance;
  15.   };
  16.   var gamble = {
  17.     win: function() {
  18.       var selfCost = M.getSpellCost(M.spells['gambler\'s fever dream']);
  19.       var spells = [];
  20.       for (var s in M.spells) {
  21.         if (s != 'gambler\'s fever dream' && M.getSpellCost(M.spells[s]) * 0.5 <= M.magic - selfCost) {
  22.           spells.push(M.spells[s]);
  23.         }
  24.       }
  25.       if (spells.length == 0) {
  26.         return ('no magics can cast');
  27.       }
  28.       var selected = choose(spells);
  29.       var result = '';
  30.       localMath.seedrandom(Game.seed + '/' + (M.spellsCastTotal + 1));
  31.       if (selected.name == 'Force the Hand of Fate') {
  32.           result = succeeds(selected, 0.5) ? hand.win(randCounter) : hand.fail(randCounter);
  33.           return 'will cast <b>Force the Hand of Fate</b> and ' + result;
  34.       } else {
  35.           result = succeeds(selected, 0.5) ? 'win' : 'fail';
  36.           return 'will cast <b>' + selected.name + '</b> and <b>' + result + '</b>';
  37.       }
  38.     }
  39.   };
  40.   var hand = {
  41.     win: function(cycle) {
  42.       /* by shimmer.initFunc */
  43.       localMath.random();
  44.       localMath.random();
  45.       /* by PlaySound or season shimmer */
  46.       for (i = 0; i < cycle; i++) {
  47.         localMath.random();
  48.       }
  49.       var choices = [];
  50.       choices.push('Frenzy', 'Lucky');
  51.       if (!Game.hasBuff('Dragonflight')) {
  52.         choices.push('Click frenzy');
  53.       }
  54.       if (localMath.random() < 0.1) {
  55.         choices.push('Cookie storm', 'Cookie storm', 'Blab');
  56.       }
  57.       if (Game.BuildingsOwned >= 10 && localMath.random() < 0.25) {
  58.         choices.push('Building special');
  59.       }
  60.       if (localMath.random() < 0.15) {
  61.         choices = ['Cookie storm drop'];
  62.       }
  63.       if (localMath.random() < 0.0001) {
  64.         choices.push('Sweet');
  65.       }
  66.       return choose(choices);
  67.     },
  68.     fail: function(cycle) {
  69.       /* by shimmer.initFunc */
  70.       localMath.random();
  71.       localMath.random();
  72.       /* by PlaySound or season */
  73.       for (var i = 0; i < cycle; i++) {
  74.         localMath.random();
  75.       }
  76.       var choices = [];
  77.       choices.push('Clot', 'Ruin');
  78.       if (localMath.random() < 0.1) {
  79.         choices.push('Cursed finger', 'Elder frenzy');
  80.       }
  81.       if (localMath.random() < 0.003) {
  82.         choices.push('Sweet');
  83.       }
  84.       if (localMath.random() < 0.1) {
  85.         choices = ['Blab'];
  86.       }
  87.       return choose(choices);
  88.     }
  89.   };
  90.   var testSpell = function() {
  91.     var ret = '';
  92.     var spellTotal = M.spellsCastTotal;
  93.     randCounter = 0;
  94.     if (Game.season == 'easter' || Game.season == 'valentines') {
  95.       randCounter++;
  96.     }
  97.     if (Game.chimeType == 1 && Game.ascensionMode != 1) {
  98.       randCounter++;
  99.     }
  100.     /* Gamblers Fever Dream */
  101.     ret += '<p><h3>Gamblers Dream</h3>';
  102.     localMath.seedrandom(Game.seed + '/' + spellTotal);
  103.     spellResult = succeeds(gamble) ? gamble.win() : gamble.fail();
  104.     ret += '<h5 style="padding-left:1em">' + spellResult + '</h5></p>';
  105.     /* Hand of Fate */
  106.     ret += '<p><h3>Hand of Fate</h3><table style="margin:auto;width:90%">';
  107.     ret += '<thead><tr><th></th><th>0 change</th><th>1 change</th><th>2 change</th></tr></thead><tbody>';
  108.     var nextBS = false;
  109.     for (var i = 0; i < 10; i++) {
  110.       ret += '<tr><td style="padding:1px 5px 0px;text-align:right;">' + (i + 1) + '</td>';
  111.       for (var j = 0; j < 3; j++) {
  112.         localMath.seedrandom(Game.seed + '/' + (spellTotal + i));
  113.         var spellSucceed = succeeds(hand);
  114.         var spellResult = spellSucceed ? hand.win(j) : hand.fail(j);
  115.         localMath.seedrandom(Game.seed + '/' + (spellTotal + i));
  116.         ret += '<td style="';
  117.         if (spellSucceed) {
  118.           if (spellResult == 'Building special' || spellResult == 'Sweet') {
  119.             ret += succeeds(hand, 0, 1) ? 'color:cyan;' : 'color:magenta;';
  120.           } else if (!succeeds(hand, 0, 1)) {
  121.             ret += 'color:orange;';
  122.           }
  123.         } else {
  124.           ret += 'color:red;';
  125.         }
  126.         if (randCounter == j) {
  127.           ret += 'font-weight:bold;">' + spellResult + '</td>';
  128.         } else {
  129.           ret += '">' + spellResult + '</td>';
  130.         }
  131.         nextBS |= i == 0 && (spellResult == 'Building special' || spellResult == 'Sweet');
  132.       }
  133.       ret += '</tr>';
  134.     }
  135.     ret += '</tbody></table></p>';
  136.     Math.seedrandom();
  137.     if (M.magic == M.magicM && !nextBS) {
  138.       document.querySelector('#grimoireSpell4').click();
  139.     }
  140.     return ret;
  141.   };
  142.   /* panel creation */
  143.   var panel = document.createElement('div');
  144.   panel.setAttribute('id', 'grimoireNext');
  145.   panel.setAttribute('class', 'framed note');
  146.   panel.style.cssText = 'margin:3px auto; width:80%';
  147.   document.getElementById('grimoireContent').appendChild(panel);
  148.   panel.innerHTML = testSpell();
  149.   /* auto refresh */
  150.   setInterval(function() {
  151.     panel.innerHTML = testSpell();
  152.   }, refleshInterval);
  153. })(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement