a bunch of sleigh things

This commit is contained in:
unsoftcapped3 2022-12-23 06:33:30 +00:00
parent 8615d3dbd1
commit 4c8a213eb4
2 changed files with 64 additions and 127 deletions

View file

@ -28,7 +28,7 @@ import {
Modifier
} from "game/modifiers";
import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, formatWhole } from "util/bignum";
import Decimal, { DecimalSource, format, formatTime, formatWhole } from "util/bignum";
import { Direction, WithRequired } from "util/common";
import { render } from "util/vue";
import { computed, ref, unref, watchEffect } from "vue";
@ -38,6 +38,12 @@ import management from "./management";
import toys from "./toys";
import trees from "./trees";
import wrappingPaper from "./wrapping-paper";
import metal from "./metal";
import plastic from "./plastic"
import { createBuyable, GenericBuyable } from "features/buyable";
import { Resource } from "features/resources/resource";
import { isArray } from "@vue/shared";
const id = "sleigh";
const day = 22;
@ -45,108 +51,61 @@ const layer = createLayer(id, function (this: BaseLayer) {
const name = "Sleigh";
const color = "#D66B02";
const colorDark = "#D66B02";
const foundationProgress = createResource<DecimalSource>(0, "foundation progress");
const maxFoundation = createSequentialModifier(() => [
createAdditiveModifier(() => ({
addend: 900,
description: "Hope Level 3",
enabled: management.elfTraining.expandersElfTraining.milestones[2].earned
})),
createAdditiveModifier(() => ({
addend: 200,
description: "Build wooden towers",
enabled: toys.row1Upgrades[2].bought
})),
createAdditiveModifier(() => ({
addend: () => Decimal.times(factory.factoryBuyables.expandFactory.amount.value, 100),
description: "Expand Factory",
enabled: () => Decimal.gt(factory.factoryBuyables.expandFactory.amount.value, 0)
}))
]) as WithRequired<Modifier, "revert" | "description">;
const computedMaxFoundation = computed(() => maxFoundation.apply(100));
const foundationConversion = createIndependentConversion(() => ({
// note: 5423 is a magic number. Don't touch this or it'll self-destruct.
scaling: addHardcap(
addSoftcap(addSoftcap(createPolynomialScaling(250, 1.5), 5423, 1 / 1e10), 1e20, 3e8),
computedMaxFoundation
),
baseResource: trees.logs,
gainResource: noPersist(foundationProgress),
roundUpCost: true,
// buyMax: management.elfTraining.expandersElfTraining.milestones[2].earned,
spend(gain, spent) {
trees.logs.value = Decimal.sub(trees.logs.value, spent);
},
costModifier: createSequentialModifier(() => [
createMultiplicativeModifier(() => ({
multiplier: wrappingPaper.boosts.beach1,
description: "Beach Wrapping Paper",
enabled: computed(() => Decimal.gt(wrappingPaper.boosts.beach1.value, 1))
})),
createExponentialModifier(() => ({
exponent: 1 / 0.99,
description: "Holly Level 5",
enabled: management.elfTraining.cutterElfTraining.milestones[4].earned
})),
createExponentialModifier(() => ({
exponent: 0.1,
description: "Scaling Jump at 1000%",
enabled: computed(() => Decimal.gte(foundationProgress.value, 1000))
})),
createMultiplicativeModifier(() => ({
multiplier: 6969, // note: 6969 is a magic number. Don't touch this or it'll self-destruct.
description: "Scaling Jump at 1000%",
enabled: computed(() => Decimal.gte(foundationProgress.value, 1000))
}))
])
}));
const buildFoundation = createClickable(() => ({
const maxProgress = 100
function displayCost(
res: Resource<DecimalSource> | Resource<DecimalSource>[],
cost: DecimalSource,
label: string
) {
const affordable = (isArray(res) ? res : [res]).every(res => Decimal.gte(res.value, cost));
return (
<span class={affordable ? "" : "unaffordable"}>
{format(cost)} {label}
</span>
);
}
const sleighProgress = computed(() => sleigh.amount)
const sleigh = createBuyable(() => ({
display: jsx(() => (
<>
<b style="font-size: x-large">
Build {formatWhole(foundationConversion.actualGain.value)}% of the foundation{" "}
<HotkeyVue hotkey={buildFoundationHK} />
</b>
<br />
<br />
<span style="font-size: large">
{"Cost"}:{" "}
{displayResource(trees.logs, foundationConversion.nextAt.value)}{" "}
{trees.logs.displayName}
</span>
<h3>Fix the sleigh</h3>
<div>
Increase sleigh fixed by 1%
</div>
<div>
Costs {displayCost(trees.logs, Decimal.pow(10, 100), "logs")},
</div>
</>
)),
visibility: () => showIf(Decimal.lt(foundationProgress.value, computedMaxFoundation.value)),
canClick: () => {
if (Decimal.lt(trees.logs.value, foundationConversion.nextAt.value)) {
return false;
}
if (Decimal.gte(foundationProgress.value, computedMaxFoundation.value)) {
return false;
}
return true;
canPurchase(): boolean {
return (
/*classroomCost.value.wood.lte(trees.logs.value) &&
classroomCost.value.paper.lte(paper.paper.value) &&
classroomCost.value.boxes.lte(boxes.boxes.value) &&
classroomCost.value.metalIngots.lte(metal.metal.value)*/
true
);
},
onClick() {
if (!unref(this.canClick)) {
return;
}
foundationConversion.convert();
onPurchase() {
/*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);
metal.metal.value = Decimal.sub(metal.metal.value, classroomCost.value.metalIngots);
this.amount.value = Decimal.add(this.amount.value, 1);*/
},
style: "width: 600px; min-height: unset"
}));
visibility: () => showIf(Decimal.lt(sleighProgress.value.value, 100)),
style: "width: 600px"
})) as GenericBuyable;
const buildFoundationHK = createHotkey(() => ({
/*const buildFoundationHK = createHotkey(() => ({
key: "x",
description: "Fix sleigh",
onPress: () => {
if (buildFoundation.canClick.value) buildFoundation.onClick();
},
enabled: noPersist(main.days[day - 1].opened)
}));
}));*/
const shouldShowPopups = computed(() => !elves.milestones[6].earned.value);
const milestone1 = createMilestone(() => ({
@ -154,7 +113,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
requirement: "1% Foundation Completed",
effectDisplay: "Trees give 5% more logs for each % of foundation completed"
},
shouldEarn: () => Decimal.gte(foundationProgress.value, 1),
shouldEarn: () => Decimal.gte(sleighProgress.value.value, 1),
showPopups: shouldShowPopups
}));
const milestones = {
@ -170,18 +129,18 @@ const layer = createLayer(id, function (this: BaseLayer) {
fillStyle: `backgroundColor: ${colorDark}`,
progress: () =>
main.day.value === day || main.currentlyMastering.value?.name === name
? Decimal.div(foundationProgress.value, 100)
? Decimal.div(sleighProgress.value.value, 100)
: 1,
display: jsx(() =>
main.day.value === day || main.currentlyMastering.value?.name === name ? (
<>{formatWhole(foundationProgress.value)}%</>
<>{formatWhole(sleighProgress.value.value)}%</>
) : (
""
)
)
}));
const [generalTab, generalTabCollapsed] = createCollapsibleModifierSections(() => [
/*const [generalTab, generalTabCollapsed] = createCollapsibleModifierSections(() => [
{
title: "Max Foundation",
modifier: maxFoundation,
@ -198,66 +157,44 @@ const layer = createLayer(id, function (this: BaseLayer) {
body: generalTab
}}
/>
));
));*/
watchEffect(() => {
if (main.day.value === day && Decimal.gte(foundationProgress.value, 100)) {
if (main.day.value === day && Decimal.gte(sleighProgress.value.value, 100)) {
main.completeDay();
} else if (
main.currentlyMastering.value?.name === name &&
Decimal.gte(foundationProgress.value, 100)
) {
main.completeMastery();
}
}
});
return {
name,
day,
color,
foundationProgress,
foundationConversion,
sleighProgress,
milestones,
collapseMilestones,
minWidth: 700,
buildFoundationHK,
generalTabCollapsed,
sleigh,
display: jsx(() => (
<>
<div>
{main.day.value === day
? `Complete the sleigh to complete the day`
: main.currentlyMastering.value?.name === name
? `Complete the foundation to decorate the day`
: `${name} Complete!`}
{Decimal.gt(computedMaxFoundation.value, 100) ? (
<>
{" - "}
<button
class="button"
style="display: inline-block;"
onClick={() => (showModifiersModal.value = true)}
>
Check Modifiers
</button>
</>
) : null}
</div>
{render(dayProgress)}
{render(modifiersModal)}
<Spacer />
<div>
<span>The foundation is </span>
<h2 style={`color: ${color}; text-shadow: 0 0 10px ${color}`}>
{formatWhole(foundationProgress.value)}
{formatWhole(sleighProgress.value.value)}
</h2>
% completed
</div>
{Decimal.lt(foundationProgress.value, 100) ||
{Decimal.lt(sleighProgress.value.value, 100) ||
management.elfTraining.expandersElfTraining.milestones[2].earned.value ? (
<Spacer />
) : null}
{render(buildFoundation)}
{render(sleigh)}
<Spacer />
{milestonesDisplay()}
</>
@ -266,7 +203,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<div>
{name}{" "}
<span class="desc">
{formatWhole(foundationProgress.value)}% {foundationProgress.displayName}
{formatWhole(sleighProgress.value.value)}% sleigh
</span>
</div>
)),

View file

@ -482,9 +482,9 @@ export const main = createLayer("main", function (this: BaseLayer) {
createDay(() => ({
day: 22,
shouldNotify: false,
layer: null, // "sleigh"
layer: "sleigh", // "sleigh"
symbol: "",
story: "",
story: "default body",
completedStory: "",
masteredStory: ""
})),