Skip to content

Commit 699434a

Browse files
committed
Change: fix overestimated waiting time.
the score is weighted too much on avoiding waiting, thus it increases quickly when deals are getting affordable; All good things are worth waiting for and worth fighting for.
1 parent dfeb281 commit 699434a

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2042.14] - 2021-09-25
10+
### Changed
11+
- Change: fix overestimated waiting time. the score is weighted too much on avoiding waiting, thus it increases quickly when deals are getting affordable; All good things are worth waiting for and worth fighting for.
12+
913
## [2042.13] - 2021-09-22
1014
### Added
1115
- Add: `cpsAcceleration` now consider multiple buying until next tier upgrade.

RELEASE.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
## [2042.13] - 2021-09-22
2-
### Added
3-
- Add: `cpsAcceleration` now consider multiple buying until next tier upgrade.
4-
- Add: button to ignore Wizard Tower.
1+
## [2042.14] - 2021-09-25
2+
### Changed
3+
- Change: fix overestimated waiting time. the score is weighted too much on avoiding waiting, thus it increases quickly when deals are getting affordable; All good things are worth waiting for and worth fighting for.

info.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"ID": "Best Deal Helper",
44
"Author": "Jethro Yu",
55
"Description": "Help you choose best deal!",
6-
"ModVersion": 2042.13,
6+
"ModVersion": 2042.14,
77
"GameVersion": 2.042,
8-
"Date": "22/09/2021",
8+
"Date": "25/09/2021",
99
"Dependencies": ["CCSE"],
1010
"Disabled": 1,
1111
"AllowSteamAchievs": 1

main.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,11 @@ let BestDealHelper = {
175175
const deltaCps = newCps - cps;
176176
if (deltaCps === 0) return 0;
177177

178-
const deltaTime = Math.max(price - Game.cookies, 0) / cps + price / newCps;
178+
let deltaTime;
179+
if(price > Game.cookies)
180+
deltaTime = (price - Game.cookies) / cps + Game.cookies / newCps;
181+
else
182+
deltaTime = price / newCps;
179183
if (deltaTime === 0) return 0; // "Milk selector"
180184

181185
return deltaCps / deltaTime;
@@ -274,15 +278,15 @@ let BestDealHelper = {
274278
return time;
275279
}
276280

277-
while (target.price > Game.cookies) {
278-
target.timeToTargetCookie = (target.price - Game.cookies) / Game.cookiesPs;
279-
let helpers = all.filter(me => me !== target && me.price < target.price);
281+
while (target.getPrice() > Game.cookies) {
282+
target.timeToTargetCookie = (target.getPrice() - Game.cookies) / Game.cookiesPs;
283+
let helpers = all.filter(me => me !== target && me.getPrice() < target.getPrice());
280284
if (!helpers.length) return;
281285

282286
helpers.forEach(function (me) {
283-
me.timeToTargetCookie = getTimeToTarget(me.price, me.buyOneCps, target.price, Game.cookies);
284-
if (me.tierPrice <= target.price) {
285-
const timeBuyTier = getTimeToTarget(me.tierPrice, me.buyTierCps, target.price, Game.cookies);
287+
me.timeToTargetCookie = getTimeToTarget(me.getPrice(), me.buyOneCps, target.getPrice(), Game.cookies);
288+
if (me.tierPrice <= target.getPrice()) {
289+
const timeBuyTier = getTimeToTarget(me.tierPrice, me.buyTierCps, target.getPrice(), Game.cookies);
286290
me.timeToTargetCookie = Math.min(me.timeToTargetCookie, timeBuyTier);
287291
}
288292
});

0 commit comments

Comments
 (0)