Migrating
This commit is contained in:
parent
61f0eace25
commit
dd666be634
3 changed files with 112 additions and 78 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import Modal from "components/Modal.vue";
|
||||||
import Slider from "components/fields/Slider.vue";
|
import Slider from "components/fields/Slider.vue";
|
||||||
import Text from "components/fields/Text.vue";
|
import Text from "components/fields/Text.vue";
|
||||||
import Toggle from "components/fields/Toggle.vue";
|
import Toggle from "components/fields/Toggle.vue";
|
||||||
|
@ -6,41 +7,36 @@ import Row from "components/layout/Row.vue";
|
||||||
import Spacer from "components/layout/Spacer.vue";
|
import Spacer from "components/layout/Spacer.vue";
|
||||||
import Sticky from "components/layout/Sticky.vue";
|
import Sticky from "components/layout/Sticky.vue";
|
||||||
import VerticalRule from "components/layout/VerticalRule.vue";
|
import VerticalRule from "components/layout/VerticalRule.vue";
|
||||||
import Modal from "components/Modal.vue";
|
import { createLayerTreeNode, createResetButton, modifierToFormula } from "data/common";
|
||||||
import { createLayerTreeNode, createResetButton } from "data/common";
|
|
||||||
import { main } from "data/projEntry";
|
import { main } from "data/projEntry";
|
||||||
import themes from "data/themes";
|
import themes from "data/themes";
|
||||||
import { createBar } from "features/bars/bar";
|
import { createBar } from "features/bars/bar";
|
||||||
import { createBuyable } from "features/buyable";
|
|
||||||
import { createChallenge } from "features/challenges/challenge";
|
import { createChallenge } from "features/challenges/challenge";
|
||||||
import { createClickable } from "features/clickables/clickable";
|
import { createClickable } from "features/clickables/clickable";
|
||||||
import {
|
import { createCumulativeConversion } from "features/conversion";
|
||||||
addSoftcap,
|
import { Visibility, jsx } from "features/feature";
|
||||||
createCumulativeConversion,
|
|
||||||
createPolynomialScaling
|
|
||||||
} from "features/conversion";
|
|
||||||
import { jsx, showIf, Visibility } from "features/feature";
|
|
||||||
import { createHotkey } from "features/hotkey";
|
import { createHotkey } from "features/hotkey";
|
||||||
import { createInfobox } from "features/infoboxes/infobox";
|
import { createInfobox } from "features/infoboxes/infobox";
|
||||||
import { createLinks } from "features/links/links";
|
import { createLinks } from "features/links/links";
|
||||||
import { createMilestone } from "features/milestones/milestone";
|
import { createMilestone } from "features/milestones/milestone";
|
||||||
|
import { createRepeatable } from "features/repeatable";
|
||||||
import { createReset } from "features/reset";
|
import { createReset } from "features/reset";
|
||||||
import MainDisplay from "features/resources/MainDisplay.vue";
|
import MainDisplay from "features/resources/MainDisplay.vue";
|
||||||
import { createResource, displayResource, trackBest } from "features/resources/resource";
|
|
||||||
import Resource from "features/resources/Resource.vue";
|
import Resource from "features/resources/Resource.vue";
|
||||||
|
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 { createTabFamily } from "features/tabs/tabFamily";
|
||||||
import { addTooltip } from "features/tooltips/tooltip";
|
import { addTooltip } from "features/tooltips/tooltip";
|
||||||
import {
|
import {
|
||||||
|
GenericTreeNode,
|
||||||
|
TreeBranch,
|
||||||
createResourceTooltip,
|
createResourceTooltip,
|
||||||
createTree,
|
createTree,
|
||||||
createTreeNode,
|
createTreeNode
|
||||||
GenericTreeNode,
|
|
||||||
TreeBranch
|
|
||||||
} 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 { createLayer } from "game/layers";
|
import { createLayer } from "game/layers";
|
||||||
import type { Modifier } from "game/modifiers";
|
|
||||||
import {
|
import {
|
||||||
createAdditiveModifier,
|
createAdditiveModifier,
|
||||||
createExponentialModifier,
|
createExponentialModifier,
|
||||||
|
@ -48,13 +44,13 @@ import {
|
||||||
createSequentialModifier
|
createSequentialModifier
|
||||||
} from "game/modifiers";
|
} from "game/modifiers";
|
||||||
import { persistent } from "game/persistence";
|
import { persistent } from "game/persistence";
|
||||||
|
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";
|
||||||
import Decimal, { format, formatWhole } from "util/bignum";
|
import Decimal, { format, formatWhole } from "util/bignum";
|
||||||
import type { WithRequired } from "util/common";
|
|
||||||
import { Direction } from "util/common";
|
import { Direction } from "util/common";
|
||||||
import { render, renderCol, renderRow } from "util/vue";
|
import { render, renderCol, renderRow } from "util/vue";
|
||||||
import { computed, ComputedRef, ref } from "vue";
|
import { ComputedRef, Ref, computed, ref, unref } from "vue";
|
||||||
import f from "./f";
|
import f from "./f";
|
||||||
|
|
||||||
const id = "c";
|
const id = "c";
|
||||||
|
@ -89,9 +85,7 @@ const layer = createLayer(id, () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
const lollipopMilestone4 = createMilestone(() => ({
|
const lollipopMilestone4 = createMilestone(() => ({
|
||||||
visibility() {
|
visibility: lollipopMilestone3.earned,
|
||||||
return showIf(lollipopMilestone3.earned.value);
|
|
||||||
},
|
|
||||||
shouldEarn() {
|
shouldEarn() {
|
||||||
return Decimal.gte(best.value, 4);
|
return Decimal.gte(best.value, 4);
|
||||||
},
|
},
|
||||||
|
@ -114,7 +108,7 @@ const layer = createLayer(id, () => {
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
style() {
|
style() {
|
||||||
if (this.earned) {
|
if (unref(this.earned)) {
|
||||||
return { backgroundColor: "#1111DD" };
|
return { backgroundColor: "#1111DD" };
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -124,6 +118,11 @@ const layer = createLayer(id, () => {
|
||||||
|
|
||||||
const funChallenge = createChallenge(() => ({
|
const funChallenge = createChallenge(() => ({
|
||||||
title: "Fun",
|
title: "Fun",
|
||||||
|
requirements: createCostRequirement(() => ({
|
||||||
|
resource: main.points,
|
||||||
|
cost: 20,
|
||||||
|
spendResources: false
|
||||||
|
})),
|
||||||
completionLimit: 3,
|
completionLimit: 3,
|
||||||
display() {
|
display() {
|
||||||
return {
|
return {
|
||||||
|
@ -135,11 +134,7 @@ const layer = createLayer(id, () => {
|
||||||
effectDisplay: format(funEffect.value) + "x"
|
effectDisplay: format(funEffect.value) + "x"
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
visibility() {
|
visibility: () => Decimal.gt(best.value, 0),
|
||||||
return showIf(Decimal.gt(best.value, 0));
|
|
||||||
},
|
|
||||||
goal: 20,
|
|
||||||
resource: main.points,
|
|
||||||
onComplete() {
|
onComplete() {
|
||||||
console.log("hiii");
|
console.log("hiii");
|
||||||
},
|
},
|
||||||
|
@ -163,17 +158,21 @@ const layer = createLayer(id, () => {
|
||||||
title: "Generator of Genericness",
|
title: "Generator of Genericness",
|
||||||
description: "Gain 1 point every second"
|
description: "Gain 1 point every second"
|
||||||
},
|
},
|
||||||
cost: 1,
|
requirements: createCostRequirement(() => ({
|
||||||
resource: points
|
cost: 1,
|
||||||
|
resource: points
|
||||||
|
}))
|
||||||
}));
|
}));
|
||||||
const lollipopMultiplierUpgrade = createUpgrade(() => ({
|
const lollipopMultiplierUpgrade = createUpgrade(() => ({
|
||||||
display: () => ({
|
display: () => ({
|
||||||
description: "Point generation is faster based on your unspent Lollipops",
|
description: "Point generation is faster based on your unspent Lollipops",
|
||||||
effectDisplay: `${format(lollipopMultiplierEffect.value)}x`
|
effectDisplay: `${format(lollipopMultiplierEffect.value)}x`
|
||||||
}),
|
}),
|
||||||
cost: 1,
|
requirements: createCostRequirement(() => ({
|
||||||
resource: points,
|
cost: 1,
|
||||||
visibility: () => showIf(generatorUpgrade.bought.value)
|
resource: points
|
||||||
|
})),
|
||||||
|
visibility: generatorUpgrade.bought
|
||||||
}));
|
}));
|
||||||
const lollipopMultiplierEffect = computed(() => {
|
const lollipopMultiplierEffect = computed(() => {
|
||||||
let ret = Decimal.add(points.value, 1).pow(0.5);
|
let ret = Decimal.add(points.value, 1).pow(0.5);
|
||||||
|
@ -181,30 +180,32 @@ const layer = createLayer(id, () => {
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
const unlockIlluminatiUpgrade = createUpgrade(() => ({
|
const unlockIlluminatiUpgrade = createUpgrade(() => ({
|
||||||
visibility() {
|
visibility: lollipopMultiplierUpgrade.bought,
|
||||||
return showIf(lollipopMultiplierUpgrade.bought.value);
|
requirements: createCostRequirement(() => ({
|
||||||
},
|
cost: 7,
|
||||||
canAfford() {
|
resource: main.points,
|
||||||
return Decimal.lt(main.points.value, 7);
|
requiresPay: false
|
||||||
},
|
})),
|
||||||
onPurchase() {
|
onPurchase() {
|
||||||
main.points.value = Decimal.add(main.points.value, 7);
|
main.points.value = Decimal.add(main.points.value, 7);
|
||||||
},
|
},
|
||||||
display:
|
display:
|
||||||
"Only buyable with less than 7 points, and gives you 7 more. Unlocks a secret subtab.",
|
"Only buyable with less than 7 points, and gives you 7 more. Unlocks a secret subtab.",
|
||||||
style() {
|
style() {
|
||||||
if (this.bought) {
|
if (unref(this.bought)) {
|
||||||
return { backgroundColor: "#1111dd" };
|
return { backgroundColor: "#1111dd" };
|
||||||
}
|
}
|
||||||
if (!this.canAfford) {
|
if (!unref(this.canPurchase)) {
|
||||||
return { backgroundColor: "#dd1111" };
|
return { backgroundColor: "#dd1111" };
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
const quasiUpgrade = createUpgrade(() => ({
|
const quasiUpgrade = createUpgrade(() => ({
|
||||||
resource: createResource(exhancers.amount, "Exhancers", 0),
|
requirements: createCostRequirement(() => ({
|
||||||
cost: 3,
|
resource: createResource(exhancers.amount, "Exhancers", 0),
|
||||||
|
cost: 3
|
||||||
|
})),
|
||||||
display: {
|
display: {
|
||||||
title: "This upgrade doesn't exist",
|
title: "This upgrade doesn't exist",
|
||||||
description: "Or does it?"
|
description: "Or does it?"
|
||||||
|
@ -212,16 +213,32 @@ const layer = createLayer(id, () => {
|
||||||
}));
|
}));
|
||||||
const upgrades = [generatorUpgrade, lollipopMultiplierUpgrade, unlockIlluminatiUpgrade];
|
const upgrades = [generatorUpgrade, lollipopMultiplierUpgrade, unlockIlluminatiUpgrade];
|
||||||
|
|
||||||
const exhancers = createBuyable(() => ({
|
const exhancers = createRepeatable(() => ({
|
||||||
resource: points,
|
requirements: createCostRequirement(() => ({
|
||||||
cost() {
|
resource: points,
|
||||||
let x = new Decimal(this.amount.value);
|
cost() {
|
||||||
if (x.gte(25)) {
|
let x = new Decimal(exhancers.amount.value);
|
||||||
x = x.pow(2).div(25);
|
if (x.gte(25)) {
|
||||||
|
x = x.pow(2).div(25);
|
||||||
|
}
|
||||||
|
const cost = Decimal.pow(2, x.pow(1.5));
|
||||||
|
return cost.floor();
|
||||||
|
},
|
||||||
|
pay(amount) {
|
||||||
|
const cost =
|
||||||
|
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);
|
||||||
|
this.resource.value = Decimal.sub(this.resource.value, cost).max(0);
|
||||||
}
|
}
|
||||||
const cost = Decimal.pow(2, x.pow(1.5));
|
})),
|
||||||
return cost.floor();
|
|
||||||
},
|
|
||||||
display() {
|
display() {
|
||||||
return {
|
return {
|
||||||
title: "Exhancers",
|
title: "Exhancers",
|
||||||
|
@ -230,9 +247,6 @@ const layer = createLayer(id, () => {
|
||||||
)} things and multiplies stuff by ${format(stuffEffect.value)}.`
|
)} things and multiplies stuff by ${format(stuffEffect.value)}.`
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onPurchase(cost) {
|
|
||||||
spentOnBuyables.value = Decimal.add(spentOnBuyables.value, cost ?? 0);
|
|
||||||
},
|
|
||||||
style: { height: "222px" },
|
style: { height: "222px" },
|
||||||
purchaseLimit: 4
|
purchaseLimit: 4
|
||||||
}));
|
}));
|
||||||
|
@ -274,8 +288,9 @@ const layer = createLayer(id, () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
exhancers.amount.value = Decimal.sub(exhancers.amount.value, 1);
|
exhancers.amount.value = Decimal.sub(exhancers.amount.value, 1);
|
||||||
points.value = Decimal.add(points.value, exhancers.cost.value);
|
const cost = (exhancers.requirements.cost as Ref<DecimalSource>).value;
|
||||||
spentOnBuyables.value = Decimal.sub(spentOnBuyables.value, exhancers.cost.value);
|
points.value = Decimal.add(points.value, cost);
|
||||||
|
spentOnBuyables.value = Decimal.sub(spentOnBuyables.value, cost);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
const buyablesDisplay = jsx(() => (
|
const buyablesDisplay = jsx(() => (
|
||||||
|
@ -362,18 +377,24 @@ const layer = createLayer(id, () => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const conversionModifier = createSequentialModifier(() => [
|
||||||
|
createExponentialModifier(() => ({
|
||||||
|
exponent: 2,
|
||||||
|
description: "Because I felt like it"
|
||||||
|
})),
|
||||||
|
createAdditiveModifier(() => ({ addend: 1, description: "Nice modifier" }))
|
||||||
|
]);
|
||||||
const conversion = createCumulativeConversion(() => ({
|
const conversion = createCumulativeConversion(() => ({
|
||||||
scaling: addSoftcap(createPolynomialScaling(10, 0.5), 1e100, 0.5),
|
formula: modifierToFormula(
|
||||||
|
conversionModifier,
|
||||||
|
Formula.variable(0)
|
||||||
|
.div(10)
|
||||||
|
.sqrt()
|
||||||
|
.step(1e100, f => f.sqrt())
|
||||||
|
),
|
||||||
baseResource: main.points,
|
baseResource: main.points,
|
||||||
gainResource: points,
|
gainResource: points,
|
||||||
roundUpCost: true,
|
roundUpCost: true
|
||||||
gainModifier: createSequentialModifier(() => [
|
|
||||||
createExponentialModifier(() => ({
|
|
||||||
exponent: 2,
|
|
||||||
description: "Because I felt like it"
|
|
||||||
})),
|
|
||||||
createAdditiveModifier(() => ({ addend: 1, description: "Nice modifier" }))
|
|
||||||
]) as WithRequired<Modifier, "description" | "revert">
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const reset = createReset(() => ({
|
const reset = createReset(() => ({
|
||||||
|
@ -434,12 +455,10 @@ const layer = createLayer(id, () => {
|
||||||
}));
|
}));
|
||||||
addTooltip(resetButton, {
|
addTooltip(resetButton, {
|
||||||
display: jsx(() =>
|
display: jsx(() =>
|
||||||
createModifierSection(
|
createModifierSection({
|
||||||
"Modifiers",
|
title: "Modifiers",
|
||||||
"",
|
modifier: conversionModifier
|
||||||
conversion.gainModifier,
|
})
|
||||||
conversion.scaling.currentGain(conversion)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
pinnable: true,
|
pinnable: true,
|
||||||
direction: Direction.Down,
|
direction: Direction.Down,
|
||||||
|
@ -587,7 +606,7 @@ const layer = createLayer(id, () => {
|
||||||
generatorUpgrade.canPurchase.value ||
|
generatorUpgrade.canPurchase.value ||
|
||||||
lollipopMultiplierUpgrade.canPurchase.value ||
|
lollipopMultiplierUpgrade.canPurchase.value ||
|
||||||
unlockIlluminatiUpgrade.canPurchase.value ||
|
unlockIlluminatiUpgrade.canPurchase.value ||
|
||||||
funChallenge.canComplete.value
|
Decimal.gt(funChallenge.canComplete.value, 0)
|
||||||
) {
|
) {
|
||||||
return "blue";
|
return "blue";
|
||||||
}
|
}
|
||||||
|
@ -675,9 +694,7 @@ const layer = createLayer(id, () => {
|
||||||
backgroundColor: "#3325CC"
|
backgroundColor: "#3325CC"
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
visibility() {
|
visibility: unlockIlluminatiUpgrade.bought,
|
||||||
return showIf(unlockIlluminatiUpgrade.bought.value);
|
|
||||||
},
|
|
||||||
display: "illuminati"
|
display: "illuminati"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Spacer from "components/layout/Spacer.vue";
|
||||||
import { createLayerTreeNode, createResetButton } from "data/common";
|
import { createLayerTreeNode, createResetButton } from "data/common";
|
||||||
import { main } from "data/projEntry";
|
import { main } from "data/projEntry";
|
||||||
import { createClickable } from "features/clickables/clickable";
|
import { createClickable } from "features/clickables/clickable";
|
||||||
import { createPolynomialScaling, createIndependentConversion } from "features/conversion";
|
import { createIndependentConversion } from "features/conversion";
|
||||||
import { jsx } from "features/feature";
|
import { jsx } from "features/feature";
|
||||||
import { createInfobox } from "features/infoboxes/infobox";
|
import { createInfobox } from "features/infoboxes/infobox";
|
||||||
import { createParticles } from "features/particles/particles";
|
import { createParticles } from "features/particles/particles";
|
||||||
|
@ -11,8 +11,8 @@ import MainDisplay from "features/resources/MainDisplay.vue";
|
||||||
import { createResource, displayResource } from "features/resources/resource";
|
import { createResource, displayResource } from "features/resources/resource";
|
||||||
import { addTooltip } from "features/tooltips/tooltip";
|
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 { createLayer } from "game/layers";
|
import { createLayer } from "game/layers";
|
||||||
import { createMultiplicativeModifier } from "game/modifiers";
|
|
||||||
import { persistent } from "game/persistence";
|
import { 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";
|
||||||
|
@ -109,10 +109,9 @@ const layer = createLayer(id, () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const conversion = createIndependentConversion(() => ({
|
const conversion = createIndependentConversion(() => ({
|
||||||
scaling: createPolynomialScaling(10, 0.5),
|
formula: Formula.variable(0).div(10).sqrt().times(c.otherThingy),
|
||||||
baseResource: main.points,
|
baseResource: main.points,
|
||||||
gainResource: points,
|
gainResource: points
|
||||||
modifyGainAmount: createMultiplicativeModifier(() => ({ multiplier: c.otherThingy }))
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const treeNode = createLayerTreeNode(() => ({
|
const treeNode = createLayerTreeNode(() => ({
|
||||||
|
|
|
@ -293,6 +293,24 @@ export function createSequentialModifier<
|
||||||
}) as unknown as S;
|
}) as unknown as S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** An object that configures a modifier section via {@link createModifierSection}. */
|
||||||
|
export interface ModifierSectionOptions {
|
||||||
|
/** The header for the section. */
|
||||||
|
title: string;
|
||||||
|
/** Smaller text that appears in the header after the title. */
|
||||||
|
subtitle?: string;
|
||||||
|
/** The modifier to render. */
|
||||||
|
modifier: WithRequired<Modifier, "description">;
|
||||||
|
/** The base value that'll be passed into the modifier. Defaults to 1. */
|
||||||
|
base?: DecimalSource;
|
||||||
|
/** The unit of the value being modified, if any. */
|
||||||
|
unit?: string;
|
||||||
|
/** The label to use for the base value. Defaults to "Base". */
|
||||||
|
baseText?: CoercableComponent;
|
||||||
|
/** Determines if numbers larger or smaller than the base should be displayed as red. */
|
||||||
|
smallerIsBetter?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a JSX element that displays a modifier.
|
* Create a JSX element that displays a modifier.
|
||||||
* Intended to be used with the output from {@link createSequentialModifier}.
|
* Intended to be used with the output from {@link createSequentialModifier}.
|
||||||
|
|
Loading…
Reference in a new issue