Skip to content

Commit

Permalink
Fix: errors on special upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
jcppkkk committed Sep 18, 2021
1 parent 48a1b18 commit dbc3ffc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2042.9] - 2021-09-18
### Changed
- Suppress notation on 0% upgrades.
- Avoid sorting upgrades in toggle pool.

### Fixed
- Errors afters ascend.
- Best deals do not show in blue if multiple deals have same ratio.
- Fix errors afters ascend.
- Fix that best deals do not show in blue if multiple deals have same ratio.
- Fix errors with Mile Selector.
- Fix 0% rate updates are included in normalizing process.

## [2042.8] - 2021-09-18
### Fixed
Expand Down
14 changes: 9 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## [2042.8] - 2021-09-18
### Fixed
- 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.

## [2042.9] - 2021-09-18
### Changed
- Grandmapocalypse related upgrades are set to 0%, including "One mind", "Communal brainsweep", "Elder pact".
- Suppress notation on 0% upgrades.
- Avoid sorting upgrades in toggle pool.

### Fixed
- Fix errors afters ascend.
- Fix that best deals do not show in blue if multiple deals have same ratio.
- Fix errors with Mile Selector.
- Fix 0% rate updates are included in normalizing process.
20 changes: 16 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @property {Array} customOptionsMenu
* @property {Array} Upgrades
* @property {string} clickStr
* @property {string} pool
* @property {number} unbuffedCps
* @property {number} globalCpsMult
* @property {number} storedCps
Expand Down Expand Up @@ -119,7 +120,7 @@ let BestDealHelper = {

logicLoop: function () {
MOD.loopCount++;
if (MOD.loopCount >= 3
if (MOD.loopCount >= 10
|| MOD.last_cps !== Game.cookiesPs
|| MOD.config.sortbuildings !== MOD.last_config_sortbuildings
|| !document.querySelector("#productAcc0")
Expand All @@ -137,7 +138,7 @@ let BestDealHelper = {

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


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

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

// Normalized Notation by Mean
const avg = all.map(e => e.cpsAcceleration).reduce((a, b) => a + b, 0) / all.length;
if (avg===0) return;
let allAcc = all.map(e => e.cpsAcceleration).filter(e => e !== 0);
if (allAcc.length === 0) return;
const avg = allAcc.reduce((a, b) => a + b, 0) / allAcc.length;

// Notation for upgrades
for (const i in upgrades) {
Expand All @@ -258,6 +261,10 @@ let BestDealHelper = {
span.style.transform = "scale(0.8,1)";
l("upgrade" + i).appendChild(span);
}
if (me.cpsAcceleration === 0) {
span.textContent = "";
continue;
}
span.textContent = Beautify(me.cpsAcceleration * 100 / avg, 1) + "%";
if (me.isBestHelper) {
let text = span.innerText;
Expand All @@ -283,6 +290,10 @@ let BestDealHelper = {
span.style.display = "block";
MOD.insertAfter(span, l("productPrice" + me.id));
}
if (me.cpsAcceleration === 0) {
span.textContent = "";
continue;
}
span.textContent = " 💹" + Beautify(me.cpsAcceleration * 100 / avg, 2) + "%";
if (me.isBestHelper) {
let text = span.innerText;
Expand All @@ -307,6 +318,7 @@ let BestDealHelper = {
if (!upgrades_order.every((value, index) => value === current_upgrades_order[index])) {
let store = document.querySelector("#upgrades");
for (let i = 0; i < upgrades.length; ++i) {
if(upgrades[i].pool === "toggle") continue;
store.appendChild(upgrades[i].l);
}
}
Expand Down

0 comments on commit dbc3ffc

Please sign in to comment.