More migrating

This commit is contained in:
thepaperpilot 2023-04-02 22:19:15 -05:00
parent 86d80dd462
commit a646a30412
2 changed files with 30 additions and 33 deletions

View file

@ -25,7 +25,7 @@ import MainDisplay from "features/resources/MainDisplay.vue";
import Resource from "features/resources/Resource.vue"; import Resource from "features/resources/Resource.vue";
import { createResource, displayResource, trackBest } from "features/resources/resource"; import { createResource, displayResource, trackBest } from "features/resources/resource";
import { createTab } from "features/tabs/tab"; import { createTab } from "features/tabs/tab";
import { createTabFamily } from "features/tabs/tabFamily"; import { GenericTabFamily, createTabFamily } from "features/tabs/tabFamily";
import { addTooltip } from "features/tooltips/tooltip"; import { addTooltip } from "features/tooltips/tooltip";
import { import {
GenericTreeNode, GenericTreeNode,
@ -35,7 +35,7 @@ import {
createTreeNode createTreeNode
} from "features/trees/tree"; } from "features/trees/tree";
import { createUpgrade } from "features/upgrades/upgrade"; import { createUpgrade } from "features/upgrades/upgrade";
import Formula from "game/formulas/formulas"; import Formula, { calculateCost } from "game/formulas/formulas";
import { createLayer } from "game/layers"; import { createLayer } from "game/layers";
import { import {
createAdditiveModifier, createAdditiveModifier,
@ -43,7 +43,7 @@ import {
createModifierSection, createModifierSection,
createSequentialModifier createSequentialModifier
} from "game/modifiers"; } from "game/modifiers";
import { persistent } from "game/persistence"; import { noPersist, persistent } from "game/persistence";
import { createCostRequirement } from "game/requirements"; import { createCostRequirement } from "game/requirements";
import settings from "game/settings"; import settings from "game/settings";
import { DecimalSource } from "lib/break_eternity"; import { DecimalSource } from "lib/break_eternity";
@ -52,6 +52,7 @@ import { Direction } from "util/common";
import { render, renderCol, renderRow } from "util/vue"; import { render, renderCol, renderRow } from "util/vue";
import { ComputedRef, Ref, computed, ref, unref } from "vue"; import { ComputedRef, Ref, computed, ref, unref } from "vue";
import f from "./f"; import f from "./f";
import { ProcessedComputable } from "util/computed";
const id = "c"; const id = "c";
const layer = createLayer(id, () => { const layer = createLayer(id, () => {
@ -160,7 +161,7 @@ const layer = createLayer(id, () => {
}, },
requirements: createCostRequirement(() => ({ requirements: createCostRequirement(() => ({
cost: 1, cost: 1,
resource: points resource: noPersist(points)
})) }))
})); }));
const lollipopMultiplierUpgrade = createUpgrade(() => ({ const lollipopMultiplierUpgrade = createUpgrade(() => ({
@ -170,7 +171,7 @@ const layer = createLayer(id, () => {
}), }),
requirements: createCostRequirement(() => ({ requirements: createCostRequirement(() => ({
cost: 1, cost: 1,
resource: points resource: noPersist(points)
})), })),
visibility: generatorUpgrade.bought visibility: generatorUpgrade.bought
})); }));
@ -215,7 +216,7 @@ const layer = createLayer(id, () => {
const exhancers = createRepeatable(() => ({ const exhancers = createRepeatable(() => ({
requirements: createCostRequirement(() => ({ requirements: createCostRequirement(() => ({
resource: points, resource: noPersist(points),
cost() { cost() {
let x = new Decimal(exhancers.amount.value); let x = new Decimal(exhancers.amount.value);
if (x.gte(25)) { if (x.gte(25)) {
@ -225,16 +226,7 @@ const layer = createLayer(id, () => {
return cost.floor(); return cost.floor();
}, },
pay(amount) { pay(amount) {
const cost = const cost = unref(this.cost as unknown as ProcessedComputable<DecimalSource>);
this.cost instanceof Formula
? calculateCost(
this.cost,
amount ?? 1,
unref(
this.spendResources as ProcessedComputable<boolean> | undefined
) ?? true
)
: unref(this.cost as ProcessedComputable<DecimalSource>);
spentOnBuyables.value = Decimal.add(spentOnBuyables.value, cost ?? 0); spentOnBuyables.value = Decimal.add(spentOnBuyables.value, cost ?? 0);
this.resource.value = Decimal.sub(this.resource.value, cost).max(0); this.resource.value = Decimal.sub(this.resource.value, cost).max(0);
} }
@ -385,15 +377,16 @@ const layer = createLayer(id, () => {
createAdditiveModifier(() => ({ addend: 1, description: "Nice modifier" })) createAdditiveModifier(() => ({ addend: 1, description: "Nice modifier" }))
]); ]);
const conversion = createCumulativeConversion(() => ({ const conversion = createCumulativeConversion(() => ({
formula: modifierToFormula( formula: x =>
modifierToFormula(
conversionModifier, conversionModifier,
Formula.variable(0) x
.div(10) .div(10)
.sqrt() .sqrt()
.step(1e100, f => f.sqrt()) .step(1e100, f => f.sqrt())
), ),
baseResource: main.points, baseResource: main.points,
gainResource: points, gainResource: noPersist(points),
roundUpCost: true roundUpCost: true
})); }));
@ -439,7 +432,7 @@ const layer = createLayer(id, () => {
textDecoration: "underline" textDecoration: "underline"
} }
})); }));
addTooltip(treeNode, { const treeNodeTooltip = addTooltip(treeNode, {
display: createResourceTooltip(points), display: createResourceTooltip(points),
pinnable: true pinnable: true
}); });
@ -453,7 +446,7 @@ const layer = createLayer(id, () => {
}, },
resetDescription: "Melt your points into " resetDescription: "Melt your points into "
})); }));
addTooltip(resetButton, { const resetButtonTooltip = addTooltip(resetButton, {
display: jsx(() => display: jsx(() =>
createModifierSection({ createModifierSection({
title: "Modifiers", title: "Modifiers",
@ -565,7 +558,7 @@ const layer = createLayer(id, () => {
marginRight: "auto" marginRight: "auto"
} }
}) })
); ) as GenericTabFamily;
const tabs = createTabFamily({ const tabs = createTabFamily({
mainTab: () => ({ mainTab: () => ({
@ -722,6 +715,7 @@ const layer = createLayer(id, () => {
quasiUpgrade, quasiUpgrade,
exhancers, exhancers,
respecBuyables, respecBuyables,
illuminatiTabs,
sellExhancer, sellExhancer,
bars: { tallBoi, longBoi, flatBoi }, bars: { tallBoi, longBoi, flatBoi },
tree, tree,
@ -741,7 +735,9 @@ const layer = createLayer(id, () => {
{render(tabs)} {render(tabs)}
{render(links)} {render(links)}
</> </>
)) )),
treeNodeTooltip,
resetButtonTooltip
}; };
}); });

View file

@ -13,7 +13,7 @@ import { addTooltip } from "features/tooltips/tooltip";
import { createResourceTooltip } from "features/trees/tree"; import { createResourceTooltip } from "features/trees/tree";
import Formula from "game/formulas/formulas"; import Formula from "game/formulas/formulas";
import { createLayer } from "game/layers"; import { createLayer } from "game/layers";
import { persistent } from "game/persistence"; import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, formatWhole } from "util/bignum"; import Decimal, { DecimalSource, formatWhole } from "util/bignum";
import { render, renderRow } from "util/vue"; import { render, renderRow } from "util/vue";
import { ref } from "vue"; import { ref } from "vue";
@ -109,9 +109,9 @@ const layer = createLayer(id, () => {
})); }));
const conversion = createIndependentConversion(() => ({ const conversion = createIndependentConversion(() => ({
formula: Formula.variable(0).div(10).sqrt().times(c.otherThingy), formula: x => x.div(10).sqrt().times(c.otherThingy),
baseResource: main.points, baseResource: main.points,
gainResource: points gainResource: noPersist(points)
})); }));
const treeNode = createLayerTreeNode(() => ({ const treeNode = createLayerTreeNode(() => ({
@ -130,7 +130,7 @@ const layer = createLayer(id, () => {
return Decimal.gte(main.points.value, 10); return Decimal.gte(main.points.value, 10);
} }
})); }));
addTooltip(treeNode, { const tooltip = addTooltip(treeNode, {
display: createResourceTooltip(points), display: createResourceTooltip(points),
pinnable: true pinnable: true
}); });
@ -201,7 +201,8 @@ const layer = createLayer(id, () => {
treeNode, treeNode,
resetButton, resetButton,
minWidth: 650, minWidth: 650,
display: tab display: tab,
tooltip
}; };
}); });