Skip to content

Commit

Permalink
Merge pull request #748 from Aktanusa/dev
Browse files Browse the repository at this point in the history
Master to version 2.031.7
  • Loading branch information
DanielNoord authored Apr 4, 2021
2 parents f7c4e23 + cba8eb7 commit ca5d9ba
Show file tree
Hide file tree
Showing 106 changed files with 3,199 additions and 1,887 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

15 changes: 11 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ module.exports = {
b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly',
BeautifyAll: 'readonly',
PlaySound: 'readonly',
},
extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 12,
},
ignorePatterns: ['*CookieMonster*.js', 'dist/*', 'node_modules/*'],
rules: {
'import/no-mutable-exports': 'off',
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-new-func': 'off',
'func-names': 'off',
'no-console': 'off',
'no-alert': 'off',
'no-restricted-globals': 'off',
'prefer-destructuring': ['error', { object: true, array: false }],
'max-len': [
1,
{
code: 100,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
},
};
3 changes: 1 addition & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion CookieMonster.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CookieMonster.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CookieMonster.js.map

Large diffs are not rendered by default.

1,873 changes: 1,430 additions & 443 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cookiemonster-mod",
"version": "2.031.6",
"version": "2.031.7",
"description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface – although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.",
"main": "CookieMonster.js",
"keywords": [
Expand Down
19 changes: 13 additions & 6 deletions src/Cache/CPS/AverageQueue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import {
ChoEggDiff,
Expand Down Expand Up @@ -50,16 +49,24 @@ export class CMAvgQueue {
}
return ret / time;
}

calcSum(timePeriod) {
let time = timePeriod;
if (time > this.maxLength) time = this.maxLength;
if (time > this.queue.length) time = this.queue.length;
if (time === 0) return 0;
return this.queue.slice(-time).reduce((a, b) => a + b, 0);
}
}

/**
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
* Called by CM.Cache.InitCache()
*/
export function InitCookiesDiff() {
CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]);
CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]); // eslint-disable-line no-unused-vars
}
7 changes: 3 additions & 4 deletions src/Cache/CPS/CPS.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-unused-vars */

import { CMOptions } from '../../Config/VariablesAndData';
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import {
Expand Down Expand Up @@ -41,7 +39,7 @@ export default function CacheAvgCPS() {
if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CacheSellForChoEgg;
if (Game.cpsSucked > 0) choEggTotal += CacheWrinklersTotal;
CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal); // eslint-disable-line no-unused-vars
choEggTotal *= 0.05;

// Add recent gains to AvgQueue's
Expand Down Expand Up @@ -89,8 +87,9 @@ export default function CacheAvgCPS() {
CacheAverageGainBank +
CacheAverageGainWrink +
(choEgg ? CacheAverageGainChoEgg : 0);
} else CacheAvgCPSWithChoEgg = CacheAverageCPS;
} else CacheAvgCPSWithChoEgg = CacheAverageCPS; // eslint-disable-line no-unused-vars

