Fix so many buyables doing the wrong costs and going up by 2

pay() when
This commit is contained in:
thepaperpilot 2022-12-24 22:13:08 -06:00
parent f96c9c407f
commit c0e3eace37
5 changed files with 38 additions and 15 deletions

View file

@ -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":

View file

@ -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);

View file

@ -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

View file

@ -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: () =>

View file

@ -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