Merge pull request #2508 from IvarK/fix-dimboost-bulk-buyer

Fix bug where bulk dimboosts could buy more than the capped amount
This commit is contained in:
Dys 2022-04-25 09:49:54 +08:00 committed by GitHub
commit 5d5374cd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -165,8 +165,9 @@ export class DimBoost {
} }
} }
export function softReset(bulk, forcedNDReset = false, forcedAMReset = false) { export function softReset(tempBulk, forcedNDReset = false, forcedAMReset = false) {
if (Currency.antimatter.gt(Player.infinityLimit)) return; if (Currency.antimatter.gt(Player.infinityLimit)) return;
const bulk = Math.min(tempBulk, DimBoost.maxBoosts - player.dimensionBoosts);
EventHub.dispatch(GAME_EVENT.DIMBOOST_BEFORE, bulk); EventHub.dispatch(GAME_EVENT.DIMBOOST_BEFORE, bulk);
player.dimensionBoosts = Math.max(0, player.dimensionBoosts + bulk); player.dimensionBoosts = Math.max(0, player.dimensionBoosts + bulk);
resetChallengeStuff(); resetChallengeStuff();
@ -202,7 +203,7 @@ export function skipResetsIfPossible() {
export function requestDimensionBoost(bulk) { export function requestDimensionBoost(bulk) {
if (Currency.antimatter.gt(Player.infinityLimit) || !DimBoost.requirement.isSatisfied) return; if (Currency.antimatter.gt(Player.infinityLimit) || !DimBoost.requirement.isSatisfied) return;
if (!DimBoost.canBeBought) return; if (!DimBoost.canBeBought) return;
if (BreakInfinityUpgrade.autobuyMaxDimboosts.isBought && bulk) maxBuyDimBoosts(true); if (BreakInfinityUpgrade.autobuyMaxDimboosts.isBought && bulk) maxBuyDimBoosts();
else softReset(1); else softReset(1);
} }