// eslint-disable-next-line no-unused-vars
CacheAverageClicks = ClicksDiff.calcAverage(
ClickTimes[CMOptions.AvgClicksHist],
);
Expand Down
5 changes: 2 additions & 3 deletions src/Cache/CPS/CurrWrinklerCPS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import { SimObjects } from '../../Sim/VariablesAndData';
import {
CacheCurrWrinklerCount,
Expand All @@ -23,8 +22,8 @@ export default function CacheCurrWrinklerCPS() {
else if (godLvl === 2) godMult *= 1.1;
else if (godLvl === 3) godMult *= 1.05;
}
CacheCurrWrinklerCount = count;
CacheCurrWrinklerCPSMult =
CacheCurrWrinklerCount = count; // eslint-disable-line no-unused-vars
CacheCurrWrinklerCPSMult = // eslint-disable-line no-unused-vars
count *
(count * 0.05 * 1.1) *
(Game.Has('Sacrilegious corruption') * 0.05 + 1) *
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/CPS/NoGoldSwitchCPS.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import CalcNoGoldSwitchCPS from '../../Sim/Calculations/NoGoldenSwitchCalc';
import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';

Expand All @@ -10,5 +9,5 @@ import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';
export default function CacheNoGoldSwitchCPS() {
if (Game.Has('Golden switch [off]')) {
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs;
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs; // eslint-disable-line no-unused-vars
}
3 changes: 1 addition & 2 deletions src/Cache/CPS/SellChoEgg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import SellBuildingsForChoEgg from '../../Sim/SimulationEvents/SellBuildingForChoEgg';
import { CacheSellForChoEgg } from '../VariablesAndData';

Expand All @@ -21,5 +20,5 @@ export default function CacheSellAllForChoEgg() {
}
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += SellBuildingsForChoEgg();
CacheSellForChoEgg = sellTotal;
CacheSellForChoEgg = sellTotal; // eslint-disable-line no-unused-vars
}
13 changes: 10 additions & 3 deletions src/Cache/CacheInit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-unused-vars */
import { ClickTimes } from '../Disp/VariablesAndData';
import { CMAvgQueue, InitCookiesDiff } from './CPS/AverageQueue';
import CacheAvgCPS from './CPS/CPS';
import CacheDragonAuras from './Dragon/CacheDragonAuras';
Expand All @@ -15,7 +15,10 @@ import {
CacheGoldenAndWrathCookiesMults,
CacheStatsCookies,
} from './Stats/Stats';
import { HeavenlyChipsDiff } from './VariablesAndData';
import {
CacheAverageCookiesFromClicks,
HeavenlyChipsDiff,
} from './VariablesAndData';
import CacheWrinklers from './Wrinklers/Wrinklers';

/**
Expand All @@ -30,7 +33,11 @@ export default function InitCache() {
CacheAllMissingUpgrades();
CacheSeasonSpec();
InitCookiesDiff();
HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
/** Used by CM.Cache.CacheHeavenlyChipsPS() */
HeavenlyChipsDiff = new CMAvgQueue(5); // eslint-disable-line no-unused-vars
CacheAverageCookiesFromClicks = new CMAvgQueue( // eslint-disable-line no-unused-vars
ClickTimes[ClickTimes.length - 1] * 20,
);
CacheHeavenlyChipsPS();
CacheAvgCPS();
CacheIncome();
Expand Down
3 changes: 1 addition & 2 deletions src/Cache/CacheLoop.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import { FormatTime } from '../Disp/BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../Disp/HelperFunctions/GetCPS';
import CacheAvgCPS from './CPS/CPS';
Expand Down Expand Up @@ -27,5 +26,5 @@ export default function LoopCache() {
1,
) -
(Game.cookiesEarned + Game.cookiesReset);
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS());
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS()); // eslint-disable-line no-unused-vars
}
5 changes: 2 additions & 3 deletions src/Cache/Dragon/CacheDragonAuras.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable no-unused-vars */
import { CacheDragonAura, CacheDragonAura2 } from '../VariablesAndData';

/**
* This functions caches the currently selected Dragon Auras
*/
export default function CacheDragonAuras() {
CacheDragonAura = Game.dragonAura;
CacheDragonAura2 = Game.dragonAura2;
CacheDragonAura = Game.dragonAura; // eslint-disable-line no-unused-vars
CacheDragonAura2 = Game.dragonAura2; // eslint-disable-line no-unused-vars
}
7 changes: 2 additions & 5 deletions src/Cache/Dragon/Dragon.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/* eslint-disable no-unused-vars */
/** Functions related to the Dragon */

import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import {
CacheCostDragonUpgrade,
CacheDragonAura,
CacheDragonAura2,
CacheLastDragonLevel,
} from '../VariablesAndData';

