Skip to content

Commit dbc3ffc

Browse files
committed
Fix: errors on special upgrades
1 parent 48a1b18 commit dbc3ffc

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ 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+
9+
## [2042.9] - 2021-09-18
10+
### Changed
11+
- Suppress notation on 0% upgrades.
12+
- Avoid sorting upgrades in toggle pool.
13+
814
### Fixed
9-
- Errors afters ascend.
10-
- Best deals do not show in blue if multiple deals have same ratio.
15+
- Fix errors afters ascend.
16+
- Fix that best deals do not show in blue if multiple deals have same ratio.
17+
- Fix errors with Mile Selector.
18+
- Fix 0% rate updates are included in normalizing process.
1119

1220
## [2042.8] - 2021-09-18
1321
### Fixed

RELEASE.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
## [2042.8] - 2021-09-18
2-
### Fixed
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.
4-
1+
## [2042.9] - 2021-09-18
52
### Changed
6-
- Grandmapocalypse related upgrades are set to 0%, including "One mind", "Communal brainsweep", "Elder pact".
3+
- Suppress notation on 0% upgrades.
4+
- Avoid sorting upgrades in toggle pool.
5+
6+
### Fixed
7+
- Fix errors afters ascend.
8+
- Fix that best deals do not show in blue if multiple deals have same ratio.
9+
- Fix errors with Mile Selector.
10+
- Fix 0% rate updates are included in normalizing process.

main.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @property {Array} customOptionsMenu
4343
* @property {Array} Upgrades
4444
* @property {string} clickStr
45+
* @property {string} pool
4546
* @property {number} unbuffedCps
4647
* @property {number} globalCpsMult
4748
* @property {number} storedCps
@@ -119,7 +120,7 @@ let BestDealHelper = {
119120

120121
logicLoop: function () {
121122
MOD.loopCount++;
122-
if (MOD.loopCount >= 3
123+
if (MOD.loopCount >= 10
123124
|| MOD.last_cps !== Game.cookiesPs
124125
|| MOD.config.sortbuildings !== MOD.last_config_sortbuildings
125126
|| !document.querySelector("#productAcc0")
@@ -137,7 +138,7 @@ let BestDealHelper = {
137138

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

143144

@@ -163,6 +164,7 @@ let BestDealHelper = {
163164
} else {
164165
deltaTime = me.price / me.newCookiesPs;
165166
}
167+
if (deltaTime === 0) return 0; // "Milk selector"
166168

167169
let deltaCps = me.newCookiesPs - Game.cookiesPs;
168170
return deltaCps / deltaTime;
@@ -239,8 +241,9 @@ let BestDealHelper = {
239241
let color = chroma.scale(palette).mode("lab").domain(domain);
240242

241243
// Normalized Notation by Mean
242-
const avg = all.map(e => e.cpsAcceleration).reduce((a, b) => a + b, 0) / all.length;
243-
if (avg===0) return;
244+
let allAcc = all.map(e => e.cpsAcceleration).filter(e => e !== 0);
245+
if (allAcc.length === 0) return;
246+
const avg = allAcc.reduce((a, b) => a + b, 0) / allAcc.length;
244247

245248
// Notation for upgrades
246249
for (const i in upgrades) {
@@ -258,6 +261,10 @@ let BestDealHelper = {
258261
span.style.transform = "scale(0.8,1)";
259262
l("upgrade" + i).appendChild(span);
260263
}
264+
if (me.cpsAcceleration === 0) {
265+
span.textContent = "";
266+
continue;
267+
}
261268
span.textContent = Beautify(me.cpsAcceleration * 100 / avg, 1) + "%";
262269
if (me.isBestHelper) {
263270
let text = span.innerText;
@@ -283,6 +290,10 @@ let BestDealHelper = {
283290
span.style.display = "block";
284291
MOD.insertAfter(span, l("productPrice" + me.id));
285292
}
293+
if (me.cpsAcceleration === 0) {
294+
span.textContent = "";
295+
continue;
296+
}
286297
span.textContent = " 💹" + Beautify(me.cpsAcceleration * 100 / avg, 2) + "%";
287298
if (me.isBestHelper) {
288299
let text = span.innerText;
@@ -307,6 +318,7 @@ let BestDealHelper = {
307318
if (!upgrades_order.every((value, index) => value === current_upgrades_order[index])) {
308319
let store = document.querySelector("#upgrades");
309320
for (let i = 0; i < upgrades.length; ++i) {
321+
if(upgrades[i].pool === "toggle") continue;
310322
store.appendChild(upgrades[i].l);
311323
}
312324
}

0 commit comments

Comments
 (0)