Fix BuildingGetPrice() and remove getSumPrice()
This commit is contained in:
14015
dist/CookieMonsterDev.js
vendored
14015
dist/CookieMonsterDev.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonsterDev.js.map
vendored
2
dist/CookieMonsterDev.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
||||
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
|
||||
import { ColourGray } from '../../Disp/VariablesAndData';
|
||||
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
|
||||
import {
|
||||
CacheMinPP, // eslint-disable-line no-unused-vars
|
||||
CacheMinPPBulk, // eslint-disable-line no-unused-vars
|
||||
@@ -25,7 +26,16 @@ function CacheColour(target, amount) {
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
target[i].color = ColourOfPP(target[i], Game.Objects[i].getSumPrice(amount));
|
||||
target[i].color = ColourOfPP(
|
||||
target[i],
|
||||
BuildingGetPrice(
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
amount,
|
||||
),
|
||||
);
|
||||
// Colour based on excluding certain top-buildings
|
||||
for (
|
||||
let j = 0;
|
||||
@@ -39,7 +49,13 @@ function CacheColour(target, amount) {
|
||||
|
||||
function CachePP(target, amount) {
|
||||
Object.keys(target).forEach((i) => {
|
||||
const price = Game.Objects[i].getSumPrice(amount);
|
||||
const price = BuildingGetPrice(
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
amount,
|
||||
);
|
||||
if (Game.cookiesPs) {
|
||||
target[i].pp = // eslint-disable-line no-param-reassign
|
||||
Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs +
|
||||
|
||||
@@ -65,28 +65,28 @@ function CacheUpgradeIncome() {
|
||||
export function CacheBuildingsPrices() {
|
||||
Object.keys(Game.Objects).forEach((i) => {
|
||||
CacheObjects1[i].price = BuildingGetPrice(
|
||||
Game.Objects[i],
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
1,
|
||||
);
|
||||
CacheObjects10[i].price = BuildingGetPrice(
|
||||
Game.Objects[i],
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
10,
|
||||
);
|
||||
CacheObjects100[i].price = BuildingGetPrice(
|
||||
Game.Objects[i],
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
100,
|
||||
);
|
||||
CacheObjectsNextAchievement[i].price = BuildingGetPrice(
|
||||
Game.Objects[i],
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
|
||||
import { CacheObjectsNextAchievement } from '../VariablesAndData';
|
||||
import IndividualAmountTillNextAchievement from './IndividualAmountTillNextAchievement';
|
||||
|
||||
@@ -17,7 +18,11 @@ export default function AllAmountTillNextAchievement(forceRecalc) {
|
||||
result[i] = {
|
||||
AmountNeeded: CacheObjectsNextAchievement[i].TotalNeeded - Game.Objects[i].amount,
|
||||
TotalNeeded: CacheObjectsNextAchievement[i].TotalNeeded,
|
||||
price: Game.Objects[i].getSumPrice(
|
||||
price: BuildingGetPrice(
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
CacheObjectsNextAchievement[i].TotalNeeded - Game.Objects[i].amount,
|
||||
),
|
||||
};
|
||||
@@ -26,7 +31,13 @@ export default function AllAmountTillNextAchievement(forceRecalc) {
|
||||
result[i] = {
|
||||
AmountNeeded: tillNext,
|
||||
TotalNeeded: Game.Objects[i].amount + tillNext,
|
||||
price: Game.Objects[i].getSumPrice(tillNext),
|
||||
price: BuildingGetPrice(
|
||||
i,
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
tillNext,
|
||||
),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/**
|
||||
* This function calculates the total price for buying "increase" of a building
|
||||
* Base Game does not currently allow this
|
||||
* It is called by CM.Cache.CacheBuildingsPrices() and CM.Disp.Tooltip()
|
||||
* @param {string} build Name of the building
|
||||
* @param {number} basePrice Base Price of building
|
||||
* @param {number} start Starting amount of building
|
||||
@@ -10,14 +8,11 @@
|
||||
* @returns {number} moni Total price
|
||||
*/
|
||||
export default function BuildingGetPrice(build, basePrice, start, free, increase) {
|
||||
let startingAmount = start;
|
||||
let moni = 0;
|
||||
for (let i = 0; i < increase; i += 1) {
|
||||
let price = basePrice * Game.priceIncrease ** Math.max(0, startingAmount - free);
|
||||
price = Game.modifyBuildingPrice(build, price);
|
||||
price = Math.ceil(price);
|
||||
moni += price;
|
||||
startingAmount += 1;
|
||||
let partialPrice = 0;
|
||||
for (let i = Math.max(0, start); i < Math.max(0, start + increase); i++) {
|
||||
partialPrice += Game.priceIncrease ** Math.max(0, i - free);
|
||||
}
|
||||
return moni;
|
||||
let price = basePrice * partialPrice;
|
||||
price = Game.modifyBuildingPrice(Game.Objects[build], price);
|
||||
return Math.ceil(price);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user