Expand Down Expand Up @@ -46,7 +43,7 @@ export default function CacheDragonCost() {
cost += price;
SimObjects[target].amount -= 1;
}
CacheCostDragonUpgrade = `Cost to rebuy: ${cost}`;
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`;
}
} else {
let cost = 0;
Expand All @@ -70,7 +67,7 @@ export default function CacheDragonCost() {
cost += price;
SimObjects[target].amount -= 1;
}
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`;
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`; // eslint-disable-line no-unused-vars
});
}
}
Expand Down
23 changes: 11 additions & 12 deletions src/Cache/PP/Building.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-unused-vars */
import { CMOptions } from '../../Config/VariablesAndData';
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { ColorGray } from '../../Disp/VariablesAndData';
import { ColourGray } from '../../Disp/VariablesAndData';
import {
CacheMinPP,
CacheObjects1,
Expand All @@ -17,19 +15,20 @@ import ColourOfPP from './ColourOfPP';
* It saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CacheBuildingsPP()
*/
function CacheColor(target, amount) {
function CacheColour(target, amount) {
Object.keys(target).forEach((i) => {
if (CMOptions.PPRigidelMode && amount === 1) {
target[i].color = ColorGray;
target[i].color = ColourGray; // eslint-disable-line no-param-reassign
return;
}
// eslint-disable-next-line no-param-reassign
target[i].color = ColourOfPP(
target[i],
Game.Objects[i].getSumPrice(amount),
);
// Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (target[i].pp === CachePPArray[j][0]) target[i].color = ColorGray;
if (target[i].pp === CachePPArray[j][0]) target[i].color = ColourGray; // eslint-disable-line no-param-reassign
}
});
}
Expand All @@ -38,11 +37,11 @@ function CachePP(target, amount) {
Object.keys(target).forEach((i) => {
const price = Game.Objects[i].getSumPrice(amount);
if (Game.cookiesPs) {
target[i].pp =
target[i].pp = // eslint-disable-line no-param-reassign
Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs +
price / target[i].bonus;
} else target[i].pp = price / target[i].bonus;
} else target[i].pp = price / target[i].bonus; // eslint-disable-line no-param-reassign
if (!(CMOptions.PPRigidelMode && amount === 1))
CachePPArray.push([target[i].pp, amount]);
});
Expand Down Expand Up @@ -73,9 +72,9 @@ export default function CacheBuildingsPP() {
}
}
}
CacheMinPP = CachePPArray[CMOptions.PPExcludeTop][indexOfMin];
CacheMinPP = CachePPArray[CMOptions.PPExcludeTop][indexOfMin]; // eslint-disable-line no-unused-vars

CacheColor(CacheObjects1, 1);
CacheColor(CacheObjects10, 10);
CacheColor(CacheObjects100, 100);
CacheColour(CacheObjects1, 1);
CacheColour(CacheObjects10, 10);
CacheColour(CacheObjects100, 100);
}
32 changes: 16 additions & 16 deletions src/Cache/PP/ColourOfPP.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CMOptions } from '../../Config/VariablesAndData';
import GetCPS from '../../Disp/HelperFunctions/GetCPS';
import {
ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
ColorYellow,
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColourYellow,
} from '../../Disp/VariablesAndData';
import { CacheMinPP, CachePPArray } from '../VariablesAndData';

Expand All @@ -21,22 +21,22 @@ import { CacheMinPP, CachePPArray } from '../VariablesAndData';
export default function ColourOfPP(me, price) {
let color = '';
// Colour based on PP
if (me.pp <= 0 || me.pp === Infinity) color = ColorGray;
else if (me.pp < CacheMinPP) color = ColorBlue;
else if (me.pp === CacheMinPP) color = ColorGreen;
else if (me.pp < CachePPArray[10][0]) color = ColorYellow;
else if (me.pp < CachePPArray[20][0]) color = ColorOrange;
else if (me.pp > CachePPArray[30][0]) color = ColorRed;
else color = ColorPurple;
if (me.pp <= 0 || me.pp === Infinity) color = ColourGray;
else if (me.pp < CacheMinPP) color = ColourBlue;
else if (me.pp === CacheMinPP) color = ColourGreen;
else if (me.pp < CachePPArray[10][0]) color = ColourYellow;
else if (me.pp < CachePPArray[20][0]) color = ColourOrange;
else if (me.pp < CachePPArray[30][0]) color = ColourRed;
else color = ColourPurple;

// Colour based on price in terms of CPS
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit))
color = ColorBlue;
color = ColourBlue;
}
// Colour based on being able to purchase
if (CMOptions.PPOnlyConsiderBuyable) {
if (price - Game.cookies > 0) color = ColorRed;
if (price - Game.cookies > 0) color = ColourRed;
}
return color;
}
5 changes: 1 addition & 4 deletions src/Cache/PriceAndIncome/PriceAndIncome.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/* eslint-disable no-unused-vars */
/** Section: Functions related to caching income */

import { CMOptions } from '../../Config/VariablesAndData';
import GetCPS from '../../Disp/HelperFunctions/GetCPS';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades';
import {
CacheAverageCPS,
CacheAverageGainBank,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
Expand All @@ -30,7 +27,7 @@ function CacheBuildingIncome(amount) {
result[i] = {};
result[i].bonus = BuyBuildingsBonusIncome(i, amount);
if (amount !== 1) {
CacheDoRemakeBuildPrices = 1;
CacheDoRemakeBuildPrices = 1; // eslint-disable-line no-unused-vars
}
});
return result;
Expand Down
Loading

0 comments on commit ca5d9ba

Please sign in to comment.