Safeguard against createdSaplings going negative

This commit is contained in:
thepaperpilot 2022-12-18 16:24:33 -06:00
parent e326f94d7e
commit bbf6c94fe5

View file

@ -596,9 +596,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
).floor()
)
)
);
).max(0);
if (masteryEffectActive.value) {
createdSaplings.value = Decimal.add(createdSaplings.value, amount);
createdSaplings.value = Decimal.add(createdSaplings.value, amount).max(0);
}
logs.value = Decimal.add(logs.value, Decimal.times(logGain.apply(1), amount));
saplings.value = Decimal.mul(amount, masteryEffectActive.value ? 2 : 1).add(
@ -652,7 +652,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
).floor()
)
)
);
).max(0);
saplings.value = Decimal.sub(saplings.value, amount);
manualPlantProgress.value = 0;
}
@ -762,7 +762,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const amountCut = Decimal.min(
trees.value,
Decimal.times(computedAutoCuttingAmount.value, diff)
);
).max(0);
const logsGained = Decimal.mul(logGain.apply(1), amountCut);
const effectiveLogsGained = Decimal.div(logsGained, diff);
@ -779,7 +779,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
const amountPlanted = Decimal.min(
saplings.value,
Decimal.times(computedAutoPlantingAmount.value, diff)
);
).max(0);
saplings.value = Decimal.sub(saplings.value, amountPlanted);
});