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 Modifier
} from "game/modifiers"; } from "game/modifiers";
import { noPersist, persistent } from "game/persistence"; 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 { Direction, WithRequired } from "util/common";
import { render } from "util/vue"; import { render } from "util/vue";
import { computed, ref, unref, watchEffect } from "vue"; import { computed, ref, unref, watchEffect } from "vue";
@ -38,6 +38,12 @@ import management from "./management";
import toys from "./toys"; import toys from "./toys";
import trees from "./trees"; import trees from "./trees";
import wrappingPaper from "./wrapping-paper"; 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 id = "sleigh";
const day = 22; const day = 22;
@ -45,108 +51,61 @@ const layer = createLayer(id, function (this: BaseLayer) {
const name = "Sleigh"; const name = "Sleigh";
const color = "#D66B02"; const color = "#D66B02";
const colorDark = "#D66B02"; const colorDark = "#D66B02";
const maxProgress = 100
const foundationProgress = createResource<DecimalSource>(0, "foundation progress"); function displayCost(
res: Resource<DecimalSource> | Resource<DecimalSource>[],
const maxFoundation = createSequentialModifier(() => [ cost: DecimalSource,
createAdditiveModifier(() => ({ label: string
addend: 900, ) {
description: "Hope Level 3", const affordable = (isArray(res) ? res : [res]).every(res => Decimal.gte(res.value, cost));
enabled: management.elfTraining.expandersElfTraining.milestones[2].earned return (
})), <span class={affordable ? "" : "unaffordable"}>
createAdditiveModifier(() => ({ {format(cost)} {label}
addend: 200, </span>
description: "Build wooden towers", );
enabled: toys.row1Upgrades[2].bought }
})), const sleighProgress = computed(() => sleigh.amount)
createAdditiveModifier(() => ({ const sleigh = createBuyable(() => ({
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(() => ({
display: jsx(() => ( display: jsx(() => (
<> <>
<b style="font-size: x-large"> <h3>Fix the sleigh</h3>
Build {formatWhole(foundationConversion.actualGain.value)}% of the foundation{" "} <div>
<HotkeyVue hotkey={buildFoundationHK} /> Increase sleigh fixed by 1%
</b> </div>
<br /> <div>
<br /> Costs {displayCost(trees.logs, Decimal.pow(10, 100), "logs")},
<span style="font-size: large"> </div>
{"Cost"}:{" "}
{displayResource(trees.logs, foundationConversion.nextAt.value)}{" "}
{trees.logs.displayName}
</span>
</> </>
)), )),
visibility: () => showIf(Decimal.lt(foundationProgress.value, computedMaxFoundation.value)), canPurchase(): boolean {
canClick: () => { return (
if (Decimal.lt(trees.logs.value, foundationConversion.nextAt.value)) { /*classroomCost.value.wood.lte(trees.logs.value) &&
return false; classroomCost.value.paper.lte(paper.paper.value) &&
} classroomCost.value.boxes.lte(boxes.boxes.value) &&
if (Decimal.gte(foundationProgress.value, computedMaxFoundation.value)) { classroomCost.value.metalIngots.lte(metal.metal.value)*/
return false; true
} );
return true;
}, },
onClick() { onPurchase() {
if (!unref(this.canClick)) { /*trees.logs.value = Decimal.sub(trees.logs.value, classroomCost.value.wood);
return; paper.paper.value = Decimal.sub(paper.paper.value, classroomCost.value.paper);
} boxes.boxes.value = Decimal.sub(boxes.boxes.value, classroomCost.value.boxes);
foundationConversion.convert(); 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", key: "x",
description: "Fix sleigh", description: "Fix sleigh",
onPress: () => { onPress: () => {
if (buildFoundation.canClick.value) buildFoundation.onClick(); if (buildFoundation.canClick.value) buildFoundation.onClick();
}, },
enabled: noPersist(main.days[day - 1].opened) enabled: noPersist(main.days[day - 1].opened)
})); }));*/
const shouldShowPopups = computed(() => !elves.milestones[6].earned.value); const shouldShowPopups = computed(() => !elves.milestones[6].earned.value);
const milestone1 = createMilestone(() => ({ const milestone1 = createMilestone(() => ({
@ -154,7 +113,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
requirement: "1% Foundation Completed", requirement: "1% Foundation Completed",
effectDisplay: "Trees give 5% more logs for each % of 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 showPopups: shouldShowPopups
})); }));
const milestones = { const milestones = {
@ -170,18 +129,18 @@ const layer = createLayer(id, function (this: BaseLayer) {
fillStyle: `backgroundColor: ${colorDark}`, fillStyle: `backgroundColor: ${colorDark}`,
progress: () => progress: () =>
main.day.value === day || main.currentlyMastering.value?.name === name main.day.value === day || main.currentlyMastering.value?.name === name
? Decimal.div(foundationProgress.value, 100) ? Decimal.div(sleighProgress.value.value, 100)
: 1, : 1,
display: jsx(() => display: jsx(() =>
main.day.value === day || main.currentlyMastering.value?.name === name ? ( 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", title: "Max Foundation",
modifier: maxFoundation, modifier: maxFoundation,
@ -198,66 +157,44 @@ const layer = createLayer(id, function (this: BaseLayer) {
body: generalTab body: generalTab
}} }}
/> />
)); ));*/
watchEffect(() => { watchEffect(() => {
if (main.day.value === day && Decimal.gte(foundationProgress.value, 100)) { if (main.day.value === day && Decimal.gte(sleighProgress.value.value, 100)) {
main.completeDay(); main.completeDay();
} else if ( }
main.currentlyMastering.value?.name === name &&
Decimal.gte(foundationProgress.value, 100)
) {
main.completeMastery();
}
}); });
return { return {
name, name,
day, day,
color, color,
foundationProgress, sleighProgress,
foundationConversion,
milestones, milestones,
collapseMilestones, collapseMilestones,
minWidth: 700, minWidth: 700,
buildFoundationHK, sleigh,
generalTabCollapsed,
display: jsx(() => ( display: jsx(() => (
<> <>
<div> <div>
{main.day.value === day {main.day.value === day
? `Complete the sleigh to complete the day` ? `Complete the sleigh to complete the day`
: main.currentlyMastering.value?.name === name
? `Complete the foundation to decorate the day`
: `${name} Complete!`} : `${name} Complete!`}
{Decimal.gt(computedMaxFoundation.value, 100) ? (
<>
{" - "}
<button
class="button"
style="display: inline-block;"
onClick={() => (showModifiersModal.value = true)}
>
Check Modifiers
</button>
</>
) : null}
</div> </div>
{render(dayProgress)} {render(dayProgress)}
{render(modifiersModal)}
<Spacer /> <Spacer />
<div> <div>
<span>The foundation is </span> <span>The foundation is </span>
<h2 style={`color: ${color}; text-shadow: 0 0 10px ${color}`}> <h2 style={`color: ${color}; text-shadow: 0 0 10px ${color}`}>
{formatWhole(foundationProgress.value)} {formatWhole(sleighProgress.value.value)}
</h2> </h2>
% completed % completed
</div> </div>
{Decimal.lt(foundationProgress.value, 100) || {Decimal.lt(sleighProgress.value.value, 100) ||
management.elfTraining.expandersElfTraining.milestones[2].earned.value ? ( management.elfTraining.expandersElfTraining.milestones[2].earned.value ? (
<Spacer /> <Spacer />
) : null} ) : null}
{render(buildFoundation)} {render(sleigh)}
<Spacer /> <Spacer />
{milestonesDisplay()} {milestonesDisplay()}
</> </>
@ -266,7 +203,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<div> <div>
{name}{" "} {name}{" "}
<span class="desc"> <span class="desc">
{formatWhole(foundationProgress.value)}% {foundationProgress.displayName} {formatWhole(sleighProgress.value.value)}% sleigh
</span> </span>
</div> </div>
)), )),

View file

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