Guest User

Untitled

a guest
Apr 1st, 2014
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CME.simulateBuy = function(object, statistic) {
  2.  
  3.     // Store initial state
  4.     ////////////////////////////////////////////////////////////////////
  5.  
  6.     // Don't simulate if this is an upgrade that has been bought already
  7.     if(object.getType() === 'upgrade' && object.bought > 0) {
  8.         return 0;
  9.     }
  10.  
  11.     // Don't simulate seasonal upgrades or Elder pledge/Covenant
  12.     var doNotSimulate = [74, 84, 85, 181, 182, 183, 184, 185];
  13.     if(doNotSimulate.indexOf(object.id) !== -1) {
  14.         return 0;
  15.     }
  16.  
  17.     // Disable some native methods
  18.     var swapped = {
  19.             SetResearch : Game.SetResearch,
  20.             Popup       : Game.Popup,
  21.             Win         : Game.Win,
  22.             Unlock      : Game.Unlock,
  23.             Collect     : Game.CollectWrinklers
  24.         },
  25.         stored = {
  26.             seasonUses       : Game.seasonUses,
  27.             cpsSucked        : Game.cpsSucked,
  28.             globalCpsMult    : Game.globalCpsMult,
  29.             cookiesPs        : Game.cookiesPs,
  30.             computedMouseCps : Game.computedMouseCps,
  31.             pledges          : Game.pledges,
  32.             elderWrath       : Game.elderWrath
  33.         },
  34.         income;
  35.  
  36.     Game.SetResearch      = function() {};
  37.     Game.Popup            = function() {};
  38.     Game.Win              = function() {};
  39.     Game.Unlock           = function() {};
  40.     Game.CollectWrinklers = function() {};
  41.  
  42.     // Simulate buy and store result
  43.     ////////////////////////////////////////////////////////////////////
  44.  
  45.     // Simulate buy and store statistic
  46.     object.simulateToggle(true);
  47.     Game.CalculateGains();
  48.     income = Game[statistic];
  49.  
  50.     // Restore initial state
  51.     ////////////////////////////////////////////////////////////////////
  52.  
  53.     // Reverse buy
  54.     object.simulateToggle(false);
  55.     Game.seasonUses       = stored.seasonUses;
  56.     Game.cpsSucked        = stored.cpsSucked;
  57.     Game.globalCpsMult    = stored.globalCpsMult;
  58.     Game.cookiesPs        = stored.cookiesPs;
  59.     Game.computedMouseCps = stored.computedMouseCps;
  60.     Game.pledges          = stored.pledges;
  61.     Game.elderWrath       = stored.elderWrath;
  62.  
  63.     // Restore native methods
  64.     Game.SetResearch      = swapped.SetResearch;
  65.     Game.Popup            = swapped.Popup;
  66.     Game.Win              = swapped.Win;
  67.     Game.Unlock           = swapped.Unlock;
  68.     Game.CollectWrinklers = swapped.Collect;
  69.  
  70.     return income - Game[statistic];
  71. };
Advertisement
Add Comment
Please, Sign In to add comment