From 17f13239ca4cf2218956f3b5680837589209882b Mon Sep 17 00:00:00 2001 From: Chorizorro Date: Mon, 30 Nov 2020 11:25:21 +0100 Subject: [PATCH] Fix building price in store in sell mode (#359) --- CookieMonster.js | 12 +++++++++++- src/Disp.js | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index c945cf9..f4b5c38 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1424,7 +1424,17 @@ CM.Disp.UpdateBuildings = function() { } else { for (var i in CM.Cache.Objects) { - l('productPrice' + Game.Objects[i].id).style.color = ''; + var o = Game.Objects[i]; + l('productPrice' + o.id).style.color = ''; + /* + * Fix sell price displayed in the object in the store. + * + * The buildings sell price displayed by the game itself (without any mod) is incorrect. + * The following line of code fixes this issue, and can be safely removed when the game gets fixed. + * + * This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262 + */ + l('productPrice' + o.id).innerHTML = Beautify(CM.Sim.BuildingSell(o, o.basePrice, o.amount, o.free, Game.buyBulk, 1)); } } diff --git a/src/Disp.js b/src/Disp.js index be7b31b..e32aab0 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -676,7 +676,17 @@ CM.Disp.UpdateBuildings = function() { } else { for (var i in CM.Cache.Objects) { - l('productPrice' + Game.Objects[i].id).style.color = ''; + var o = Game.Objects[i]; + l('productPrice' + o.id).style.color = ''; + /* + * Fix sell price displayed in the object in the store. + * + * The buildings sell price displayed by the game itself (without any mod) is incorrect. + * The following line of code fixes this issue, and can be safely removed when the game gets fixed. + * + * This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262 + */ + l('productPrice' + o.id).innerHTML = Beautify(CM.Sim.BuildingSell(o, o.basePrice, o.amount, o.free, Game.buyBulk, 1)); } }