Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CME.simulateBuy = function(object, statistic) {
- // Store initial state
- ////////////////////////////////////////////////////////////////////
- // Don't simulate if this is an upgrade that has been bought already
- if(object.getType() === 'upgrade' && object.bought > 0) {
- return 0;
- }
- // Don't simulate seasonal upgrades or Elder pledge/Covenant
- var doNotSimulate = [74, 84, 85, 181, 182, 183, 184, 185];
- if(doNotSimulate.indexOf(object.id) !== -1) {
- return 0;
- }
- // Disable some native methods
- var swapped = {
- SetResearch : Game.SetResearch,
- Popup : Game.Popup,
- Win : Game.Win,
- Unlock : Game.Unlock,
- Collect : Game.CollectWrinklers
- },
- stored = {
- seasonUses : Game.seasonUses,
- cpsSucked : Game.cpsSucked,
- globalCpsMult : Game.globalCpsMult,
- cookiesPs : Game.cookiesPs,
- computedMouseCps : Game.computedMouseCps,
- pledges : Game.pledges,
- elderWrath : Game.elderWrath
- },
- income;
- Game.SetResearch = function() {};
- Game.Popup = function() {};
- Game.Win = function() {};
- Game.Unlock = function() {};
- Game.CollectWrinklers = function() {};
- // Simulate buy and store result
- ////////////////////////////////////////////////////////////////////
- // Simulate buy and store statistic
- object.simulateToggle(true);
- Game.CalculateGains();
- income = Game[statistic];
- // Restore initial state
- ////////////////////////////////////////////////////////////////////
- // Reverse buy
- object.simulateToggle(false);
- Game.seasonUses = stored.seasonUses;
- Game.cpsSucked = stored.cpsSucked;
- Game.globalCpsMult = stored.globalCpsMult;
- Game.cookiesPs = stored.cookiesPs;
- Game.computedMouseCps = stored.computedMouseCps;
- Game.pledges = stored.pledges;
- Game.elderWrath = stored.elderWrath;
- // Restore native methods
- Game.SetResearch = swapped.SetResearch;
- Game.Popup = swapped.Popup;
- Game.Win = swapped.Win;
- Game.Unlock = swapped.Unlock;
- Game.CollectWrinklers = swapped.Collect;
- return income - Game[statistic];
- };
Advertisement
Add Comment
Please, Sign In to add comment