Skip to content

Commit 48a1b18

Browse files
committed
Fix: Errors afters ascend
1 parent 40588ed commit 48a1b18

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Fixed
9+
- Errors afters ascend.
10+
- Best deals do not show in blue if multiple deals have same ratio.
811

912
## [2042.8] - 2021-09-18
1013
### Fixed
11-
- Fix "raw cookies per second" get changed incorrectly. However, this Mod cannot detect whether your stat is correct or incorrectly; Please export your save, visit https://coderpatsy.bitbucket.io/cookies/editor.html, change `Highest raw CpS` to 0 and import modified save back to fix the value.
14+
- Fix "raw cookies per second" get changed incorrect. However, this Mod cannot detect whether your stat is correct or incorrectly; Please export your save, visit https://coderpatsy.bitbucket.io/cookies/editor.html, change `Highest raw CpS` to 0 and import modified save back to fix the value.
1215

1316
### Changed
1417
- Grandmapocalypse related upgrades are set to 0%, including "One mind", "Communal brainsweep", "Elder pact".

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## [2042.8] - 2021-09-18
22
### Fixed
3-
- Fix "raw cookies per second" get changed incorrectly. However, this Mod cannot detect whether your stat is correct or incorrectly; Please export your save, visit https://coderpatsy.bitbucket.io/cookies/editor.html, change `Highest raw CpS` to 0 and import modified save back to fix the value.
3+
- Fix "raw cookies per second" get changed incorrect. However, this Mod cannot detect whether your stat is correct or incorrectly; Please export your save, visit https://coderpatsy.bitbucket.io/cookies/editor.html, change `Highest raw CpS` to 0 and import modified save back to fix the value.
44

55
### Changed
66
- Grandmapocalypse related upgrades are set to 0%, including "One mind", "Communal brainsweep", "Elder pact".

main.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
* @property {DocumentFragment} l
1919
* @property {number} price
2020
* @property {number} timeToTargetCookie
21+
* @property {number} newCookiesPs
2122
*/
2223
/**
2324
* @typedef {Object} Upgrade
2425
* @property {function} getPrice
2526
* @property {number} bought
2627
* @property {number} timeToTargetCookie
28+
* @property {number} newCookiesPs
2729
*/
2830
/**
2931
* @typedef {Object} Game
@@ -63,7 +65,11 @@ let BestDealHelper = {
6365
sortbuildings: 0,
6466
},
6567

66-
isLoaded: false, load_chroma: false, loopCount: 0, register: function () {
68+
isLoaded: false,
69+
load_chroma: false,
70+
loopCount: 0,
71+
72+
register: function () {
6773
Game.registerMod(this.name, this);
6874
},
6975

@@ -72,6 +78,7 @@ let BestDealHelper = {
7278
[...document.getElementsByClassName("product")].forEach(e => e.style.lineHeight = "18px");
7379
[...document.getElementsByClassName("productName")].forEach(e => e.style.fontSize = "26px");
7480

81+
// noinspection JSUndeclaredVariable
7582
MOD = this;
7683
Game.customOptionsMenu.push(MOD.addOptionsMenu);
7784
MOD.last_cps = 0;
@@ -112,7 +119,11 @@ let BestDealHelper = {
112119

113120
logicLoop: function () {
114121
MOD.loopCount++;
115-
if (MOD.loopCount >= 5 || MOD.last_cps !== Game.cookiesPs || MOD.config.sortbuildings !== MOD.last_config_sortbuildings || !document.querySelector("#productAcc0") || (document.querySelector("#upgrade0") && !document.querySelector("#upgradeAcc0"))) {
122+
if (MOD.loopCount >= 3
123+
|| MOD.last_cps !== Game.cookiesPs
124+
|| MOD.config.sortbuildings !== MOD.last_config_sortbuildings
125+
|| !document.querySelector("#productAcc0")
126+
|| (document.querySelector("#upgrade0") && !document.querySelector("#upgradeAcc0"))) {
116127
MOD.sortDeals();
117128
MOD.loopCount = 0;
118129
MOD.last_config_sortbuildings = MOD.config.sortbuildings;
@@ -126,12 +137,13 @@ let BestDealHelper = {
126137

127138
getCpsAcceleration: function (me) {
128139
// Treat Grandmapocalypse upgrade as 0% temporary
129-
if (["One mind", "Communal brainsweep", "Elder pact"].includes(me.name)) return 0;
140+
if (["Milk selector", "One mind", "Communal brainsweep", "Elder pact"].includes(me.name)) return 0;
141+
if (Game.cookies === 0) return 0;
142+
130143

131144
// Backup
132145
Game.Logic_ = Game.Logic;
133-
Game.Logic = function () {
134-
};
146+
Game.Logic = function () {};
135147
let oldCookiesPsRawHighest = Game.cookiesPsRawHighest;
136148

137149
if (me.type === "upgrade") me.bought++; else me.amount++;
@@ -203,6 +215,7 @@ let BestDealHelper = {
203215
let rank = 0;
204216
let domain = [all[rank].cpsAcceleration];
205217
rank++;
218+
while (rank < all.length && all[rank].cpsAcceleration === all[0].cpsAcceleration) rank++;
206219
if (rank < all.length) {
207220
palette.unshift("#00ff00");
208221
domain.unshift(all[rank].cpsAcceleration);
@@ -227,6 +240,7 @@ let BestDealHelper = {
227240

228241
// Normalized Notation by Mean
229242
const avg = all.map(e => e.cpsAcceleration).reduce((a, b) => a + b, 0) / all.length;
243+
if (avg===0) return;
230244

231245
// Notation for upgrades
232246
for (const i in upgrades) {
@@ -255,7 +269,7 @@ let BestDealHelper = {
255269
span.appendChild(charElem);
256270
}
257271
} else {
258-
span.style.color = color(me.cpsAcceleration);
272+
try {span.style.color = color(me.cpsAcceleration);} catch (e) { }
259273
}
260274
}
261275
// Notation for buildings
@@ -280,7 +294,7 @@ let BestDealHelper = {
280294
span.appendChild(charElem);
281295
}
282296
} else {
283-
span.style.color = color(me.cpsAcceleration);
297+
try {span.style.color = color(me.cpsAcceleration);} catch (e) { }
284298
}
285299
}
286300

0 commit comments

Comments
 (0)