Merge pull request #835 from DanielNoord/tillnextachiev
Some optimizations in Left till next achievement calculations
This commit is contained in:
2
dist/CookieMonsterDev.js
vendored
2
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
@@ -26,9 +26,7 @@ export default function AllAmountTillNextAchievement(forceRecalc) {
|
||||
result[i] = {
|
||||
AmountNeeded: tillNext,
|
||||
TotalNeeded: Game.Objects[i].amount + tillNext,
|
||||
price: Game.Objects[i].getSumPrice(
|
||||
Game.Objects[i].amount + tillNext - Game.Objects[i].amount,
|
||||
),
|
||||
price: Game.Objects[i].getSumPrice(tillNext),
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3,10 +3,24 @@ import { SimAchievementsOwned } from '../../Sim/VariablesAndData';
|
||||
|
||||
export default function IndividualAmountTillNextAchievement(building) {
|
||||
const AchievementsAtStart = Game.AchievementsOwned;
|
||||
for (let index = 0; index < 101; index++) {
|
||||
let index = 100;
|
||||
let lastIndexWithChange = 100;
|
||||
while (index > -1) {
|
||||
BuyBuildingsBonusIncome(building, index);
|
||||
if (SimAchievementsOwned > AchievementsAtStart) {
|
||||
return index;
|
||||
lastIndexWithChange = index;
|
||||
index -= 10;
|
||||
} else if (index === 100) {
|
||||
return 101;
|
||||
} else {
|
||||
index += 1;
|
||||
while (index <= lastIndexWithChange) {
|
||||
BuyBuildingsBonusIncome(building, index);
|
||||
if (SimAchievementsOwned > AchievementsAtStart) {
|
||||
return index;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 101;
|
||||
|
||||
Reference in New Issue
Block a user