From b1e1875651605bcb63fa839c2499f7495cbe37ec Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Mon, 12 Dec 2022 19:02:55 -0600 Subject: [PATCH 1/5] Added books for new elves --- src/data/layers/elves.tsx | 30 +++++++++++++++--------------- src/data/layers/paper.tsx | 23 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/data/layers/elves.tsx b/src/data/layers/elves.tsx index c6dca5a..7eb2a81 100644 --- a/src/data/layers/elves.tsx +++ b/src/data/layers/elves.tsx @@ -318,11 +318,11 @@ const layer = createLayer(id, function (this: BaseLayer) { description: "6 Elves Trained", enabled: elvesMilestone.earned })), - // createMultiplicativeModifier(() => ({ - // multiplier: () => Decimal.times(paper.books.clothBook.amount.value, 0.1).add(1), - // description: "Fuzzy Bee and Friends", - // enabled: () => Decimal.gt(paper.books.clothBook.amount.value, 0) - // })), + createMultiplicativeModifier(() => ({ + multiplier: () => Decimal.times(paper.books.miningDrillBook.amount.value, 0.1).add(1), + description: "Drills and Mills", + enabled: () => Decimal.gt(paper.books.miningDrillBook.amount.value, 0) + })), createMultiplicativeModifier(() => ({ multiplier: 2, description: "10 Elves Trained", @@ -335,11 +335,11 @@ const layer = createLayer(id, function (this: BaseLayer) { description: "6 Elves Trained", enabled: elvesMilestone.earned })), - // createMultiplicativeModifier(() => ({ - // multiplier: () => Decimal.times(paper.books.clothBook.amount.value, 0.1).add(1), - // description: "Fuzzy Bee and Friends", - // enabled: () => Decimal.gt(paper.books.clothBook.amount.value, 0) - // })), + createMultiplicativeModifier(() => ({ + multiplier: () => Decimal.times(paper.books.metalBook.amount.value, 0.1).add(1), + description: "Physical Metallurgy", + enabled: () => Decimal.gt(paper.books.metalBook.amount.value, 0) + })), createMultiplicativeModifier(() => ({ multiplier: 2, description: "10 Elves Trained", @@ -352,11 +352,11 @@ const layer = createLayer(id, function (this: BaseLayer) { description: "6 Elves Trained", enabled: elvesMilestone.earned })), - // createMultiplicativeModifier(() => ({ - // multiplier: () => Decimal.times(paper.books.clothBook.amount.value, 0.1).add(1), - // description: "Fuzzy Bee and Friends", - // enabled: () => Decimal.gt(paper.books.clothBook.amount.value, 0) - // })), + createMultiplicativeModifier(() => ({ + multiplier: () => Decimal.times(paper.books.heavyDrillBook.amount.value, 0.1).add(1), + description: "Deep in the Earth", + enabled: () => Decimal.gt(paper.books.heavyDrillBook.amount.value, 0) + })), createMultiplicativeModifier(() => ({ multiplier: 2, description: "10 Elves Trained", diff --git a/src/data/layers/paper.tsx b/src/data/layers/paper.tsx index 94022e3..6edcfe8 100644 --- a/src/data/layers/paper.tsx +++ b/src/data/layers/paper.tsx @@ -187,6 +187,24 @@ const layer = createLayer(id, function (this: BaseLayer) { buyableName: "Cloth Buyables", visibility: () => showIf(elves.elves.clothElf.bought.value) }); + const miningDrillBook = createBook({ + name: "Drills and Mills", + elfName: "Peppermint", + buyableName: "Mining Drill", + visibility: () => showIf(management.elfTraining.expandersElfTraining.milestones[3].earned.value) + }); + const metalBook = createBook({ + name: "Physical Metallurgy", + elfName: "Twinkle", + buyableName: "Metal Buyables", + visibility: () => showIf(management.elfTraining.expandersElfTraining.milestones[4].earned.value) + }); + const heavyDrillBook = createBook({ + name: "Deep in the Earth", + elfName: "Frosty", + buyableName: "Oil Drills", + visibility: () => showIf(management.elfTraining.heatedCutterElfTraining.milestones[4].earned.value) + }); const books = { cuttersBook, plantersBook, @@ -199,7 +217,10 @@ const layer = createLayer(id, function (this: BaseLayer) { kilnBook, paperBook, boxBook, - clothBook + clothBook, + miningDrillBook, + metalBook, + heavyDrillBook }; const sumBooks = computed(() => Object.values(books).reduce((acc, curr) => acc.add(curr.amount.value), new Decimal(0))); From 872d6208b682d3c14ed9972a017f9badeba4acb7 Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Mon, 12 Dec 2022 19:21:35 -0600 Subject: [PATCH 2/5] Fixed upgrades costing trees --- src/data/layers/management.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/layers/management.tsx b/src/data/layers/management.tsx index a114018..1e4d610 100644 --- a/src/data/layers/management.tsx +++ b/src/data/layers/management.tsx @@ -972,7 +972,7 @@ const layer = createLayer(id, () => { title: "Focus Booster", description: "Double experience multiplier from focus" }, - resource: trees.trees, + resource: trees.logs, cost: 1e30 })); const focusUpgrade2 = createUpgrade(() => ({ @@ -980,7 +980,7 @@ const layer = createLayer(id, () => { title: "Focus Buffer", description: "Increase elves affected by focus by 1" }, - resource: trees.trees, + resource: trees.logs, cost: 1e40 })); const focusUpgrade3 = createUpgrade(() => ({ @@ -988,7 +988,7 @@ const layer = createLayer(id, () => { title: "Focus Upgrader", description: "Focus can now be rerolled every 10 seconds" }, - resource: trees.trees, + resource: trees.logs, cost: 1e50 })); const upgrades = { focusUpgrade1, focusUpgrade2, focusUpgrade3 }; From 2803a997365d3929169ef9af3d13f7d9c93c1c72 Mon Sep 17 00:00:00 2001 From: Anthony Lawn Date: Mon, 12 Dec 2022 19:40:14 -0600 Subject: [PATCH 3/5] Fix infinite recursion --- src/data/layers/trees.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/layers/trees.tsx b/src/data/layers/trees.tsx index 0d17f64..5e67dae 100644 --- a/src/data/layers/trees.tsx +++ b/src/data/layers/trees.tsx @@ -329,9 +329,9 @@ const layer = createLayer(id, function (this: BaseLayer) { ]) as WithRequired; const computedAutoCuttingAmount = computed(() => autoCuttingAmount.apply(0)); const lastAutoCuttingAmount = ref(0); - watch(computedAutoCuttingAmount, cut => { + setInterval(() => watch(computedAutoCuttingAmount, cut => { lastAutoCuttingAmount.value = cut; - }); + }), 0); const manualPlantingAmount = createSequentialModifier(() => [ createAdditiveModifier(() => ({ @@ -420,9 +420,9 @@ const layer = createLayer(id, function (this: BaseLayer) { ]) as WithRequired; const computedAutoPlantingAmount = computed(() => autoPlantingAmount.apply(0)); const lastAutoPlantedAmount = ref(0); - watch(computedAutoPlantingAmount, planted => { + setInterval(() => watch(computedAutoPlantingAmount, planted => { lastAutoPlantedAmount.value = planted; - }); + }), 0); const logGain = createSequentialModifier(() => [ createMultiplicativeModifier(() => ({ From 8d6fd36e90910fc952323db1c33caa51402a2dfb Mon Sep 17 00:00:00 2001 From: circle-gon <97845741+circle-gon@users.noreply.github.com> Date: Tue, 13 Dec 2022 02:01:07 +0000 Subject: [PATCH 4/5] more clarifications --- src/data/layers/management.tsx | 60 +++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/data/layers/management.tsx b/src/data/layers/management.tsx index 1e4d610..bacdb0b 100644 --- a/src/data/layers/management.tsx +++ b/src/data/layers/management.tsx @@ -12,7 +12,12 @@ import { createMilestone, GenericMilestone } from "features/milestones/milestone import { createUpgrade } from "features/upgrades/upgrade"; import { globalBus } from "game/events"; import { createLayer } from "game/layers"; -import { createMultiplicativeModifier, createSequentialModifier, Modifier } from "game/modifiers"; +import { + createAdditiveModifier, + createMultiplicativeModifier, + createSequentialModifier, + Modifier +} from "game/modifiers"; import { persistent } from "game/persistence"; import Decimal, { DecimalSource, format, formatTime, formatWhole } from "util/bignum"; import { Direction } from "util/common"; @@ -896,12 +901,11 @@ const layer = createLayer(id, () => { } focusTime.value = Math.max(focusTime.value - diff, 0); focusCooldown.value = Math.max(focusCooldown.value - diff, 0); - if (focusTime.value > 0) { + if (focusTime.value === 0) { focusMulti.value = Decimal.pow( focusMaxMulti.value, 1 - Math.abs(Math.sin((Date.now() / 1000) * 2)) ); - } }); @@ -912,7 +916,32 @@ const layer = createLayer(id, () => { const focusCooldown = persistent(0); const focusTime = persistent(0); - const focusMaxMulti = computed(() => focusUpgrade1.bought.value ? 20 : 10); + const focusMaxMultiModifiers = createSequentialModifier(() => [ + createMultiplicativeModifier(() => ({ + multiplier: 2, + description: "Focus Upgrade 1", + enabled: focusUpgrade1.bought + })) + ]); + const maximumElvesModifier = createSequentialModifier(() => [ + createAdditiveModifier(() => ({ + addend: 1, + description: "Focus Upgrade 2", + enabled: focusUpgrade2.bought + })) + ]); + + const cooldownModifiers = createSequentialModifier(() => [ + createAdditiveModifier(() => ({ + addend: -5, + description: "Focus Upgrade 3", + enabled: focusUpgrade3.bought + })) + ]); + + const focusMaxMulti = computed(() => focusMaxMultiModifiers.apply(10)); + const maximumElves = computed(() => maximumElvesModifier.apply(3)); + const cooldown = computed(() => cooldownModifiers.apply(15)); const focusMeter = createBar(() => ({ direction: Direction.Right, @@ -949,9 +978,9 @@ const layer = createLayer(id, () => { }, canClick: () => focusCooldown.value === 0, onClick() { - focusCooldown.value = focusUpgrade3.bought.value ? 10 : 15; + focusCooldown.value = cooldown.value; focusTime.value = 10; - rerollFocusTargets(12, focusUpgrade2.bought.value ? 4 : 3); + rerollFocusTargets(12, maximumElves.value); } })); @@ -970,7 +999,7 @@ const layer = createLayer(id, () => { const focusUpgrade1 = createUpgrade(() => ({ display: { title: "Focus Booster", - description: "Double experience multiplier from focus" + description: "Multiplies the maximum experience multiplier from focus by 2" }, resource: trees.logs, cost: 1e30 @@ -1131,6 +1160,22 @@ const layer = createLayer(id, () => { // ------------------------------------------------------------------------------- Modifiers const [generalTab, generalTabCollapsed] = createCollapsibleModifierSections(() => [ + { + title: "Elves affected by Focus", + modifier: maximumElvesModifier, + base: 3 + }, + { + title: "Maximum Focus Effect", + modifier: focusMaxMultiModifiers, + base: 10 + }, + { + title: "Focus Cooldown", + modifier: cooldownModifiers, + unit: " secs", + base: 15 + }, { title: "Global XP Gain", modifier: globalXPModifier, @@ -1244,7 +1289,6 @@ const layer = createLayer(id, () => { focusTargets, focusCooldown, focusTime, - display: jsx(() => ( <> From efbe9ab9c9b97f3db9448783304f3195026b4e3a Mon Sep 17 00:00:00 2001 From: circle-gon <97845741+circle-gon@users.noreply.github.com> Date: Tue, 13 Dec 2022 02:08:18 +0000 Subject: [PATCH 5/5] changes most things to be DecimalSource not number --- src/data/layers/management.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/data/layers/management.tsx b/src/data/layers/management.tsx index bacdb0b..8a3a299 100644 --- a/src/data/layers/management.tsx +++ b/src/data/layers/management.tsx @@ -165,7 +165,7 @@ const layer = createLayer(id, () => { createMultiplicativeModifier(() => ({ multiplier: focusMulti, description: "Focus Multiplier", - enabled: () => focusTime.value > 0 && focusTargets.value[elf.name] == true + enabled: () => Decimal.gt(focusTime.value, 0) && focusTargets.value[elf.name] == true })), ...modifiers ]); @@ -899,9 +899,9 @@ const layer = createLayer(id, () => { ); } } - focusTime.value = Math.max(focusTime.value - diff, 0); - focusCooldown.value = Math.max(focusCooldown.value - diff, 0); - if (focusTime.value === 0) { + focusTime.value = Decimal.sub(focusTime.value, diff).max(0) + focusCooldown.value = Decimal.sub(focusCooldown.value, diff).max(0) + if (Decimal.eq(focusTime.value, 0)) { focusMulti.value = Decimal.pow( focusMaxMulti.value, 1 - Math.abs(Math.sin((Date.now() / 1000) * 2)) @@ -913,8 +913,8 @@ const layer = createLayer(id, () => { const focusMulti = persistent(1); const focusTargets = persistent>({}); - const focusCooldown = persistent(0); - const focusTime = persistent(0); + const focusCooldown = persistent(0); + const focusTime = persistent(0); const focusMaxMultiModifiers = createSequentialModifier(() => [ createMultiplicativeModifier(() => ({ @@ -941,7 +941,7 @@ const layer = createLayer(id, () => { const focusMaxMulti = computed(() => focusMaxMultiModifiers.apply(10)); const maximumElves = computed(() => maximumElvesModifier.apply(3)); - const cooldown = computed(() => cooldownModifiers.apply(15)); + const cooldown = computed(() => Number(cooldownModifiers.apply(15))); const focusMeter = createBar(() => ({ direction: Direction.Right, @@ -962,7 +962,7 @@ const layer = createLayer(id, () => { <> Motivate elves to focus, multiplying 3 random elves' XP gain by up to{" "} {format(focusMaxMulti.value)}x, equal to the focus bars' effect. - {focusCooldown.value > 0 ? ( + {Decimal.gte(focusCooldown.value, 0) ? ( <>
Reroll cooldown: {formatTime(focusCooldown.value)} @@ -976,19 +976,21 @@ const layer = createLayer(id, () => { style: { width: "300px" }, - canClick: () => focusCooldown.value === 0, + canClick: () => Decimal.eq(focusCooldown.value, 0), onClick() { focusCooldown.value = cooldown.value; focusTime.value = 10; + + // better choice? this has to be a number rerollFocusTargets(12, maximumElves.value); } })); - function rerollFocusTargets(range: number, count: number) { + function rerollFocusTargets(range: number, count: DecimalSource) { let x = 0; focusTargets.value = {}; - count = Math.min(count, range); - while (x < count) { + const newCount = Decimal.min(count, range) + while (newCount.gte(x)) { const roll = Object.values(elfTraining)[Math.floor(Math.random() * range)]?.name ?? ""; if (!focusTargets.value[roll]) { focusTargets.value[roll] = true;