From 5d9096425bc657441766b9221355df6a82c2beb9 Mon Sep 17 00:00:00 2001 From: Chunkybanana <62921243+chunkybanana@users.noreply.github.com> Date: Wed, 14 Dec 2022 01:07:35 +0000 Subject: [PATCH] Implement wrapping paper modifiers --- src/data/layers/boxes.tsx | 3 ++- src/data/layers/coal.tsx | 4 ++++ src/data/layers/dyes.tsx | 18 +++++++++------ src/data/layers/elves.tsx | 44 ++++++++++++++++++++++++++---------- src/data/layers/paper.tsx | 16 ++++++++++++- src/data/layers/trees.tsx | 6 +++++ src/data/layers/workshop.tsx | 10 ++++++-- vite.config.ts | 1 - 8 files changed, 78 insertions(+), 24 deletions(-) diff --git a/src/data/layers/boxes.tsx b/src/data/layers/boxes.tsx index e5cff9a..17ab1ad 100644 --- a/src/data/layers/boxes.tsx +++ b/src/data/layers/boxes.tsx @@ -32,6 +32,7 @@ import paper from "./paper"; import plastic from "./plastic"; import trees from "./trees"; import workshop from "./workshop"; +import wrappingPaper from "./wrapping-paper" export type BoxesBuyable = GenericBuyable & { resource: Resource; @@ -219,7 +220,7 @@ const layer = createLayer(id, function (this: BaseLayer) { if (management.elfTraining.boxElfTraining.milestones[2].earned.value) { scaling--; } - return Decimal.pow(scaling, v).times(100).div(dyes.boosts.orange2.value); + return Decimal.pow(scaling, v).times(100).div(dyes.boosts.orange2.value).div(wrappingPaper.boosts.ocean1.value); }, visibility: () => showIf(logsUpgrade.bought.value), freeLevels: computed(() => diff --git a/src/data/layers/coal.tsx b/src/data/layers/coal.tsx index 5632b1a..2544ec5 100644 --- a/src/data/layers/coal.tsx +++ b/src/data/layers/coal.tsx @@ -40,6 +40,7 @@ import paper from "./paper"; import trees from "./trees"; import dyes from "./dyes"; import management from "./management"; +import wrappingPaper from "./wrapping-paper"; interface BetterFertilizerUpgOptions { canAfford: () => boolean; @@ -429,6 +430,7 @@ const layer = createLayer(id, function (this: BaseLayer) { if (management.elfTraining.heatedCutterElfTraining.milestones[0].earned.value) { v = Decimal.pow(0.95, paper.books.heatedCuttersBook.amount.value).times(v); } + v = v.div(wrappingPaper.boosts.rainbow1.value); return Decimal.add(v, 1).pow(2.5).times(10); }, display: { @@ -452,6 +454,7 @@ const layer = createLayer(id, function (this: BaseLayer) { if (management.elfTraining.heatedPlanterElfTraining.milestones[0].earned.value) { v = Decimal.pow(0.95, paper.books.heatedPlantersBook.amount.value).times(v); } + v = v.div(wrappingPaper.boosts.rainbow1.value); return Decimal.add(v, 1).pow(2.5).times(10); }, display: { @@ -475,6 +478,7 @@ const layer = createLayer(id, function (this: BaseLayer) { if (management.elfTraining.fertilizerElfTraining.milestones[1].earned.value) { v = Decimal.pow(0.95, paper.books.fertilizerBook.amount.value).times(v); } + v = v.div(wrappingPaper.boosts.rainbow1.value); return Decimal.add(v, 1).pow(1.5).times(50000); }, display: { diff --git a/src/data/layers/dyes.tsx b/src/data/layers/dyes.tsx index 373e43e..8a08961 100644 --- a/src/data/layers/dyes.tsx +++ b/src/data/layers/dyes.tsx @@ -30,6 +30,7 @@ import management from "./management"; import oil from "./oil"; import trees from "./trees"; import wrappingPaper from "./wrapping-paper"; +import paper from "./paper"; interface Dye { name: string; @@ -195,6 +196,7 @@ const layer = createLayer(id, function (this: BaseLayer) { let v = buyable.amount.value; if (Decimal.gte(v, 25)) v = Decimal.pow(v, 2).div(20); // intentional price jump #2 if (Decimal.gte(v, 10)) v = Decimal.pow(v, 2).div(5); // intentional price jump + v = Decimal.mul(v, Decimal.pow(0.95, paper.books.dyeBook.amount.value)) return Decimal.div(v, 10).plus(1); }, canPurchase: computed((cost?: DecimalSource) => { @@ -208,17 +210,19 @@ const layer = createLayer(id, function (this: BaseLayer) { }), onPurchase(cost?: DecimalSource) { const trueCost = cost ?? unref(buyable.cost) ?? Decimal.dInf; - unref(costs).forEach(c => { - c.res.value = Decimal.sub( - c.res.value, - Decimal.pow(trueCost, unref(c.root ?? 1)).times(unref(c.base)) - ); - }); amount.value = Decimal.add(amount.value, computedToGenerate.value); buyable.amount.value = Decimal.add(buyable.amount.value, 1); - options.dyesToReset.forEach(dye => dye.reset()); + if (!wrappingPaper.milestones.secondaryNoReset.earned) { + unref(costs).forEach(c => { + c.res.value = Decimal.sub( + c.res.value, + Decimal.pow(trueCost, unref(c.root ?? 1)).times(unref(c.base)) + ); + }); + options.dyesToReset.forEach(dye => dye.reset()); + } } }; }); diff --git a/src/data/layers/elves.tsx b/src/data/layers/elves.tsx index d165c4c..d8060fe 100644 --- a/src/data/layers/elves.tsx +++ b/src/data/layers/elves.tsx @@ -35,6 +35,8 @@ import paper from "./paper"; import plastic from "./plastic"; import trees from "./trees"; import workshop from "./workshop"; +import wrappingPaper from "./wrapping-paper"; +import dyes from "./dyes"; const id = "elves"; const day = 4; @@ -381,6 +383,14 @@ const layer = createLayer(id, function (this: BaseLayer) { })) ]); + const dyeCooldown = createSequentialModifier(() => [ + createMultiplicativeModifier(() => ({ + multiplier: Infinity, + description: "Dye", + enabled: () => true + })) + ]); + const [generalTab, generalTabCollapsed] = createCollapsibleModifierSections(() => [ { title: "Holly Auto-Buy Frequency", @@ -508,7 +518,7 @@ const layer = createLayer(id, function (this: BaseLayer) { )); const trainingCost = computed(() => { - let cost = Decimal.pow(4, totalElves.value).times(1e6); + let cost = Decimal.pow(Decimal.sub(4, wrappingPaper.boosts.jazzy1.value), totalElves.value).times(1e6); if (Decimal.gte(totalElves.value, 9)) { cost = Decimal.times(cost, 1e15); } @@ -520,13 +530,13 @@ const layer = createLayer(id, function (this: BaseLayer) { name: string; description: string; buyable: - | (GenericBuyable & { resource: Resource }) - | (GenericBuyable & { resource: Resource })[]; + | (GenericBuyable & { resource?: Resource }) + | (GenericBuyable & { resource?: Resource })[]; cooldownModifier: Modifier; customCost?: (amount: DecimalSource) => DecimalSource; hasToggle?: boolean; toggleDesc?: string; - onAutoPurchase?: (buyable: GenericBuyable & { resource: Resource }) => void; + onAutoPurchase?: (buyable: GenericBuyable & { resource?: Resource }) => void; onPurchase?: VoidFunction; // Will get overriden by the custom onpurchase, but that's fine canBuy?: Computable; buyMax?: Computable; @@ -550,12 +560,11 @@ const layer = createLayer(id, function (this: BaseLayer) { buyable => { while (buyMax ? true : Decimal.gte(buyProgress.value, cooldown)) { if ( - options.customCost == undefined - ? unref(buyable.canPurchase) - : Decimal.gte( - buyable.resource.value, - options.customCost(buyable.amount.value) - ) + options.customCost && buyable.resource + ? Decimal.gte( + buyable.resource.value, + options.customCost(buyable.amount.value) + ) : unref(buyable.canPurchase) ) { buyable.amount.value = Decimal.add(buyable.amount.value, 1); buyProgress.value = Decimal.sub(buyProgress.value, cooldown); @@ -830,6 +839,16 @@ const layer = createLayer(id, function (this: BaseLayer) { showIf(management.elfTraining.expandersElfTraining.milestones[4].earned.value) }); const managementElves2 = [metalElf]; + const dyeElf = createElf({ + name: "Carol", + description: + "Carol will automatically purchase all dyes you can afford, without actually spending any resources.", + buyable: Object.values(dyes.dyes).map(dye => dye.buyable), + cooldownModifier: dyeCooldown, // Note: Buy max will be unlocked at this point + visibility: () => + showIf(wrappingPaper.milestones.unlockDyeElf.earned.value) + }); + const wrappingPaperElves = [dyeElf]; const elves = { cuttersElf, plantersElf, @@ -846,7 +865,8 @@ const layer = createLayer(id, function (this: BaseLayer) { miningDrillElf, heavyDrillElf, oilElf, - metalElf + metalElf, + dyeElf, }; const totalElves = computed(() => Object.values(elves).filter(elf => elf.bought.value).length); @@ -1032,7 +1052,7 @@ const layer = createLayer(id, function (this: BaseLayer) { fireElves, plasticElves, managementElves, - managementElves2 + managementElves2.concat(wrappingPaperElves) )} {milestonesDisplay()} diff --git a/src/data/layers/paper.tsx b/src/data/layers/paper.tsx index 06d0223..fb28ed5 100644 --- a/src/data/layers/paper.tsx +++ b/src/data/layers/paper.tsx @@ -29,6 +29,7 @@ import trees from "./trees"; import dyes from "./dyes"; import management from "./management"; import workshop from "./workshop"; +import wrappingPaper from "./wrapping-paper"; const id = "paper"; const day = 5; @@ -225,6 +226,13 @@ const layer = createLayer(id, function (this: BaseLayer) { visibility: () => showIf(management.elfTraining.expandersElfTraining.milestones[4].earned.value) }); + const dyeBook = createBook({ + name: "Arts and Crafts", + elfName: "Carol", + buyableName: "Dye Buyables", + visibility: () => + showIf(elves.elves.dyeElf.bought.value) + }); const books = { cuttersBook, plantersBook, @@ -241,7 +249,8 @@ const layer = createLayer(id, function (this: BaseLayer) { miningDrillBook, heavyDrillBook, oilBook, - metalBook + metalBook, + dyeBook }; const sumBooks = computed(() => Object.values(books).reduce((acc, curr) => acc.add(curr.amount.value), new Decimal(0)) @@ -306,6 +315,11 @@ const layer = createLayer(id, function (this: BaseLayer) { multiplier: 2, description: "1000% Foundation Completed", enabled: workshop.milestones.extraExpansionMilestone5.earned + })), + createMultiplicativeModifier(() => ({ + multiplier: wrappingPaper.boosts.sunshine1, + description: "Sunshine Wrapping Paper", + enabled: () => Decimal.gte(wrappingPaper.boosts.sunshine1.value, 2) })) ]) as WithRequired; const ashCost = createSequentialModifier(() => [ diff --git a/src/data/layers/trees.tsx b/src/data/layers/trees.tsx index 478931e..77d224f 100644 --- a/src/data/layers/trees.tsx +++ b/src/data/layers/trees.tsx @@ -36,6 +36,7 @@ import elves from "./elves"; import management from "./management"; import paper from "./paper"; import workshop from "./workshop"; +import wrappingPaper from "./wrapping-paper"; const id = "trees"; const day = 1; @@ -505,6 +506,11 @@ const layer = createLayer(id, function (this: BaseLayer) { description: "Noel Level 1", enabled: management.elfTraining.fertilizerElfTraining.milestones[0].earned })), + createMultiplicativeModifier(() => ({ + multiplier: wrappingPaper.boosts.christmas1, + description: "Christmas Wrapping Paper", + enabled: computed(() => Decimal.gt(wrappingPaper.boosts.christmas1.value, 1)) + })), createExponentialModifier(() => ({ exponent: 1.2, description: "100% Foundation Completed", diff --git a/src/data/layers/workshop.tsx b/src/data/layers/workshop.tsx index e6f5e3a..bc73932 100644 --- a/src/data/layers/workshop.tsx +++ b/src/data/layers/workshop.tsx @@ -17,7 +17,7 @@ import { createHotkey } from "features/hotkey"; import { createMilestone } from "features/milestones/milestone"; import { createResource, displayResource } from "features/resources/resource"; import { BaseLayer, createLayer } from "game/layers"; -import { createExponentialModifier, createSequentialModifier } from "game/modifiers"; +import { createExponentialModifier, createMultiplicativeModifier, createSequentialModifier } from "game/modifiers"; import { noPersist } from "game/persistence"; import Decimal, { DecimalSource, format, formatWhole } from "util/bignum"; import { Direction } from "util/common"; @@ -26,6 +26,7 @@ import { computed, unref, watchEffect } from "vue"; import elves from "./elves"; import management from "./management"; import trees from "./trees"; +import wrappingPaper from "./wrapping-paper"; const id = "workshop"; const day = 2; @@ -50,8 +51,13 @@ const layer = createLayer(id, function (this: BaseLayer) { trees.logs.value = Decimal.sub(trees.logs.value, spent); }, costModifier: createSequentialModifier(() => [ + createMultiplicativeModifier(() => ({ + multiplier: computed(() => wrappingPaper.boosts.beach1.value), + description: "Beach Wrapping Paper", + enabled: computed(() => Decimal.gt(wrappingPaper.boosts.beach1.value,1)) + })), createExponentialModifier(() => ({ - exponent: 0.95, + exponent: 0.95, // Needs fixing description: "Holly Level 5", enabled: management.elfTraining.cutterElfTraining.milestones[4].earned })) diff --git a/vite.config.ts b/vite.config.ts index 8c4992e..3772079 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,7 +19,6 @@ export default defineConfig({ } } }, - server: { hmr: { clientPort: process.env.CODESPACES ? 443 : undefined } }, resolve: { alias: { vue: "vue/dist/vue.esm-bundler.js"