diff --git a/src/data/layers/dyes.tsx b/src/data/layers/dyes.tsx index 11a1d8f..e6612f6 100644 --- a/src/data/layers/dyes.tsx +++ b/src/data/layers/dyes.tsx @@ -361,6 +361,7 @@ const layer = createLayer(id, function (this: BaseLayer) { ); }), onPurchase(cost?: DecimalSource) { + buyable.amount.value = Decimal.add(buyable.amount.value, -1); let buyMax = false; switch (options.color) { case "red": diff --git a/src/data/layers/management.tsx b/src/data/layers/management.tsx index 8fdf721..c7a91e0 100644 --- a/src/data/layers/management.tsx +++ b/src/data/layers/management.tsx @@ -1655,6 +1655,8 @@ const layer = createLayer(id, () => { ); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); trees.logs.value = Decimal.sub(trees.logs.value, schoolCost.value.wood); coal.coal.value = Decimal.sub(coal.coal.value, schoolCost.value.coal); paper.paper.value = Decimal.sub(paper.paper.value, schoolCost.value.paper); @@ -1718,6 +1720,8 @@ const layer = createLayer(id, () => { ); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); trees.logs.value = Decimal.sub(trees.logs.value, classroomCost.value.wood); paper.paper.value = Decimal.sub(paper.paper.value, classroomCost.value.paper); boxes.boxes.value = Decimal.sub(boxes.boxes.value, classroomCost.value.boxes); diff --git a/src/data/layers/routing.tsx b/src/data/layers/routing.tsx index 7d1dd6a..970ba5e 100644 --- a/src/data/layers/routing.tsx +++ b/src/data/layers/routing.tsx @@ -654,6 +654,8 @@ const layer = createLayer(id, function (this: BaseLayer) { ); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); management.classrooms.amount.value = Decimal.sub( management.classrooms.amount.value, unref(metaBuyables.classroom.cost ?? 0) @@ -685,9 +687,6 @@ const layer = createLayer(id, function (this: BaseLayer) { unref(metaBuyables.tick.cost ?? 0) ); }, - onPurchase() { - this.amount.value = Decimal.add(this.amount.value, 1); - }, display: jsx(() => ( <> Upgrade computer diff --git a/src/data/layers/toys.tsx b/src/data/layers/toys.tsx index 370f43f..dacafcf 100644 --- a/src/data/layers/toys.tsx +++ b/src/data/layers/toys.tsx @@ -103,6 +103,8 @@ const layer = createLayer(id, function (this: BaseLayer) { ); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); cloth.cloth.value = Decimal.sub(cloth.cloth.value, clothesCost.value.cloth); this.amount.value = Decimal.add(this.amount.value, 1); clothes.value = Decimal.add(clothes.value, 1); @@ -135,6 +137,8 @@ const layer = createLayer(id, function (this: BaseLayer) { return woodenBlocksCost.value.wood.lte(trees.logs.value); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); trees.logs.value = Decimal.sub(trees.logs.value, woodenBlocksCost.value.wood); this.amount.value = Decimal.add(this.amount.value, 1); woodenBlocks.value = Decimal.add(woodenBlocks.value, 1); @@ -194,6 +198,8 @@ const layer = createLayer(id, function (this: BaseLayer) { ); }, onPurchase() { + // Lower amount first so costs are accurate, then re-add the purchase after + this.amount.value = Decimal.add(this.amount.value, -1); metal.metal.value = Decimal.sub(metal.metal.value, trucksCost.value.metal); plastic.plastic.value = Decimal.sub(plastic.plastic.value, trucksCost.value.plastic); this.amount.value = Decimal.add(this.amount.value, 1); @@ -291,7 +297,8 @@ const layer = createLayer(id, function (this: BaseLayer) { const milestone8 = createMilestone(() => ({ display: { requirement: "6000 toys", - effectDisplay: "Running out of energy? Let's increase the limit! Multiply energy capacity by 1.4" + effectDisplay: + "Running out of energy? Let's increase the limit! Multiply energy capacity by 1.4" }, shouldEarn: () => Decimal.gte(toySum.value, 6000), visibility: () => diff --git a/src/data/layers/wrapping-paper.tsx b/src/data/layers/wrapping-paper.tsx index c267294..0837fe0 100644 --- a/src/data/layers/wrapping-paper.tsx +++ b/src/data/layers/wrapping-paper.tsx @@ -17,7 +17,7 @@ import { main } from "../projEntry"; import { default as dyes, type enumColor } from "./dyes"; import elves from "./elves"; import toys from "./toys"; -import packing from "./packing" +import packing from "./packing"; const id = "wrappingPaper"; const day = 15; @@ -115,10 +115,6 @@ const layer = createLayer(id, () => { if (Decimal.lt(resource.value, cost)) return false; } return true; - }, - onPurchase() { - buyable.amount.value = Decimal.add(buyable.amount.value, 1); - // todo: stuff } }; }); @@ -260,22 +256,38 @@ const layer = createLayer(id, () => { ] }) }; - const packingBoost = computed(() => packing.packingMilestones.wrappingPaperBoost.earned.value ? 2 : 1) + const packingBoost = computed(() => + packing.packingMilestones.wrappingPaperBoost.earned.value ? 2 : 1 + ); const boosts = { christmas1: computed(() => - main.isMastery.value ? 1 : Decimal.add(wrappingPaper.christmas.buyable.amount.value, 1).mul(packingBoost.value) + main.isMastery.value + ? 1 + : Decimal.add(wrappingPaper.christmas.buyable.amount.value, 1).mul( + packingBoost.value + ) ), // Probably not the best way to do this, but it works rainbow1: computed(() => - main.isMastery.value ? 1 : Decimal.pow(2, wrappingPaper.rainbow.buyable.amount.value).mul(packingBoost.value) + main.isMastery.value + ? 1 + : Decimal.pow(2, wrappingPaper.rainbow.buyable.amount.value).mul(packingBoost.value) ), jazzy1: computed(() => - main.isMastery.value ? 1 : Decimal.add(wrappingPaper.jazzy.buyable.amount.value, 1).mul(packingBoost.value) + main.isMastery.value + ? 1 + : Decimal.add(wrappingPaper.jazzy.buyable.amount.value, 1).mul(packingBoost.value) ), sunshine1: computed(() => - main.isMastery.value ? 1 : Decimal.add(wrappingPaper.sunshine.buyable.amount.value, 1).mul(packingBoost.value) + main.isMastery.value + ? 1 + : Decimal.add(wrappingPaper.sunshine.buyable.amount.value, 1).mul( + packingBoost.value + ) ), ocean1: computed(() => - main.isMastery.value ? 1 : Decimal.pow(1.5, wrappingPaper.ocean.buyable.amount.value).mul(packingBoost.value) + main.isMastery.value + ? 1 + : Decimal.pow(1.5, wrappingPaper.ocean.buyable.amount.value).mul(packingBoost.value) ), beach1: computed(() => main.isMastery.value