Merge pull request #743 from DanielNoord/clickscps
Show cookies from clicks in stats
This commit is contained in:
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
1873
package-lock.json
generated
1873
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/* 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';
|
||||
@@ -15,7 +16,10 @@ import {
|
||||
CacheGoldenAndWrathCookiesMults,
|
||||
CacheStatsCookies,
|
||||
} from './Stats/Stats';
|
||||
import { HeavenlyChipsDiff } from './VariablesAndData';
|
||||
import {
|
||||
CacheAverageCookiesFromClicks,
|
||||
HeavenlyChipsDiff,
|
||||
} from './VariablesAndData';
|
||||
import CacheWrinklers from './Wrinklers/Wrinklers';
|
||||
|
||||
/**
|
||||
@@ -31,6 +35,9 @@ export default function InitCache() {
|
||||
CacheSeasonSpec();
|
||||
InitCookiesDiff();
|
||||
HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
|
||||
CacheAverageCookiesFromClicks = new CMAvgQueue(
|
||||
ClickTimes[ClickTimes.length - 1] * 20,
|
||||
);
|
||||
CacheHeavenlyChipsPS();
|
||||
CacheAvgCPS();
|
||||
CacheIncome();
|
||||
|
||||
@@ -39,6 +39,7 @@ export let CacheCurrWrinklerCount = 0;
|
||||
export let CacheUpgrades = {};
|
||||
|
||||
export let CacheAverageClicks = {};
|
||||
export let CacheAverageCookiesFromClicks;
|
||||
|
||||
export let CacheMissingUpgrades = {};
|
||||
export let CacheMissingUpgradesPrestige = {};
|
||||
|
||||
@@ -2,7 +2,7 @@ import ConfigDefault from '../../Data/SettingsDefault';
|
||||
import ConfigData from '../../Data/SettingsData';
|
||||
import { CMOptions } from '../VariablesAndData';
|
||||
import save from '../../InitSaveLoad/save';
|
||||
import CMLoop from '../../Main/Loop';
|
||||
import CMLoopHook from '../../Main/LoopHook';
|
||||
import UpdateColours from '../../Disp/HelperFunctions/UpdateColours';
|
||||
|
||||
/** Functions related to saving, loading and restoring all settings */
|
||||
@@ -68,7 +68,7 @@ export function LoadConfig(settings) {
|
||||
}
|
||||
});
|
||||
if (mod) SaveConfig();
|
||||
CMLoop(); // Do loop once
|
||||
CMLoopHook(); // Do loop once
|
||||
Object.keys(ConfigDefault).forEach((i) => {
|
||||
if (i !== 'Header' && typeof ConfigData[i].func !== 'undefined') {
|
||||
ConfigData[i].func();
|
||||
|
||||
@@ -389,7 +389,7 @@ const Config = {
|
||||
'Tooltip',
|
||||
[
|
||||
'Building/upgrade tooltip information OFF',
|
||||
'Building/upgrade tooltip information ON',
|
||||
'Building/upgrade tooltip information ON',
|
||||
],
|
||||
'Extra information in building/upgrade tooltips',
|
||||
true,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { CMOptions } from '../../../Config/VariablesAndData';
|
||||
|
||||
import {
|
||||
CacheAverageClicks,
|
||||
CacheAverageCookiesFromClicks,
|
||||
CacheWrinklersFattest,
|
||||
CacheWrinklersNormal,
|
||||
CacheWrinklersTotal,
|
||||
@@ -114,7 +115,7 @@ export default function AddMenuStats(title) {
|
||||
stats.appendChild(
|
||||
CreateElements.StatsListing(
|
||||
'basic',
|
||||
`Average Cookies Per Second (Past ${
|
||||
`Average cookies per second (past ${
|
||||
CookieTimes[CMOptions.AvgCPSHist] < 60
|
||||
? `${CookieTimes[CMOptions.AvgCPSHist]} seconds`
|
||||
: CookieTimes[CMOptions.AvgCPSHist] / 60 +
|
||||
@@ -126,12 +127,27 @@ export default function AddMenuStats(title) {
|
||||
stats.appendChild(
|
||||
CreateElements.StatsListing(
|
||||
'basic',
|
||||
`Average Cookie Clicks Per Second (Past ${
|
||||
`Average cookie clicks per second (past ${
|
||||
ClickTimes[CMOptions.AvgClicksHist]
|
||||
}${CMOptions.AvgClicksHist === 0 ? ' second' : ' seconds'})`,
|
||||
document.createTextNode(Beautify(CacheAverageClicks, 1)),
|
||||
),
|
||||
);
|
||||
stats.appendChild(
|
||||
CreateElements.StatsListing(
|
||||
'basic',
|
||||
`Cookies from clicking (past ${ClickTimes[CMOptions.AvgClicksHist]}${
|
||||
CMOptions.AvgClicksHist === 0 ? ' second' : ' seconds'
|
||||
})`,
|
||||
document.createTextNode(
|
||||
Beautify(
|
||||
CacheAverageCookiesFromClicks.calcSum(
|
||||
CacheAverageClicks * ClickTimes[CMOptions.AvgClicksHist],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (Game.Has('Fortune cookies')) {
|
||||
const fortunes = [];
|
||||
Object.keys(GameData.Fortunes).forEach((i) => {
|
||||
@@ -152,7 +168,7 @@ export default function AddMenuStats(title) {
|
||||
stats.appendChild(
|
||||
CreateElements.StatsListing(
|
||||
'basic',
|
||||
'Missed Golden Cookies',
|
||||
'Missed golden cookies',
|
||||
document.createTextNode(Beautify(Game.missedGoldenClicks)),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -83,7 +83,7 @@ export function LuckySection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Lucky!" Cookies Required',
|
||||
'"Lucky!" cookies required',
|
||||
luckyReqFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -113,7 +113,7 @@ export function LuckySection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Lucky!" Cookies Required (Frenzy)',
|
||||
'"Lucky!" cookies required (frenzy)',
|
||||
luckyReqFrenFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -130,7 +130,7 @@ export function LuckySection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
`"Lucky!" Reward (MAX)${luckySplit ? ' (Golden / Wrath)' : ''}`,
|
||||
`"Lucky!" reward (max)${luckySplit ? ' (golden / wrath)' : ''}`,
|
||||
luckyRewardMaxSpan,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -145,7 +145,7 @@ export function LuckySection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
`"Lucky!" Reward (MAX) (Frenzy)${luckySplit ? ' (Golden / Wrath)' : ''}`,
|
||||
`"Lucky!" reward (max) (frenzy)${luckySplit ? ' (golden / wrath)' : ''}`,
|
||||
luckyRewardFrenzyMaxSpan,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -165,7 +165,7 @@ export function LuckySection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
`"Lucky!" Reward (CUR)${luckySplit ? ' (Golden / Wrath)' : ''}`,
|
||||
`"Lucky!" reward (cur)${luckySplit ? ' (golden / wrath)' : ''}`,
|
||||
luckyCurSpan,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -211,7 +211,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Cookies Required',
|
||||
'"Chain" cookies required',
|
||||
chainReqFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -242,7 +242,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Cookies Required (Wrath)',
|
||||
'"Chain" cookies required (Wrath)',
|
||||
chainWrathReqFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -273,7 +273,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Cookies Required (Frenzy)',
|
||||
'"Chain" cookies required (Frenzy)',
|
||||
chainReqFrenFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -305,7 +305,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Cookies Required (Frenzy) (Wrath)',
|
||||
'"Chain" cookies required (frenzy) (Wrath)',
|
||||
chainWrathReqFrenFrag,
|
||||
goldCookTooltip,
|
||||
),
|
||||
@@ -314,7 +314,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Reward (MAX) (Golden / Wrath)',
|
||||
'"Chain" reward (max) (golden / wrath)',
|
||||
document.createTextNode(
|
||||
`${Beautify(CacheChainMaxReward[0])} / ${Beautify(
|
||||
CacheChainWrathMaxReward[0],
|
||||
@@ -327,7 +327,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)',
|
||||
'"Chain" reward (max) (frenzy) (golden / wrath)',
|
||||
document.createTextNode(
|
||||
`${Beautify(CacheChainFrenzyMaxReward[0])} / ${Beautify(
|
||||
CacheChainFrenzyMaxReward[0],
|
||||
@@ -354,7 +354,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Chain" Reward (CUR) (Golden / Wrath)',
|
||||
'"Chain" reward (cur) (golden / wrath)',
|
||||
document.createTextNode(
|
||||
`${Beautify(chainCur)} / ${Beautify(chainCurWrath)}`,
|
||||
),
|
||||
@@ -365,7 +365,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'CPS Needed For Next Level (G / W)',
|
||||
'CPS needed for next level (g / w)',
|
||||
document.createTextNode(
|
||||
`${Beautify(CacheChainRequiredNext)} / ${Beautify(
|
||||
CacheChainWrathRequiredNext,
|
||||
@@ -377,7 +377,7 @@ export function ChainSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'CPS Needed For Next Level (Frenzy) (G / W)',
|
||||
'CPS needed for next level (frenzy) (g / w)',
|
||||
document.createTextNode(
|
||||
`${Beautify(CacheChainFrenzyRequiredNext)} / ${Beautify(
|
||||
CacheChainFrenzyWrathRequiredNext,
|
||||
@@ -422,7 +422,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Conjure Baked Goods" Cookies Required',
|
||||
'"Conjure Baked Goods" cookies required',
|
||||
conjureReqFrag,
|
||||
'GoldCookTooltipPlaceholder',
|
||||
),
|
||||
@@ -430,7 +430,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Conjure Baked Goods" Reward (MAX)',
|
||||
'"Conjure Baked Goods" reward (max)',
|
||||
document.createTextNode(Beautify(CacheConjureReward)),
|
||||
'GoldCookTooltipPlaceholder',
|
||||
),
|
||||
@@ -465,7 +465,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Conjure Baked Goods" Cookies Required (Frenzy)',
|
||||
'"Conjure Baked Goods" cookies required (frenzy)',
|
||||
conjureFrenzyReqFrag,
|
||||
'GoldCookTooltipPlaceholder',
|
||||
),
|
||||
@@ -473,7 +473,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Conjure Baked Goods" Reward (MAX) (Frenzy)',
|
||||
'"Conjure Baked Goods" reward (max) (frenzy)',
|
||||
document.createTextNode(Beautify(CacheConjureReward * 7)),
|
||||
'GoldCookTooltipPlaceholder',
|
||||
),
|
||||
@@ -481,7 +481,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Conjure Baked Goods" Reward (CUR)',
|
||||
'"Conjure Baked Goods" reward (cur)',
|
||||
document.createTextNode(Beautify(conjureFrenzyCur)),
|
||||
'GoldCookTooltipPlaceholder',
|
||||
),
|
||||
@@ -490,7 +490,7 @@ export function SpellsSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'"Spontaneous Edifice" Cookies Required (most expensive building)',
|
||||
'"Spontaneous Edifice" cookies required (most expensive building)',
|
||||
document.createTextNode(
|
||||
`${Beautify(CacheEdifice)} (${CacheEdificeBuilding})`,
|
||||
),
|
||||
@@ -603,7 +603,7 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'Prestige Level (CUR / MAX)',
|
||||
'Prestige level (cur / max)',
|
||||
document.createTextNode(
|
||||
`${Beautify(Game.prestige)} / ${Beautify(possiblePresMax)}`,
|
||||
),
|
||||
@@ -636,7 +636,7 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'Cookies To Next Level',
|
||||
'Cookies to next level',
|
||||
cookiesNextFrag,
|
||||
'NextPrestTooltipPlaceholder',
|
||||
),
|
||||
@@ -645,7 +645,7 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'Heavenly Chips (CUR / MAX)',
|
||||
'Heavenly chips (cur / max)',
|
||||
document.createTextNode(
|
||||
`${Beautify(Game.heavenlyChips)} / ${Beautify(
|
||||
possiblePresMax - Game.prestige + Game.heavenlyChips,
|
||||
@@ -658,7 +658,7 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'basic',
|
||||
'Heavenly Chips Per Second (last 5 seconds)',
|
||||
'Heavenly chips per second (last 5 seconds)',
|
||||
document.createTextNode(Beautify(CacheHCPerSecond, 2)),
|
||||
),
|
||||
);
|
||||
@@ -672,14 +672,14 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'basic',
|
||||
'Heavenly Chips To Target Set In Settings (CUR)',
|
||||
'Heavenly chips to target set in settings (cur)',
|
||||
document.createTextNode(Beautify(CookiesTillTarget)),
|
||||
),
|
||||
);
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'basic',
|
||||
'Time To Target (CUR, Current 5 Second Average)',
|
||||
'Time till target (cur, current 5 second average)',
|
||||
document.createTextNode(
|
||||
FormatTime(CookiesTillTarget / CacheHCPerSecond),
|
||||
),
|
||||
@@ -700,7 +700,7 @@ export function PrestigeSection() {
|
||||
section.appendChild(
|
||||
StatsListing(
|
||||
'withTooltip',
|
||||
'Reset Bonus Income',
|
||||
'Reset bonus income',
|
||||
resetFrag,
|
||||
'ResetTooltipPlaceholder',
|
||||
),
|
||||
|
||||
@@ -55,7 +55,7 @@ export default function ReplaceAscendTooltip() {
|
||||
)} more cookies</b> for the next level.<br>`;
|
||||
str += `${
|
||||
CMOptions.TooltipAscendButton
|
||||
? `<div class='line'></div>It takes ${CacheTimeTillNextPrestige} to reach the next level and you are making ${Beautify(
|
||||
? `<div class='line'></div>It takes ${CacheTimeTillNextPrestige} to reach the next level and you were making ${Beautify(
|
||||
CacheHCPerSecond,
|
||||
2,
|
||||
)} chips on average in the last 5 seconds.<br>`
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { VersionMajor, VersionMinor } from '../Data/Moddata';
|
||||
import Draw from '../Disp/Draw';
|
||||
import CMClickHook from '../Main/ClickHook';
|
||||
import InitializeCookieMonster from '../Main/Initialization';
|
||||
import CMLoop from '../Main/Loop';
|
||||
import CMLoopHook from '../Main/LoopHook';
|
||||
import { isInitializing } from './Variables';
|
||||
|
||||
/**
|
||||
@@ -16,13 +17,14 @@ export default function init() {
|
||||
let proceed = true;
|
||||
if (Game.version !== Number(VersionMajor)) {
|
||||
proceed = confirm(
|
||||
`Cookie Monster version ${VersionMajor}.${VersionMinor} is meant for Game version ${VersionMajor}. Loading a different version may cause errors. Do you still want to load Cookie Monster?`,
|
||||
`Cookie Monster version ${VersionMajor}.${VersionMinor} is meant for Game version ${VersionMajor}. Loading a different version may cause errors. Do you still want to load Cookie Monster?`,
|
||||
);
|
||||
}
|
||||
if (proceed) {
|
||||
InitializeCookieMonster();
|
||||
Game.registerHook('draw', Draw);
|
||||
Game.registerHook('logic', CMLoop);
|
||||
Game.registerHook('logic', CMLoopHook);
|
||||
Game.registerHook('click', CMClickHook);
|
||||
isInitializing = false;
|
||||
}
|
||||
}
|
||||
|
||||
6
src/Main/ClickHook.js
Normal file
6
src/Main/ClickHook.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { CacheAverageCookiesFromClicks } from '../Cache/VariablesAndData';
|
||||
|
||||
export default function CMClickHook() {
|
||||
// Add cookies from click to array that stores average
|
||||
CacheAverageCookiesFromClicks.addLatest(Game.computedMouseCps);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ import { LastModCount } from './VariablesAndData';
|
||||
* Main loop of Cookie Monster
|
||||
* CM.init registers it to the "logic" hook provided by the modding api
|
||||
*/
|
||||
export default function CMLoop() {
|
||||
export default function CMLoopHook() {
|
||||
if (LastAscendState !== Game.OnAscend) {
|
||||
LastAscendState = Game.OnAscend;
|
||||
UpdateAscendState();
|
||||
Reference in New Issue
Block a user