Merge branch 'day-20-factory' of https://github.com/thepaperpilot/Advent-Incremental into day-20-factory

This commit is contained in:
circle-gon 2022-12-21 12:57:04 +00:00
commit 4d4c15cdf0
60 changed files with 8121 additions and 494 deletions

View file

@ -11,7 +11,8 @@ module.exports = {
"@vue/eslint-config-prettier" "@vue/eslint-config-prettier"
], ],
parserOptions: { parserOptions: {
ecmaVersion: 2020 ecmaVersion: 2020,
project: "tsconfig.json"
}, },
ignorePatterns: ["src/lib"], ignorePatterns: ["src/lib"],
rules: { rules: {
@ -19,7 +20,14 @@ module.exports = {
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"vue/script-setup-uses-vars": "warn", "vue/script-setup-uses-vars": "warn",
"vue/no-mutating-props": "off", "vue/no-mutating-props": "off",
"vue/multi-word-component-names": "off" "vue/multi-word-component-names": "off",
"@typescript-eslint/strict-boolean-expressions": [
"error",
{
allowNullableObject: true,
allowNullableBoolean: true
}
]
}, },
globals: { globals: {
defineProps: "readonly", defineProps: "readonly",

7587
package-lock.json generated

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -32,7 +32,7 @@ const theme = computed(() => themes[settings.theme].variables as CSSProperties);
const showTPS = toRef(settings, "showTPS"); const showTPS = toRef(settings, "showTPS");
const gameComponent = computed(() => { const gameComponent = computed(() => {
return coerceComponent(jsx(() => <>{gameComponents.map(render)}</>)); return coerceComponent(jsx(() => (<>{gameComponents.map(render)}</>)));
}); });
</script> </script>

View file

@ -80,7 +80,7 @@ const isOpen = ref(false);
const timePlayed = computed(() => formatTime(player.timePlayed)); const timePlayed = computed(() => formatTime(player.timePlayed));
const infoComponent = computed(() => { const infoComponent = computed(() => {
return coerceComponent(jsx(() => <>{infoComponents.map(render)}</>)); return coerceComponent(jsx(() => (<>{infoComponents.map(render)}</>)));
}); });
defineExpose({ defineExpose({

View file

@ -12,9 +12,7 @@
</Context> </Context>
</div> </div>
<button v-if="unref(minimizable)" class="minimize" @click="setMinimized(true)"> <button v-if="unref(minimizable)" class="minimize" @click="setMinimized(true)"></button>
</button>
</div> </div>
</template> </template>
@ -114,7 +112,6 @@ export default defineComponent({
} }
} }
return { return {
component, component,
minimizedComponent, minimizedComponent,
@ -124,7 +121,7 @@ export default defineComponent({
goBack, goBack,
setMinimized, setMinimized,
minimized, minimized,
minWidth, minWidth
}; };
} }
}); });
@ -207,7 +204,7 @@ export default defineComponent({
pointer-events: none; pointer-events: none;
} }
</style> </style>
<style> <style>
.layer-tab.minimized > * > .desc { .layer-tab.minimized > * > .desc {
color: var(--accent1); color: var(--accent1);
font-size: 30px; font-size: 30px;

View file

@ -40,7 +40,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { FeatureNode } from "game/layers"; import type { FeatureNode } from "game/layers";
import { computed, ref, toRefs } from "vue"; import { computed, ref, toRefs, unref } from "vue";
import Context from "./Context.vue"; import Context from "./Context.vue";
const _props = defineProps<{ const _props = defineProps<{
@ -51,7 +51,7 @@ const emit = defineEmits<{
(e: "update:modelValue", value: boolean): void; (e: "update:modelValue", value: boolean): void;
}>(); }>();
const isOpen = computed(() => props.modelValue || isAnimating.value); const isOpen = computed(() => unref(props.modelValue) || isAnimating.value);
function close() { function close() {
emit("update:modelValue", false); emit("update:modelValue", false);
} }

View file

@ -62,7 +62,7 @@ const savesManager = ref<ComponentPublicInstance<typeof SavesManager> | null>(nu
const path = computed(() => state.NaNPath?.join(".")); const path = computed(() => state.NaNPath?.join("."));
const property = computed(() => state.NaNPath?.slice(-1)[0]); const property = computed(() => state.NaNPath?.slice(-1)[0]);
const previous = computed<DecimalSource | null>(() => { const previous = computed<DecimalSource | null>(() => {
if (state.NaNReceiver && property.value) { if (state.NaNReceiver && property.value != null) {
return state.NaNReceiver[property.value] as DecimalSource; return state.NaNReceiver[property.value] as DecimalSource;
} }
return null; return null;
@ -77,21 +77,21 @@ const isPaused = computed({
}); });
function setZero() { function setZero() {
if (state.NaNReceiver && property.value) { if (state.NaNReceiver && property.value != null) {
state.NaNReceiver[property.value] = new Decimal(0); state.NaNReceiver[property.value] = new Decimal(0);
state.hasNaN = false; state.hasNaN = false;
} }
} }
function setOne() { function setOne() {
if (state.NaNReceiver && property.value) { if (state.NaNReceiver && property.value != null) {
state.NaNReceiver[property.value] = new Decimal(1); state.NaNReceiver[property.value] = new Decimal(1);
state.hasNaN = false; state.hasNaN = false;
} }
} }
function ignore() { function ignore() {
if (state.NaNReceiver && property.value) { if (state.NaNReceiver && property.value != null) {
state.NaNReceiver[property.value] = new Decimal(NaN); state.NaNReceiver[property.value] = new Decimal(NaN);
state.hasNaN = false; state.hasNaN = false;
} }

View file

@ -81,7 +81,7 @@ const themes = Object.keys(rawThemes).map(theme => ({
})); }));
const settingFieldsComponent = computed(() => { const settingFieldsComponent = computed(() => {
return coerceComponent(jsx(() => <>{settingFields.map(render)}</>)); return coerceComponent(jsx(() => (<>{settingFields.map(render)}</>)));
}); });
const { showTPS, theme, usingLog, alignUnits } = toRefs(settings); const { showTPS, theme, usingLog, alignUnits } = toRefs(settings);

View file

@ -107,11 +107,11 @@ const isEditing = ref(false);
const isConfirming = ref(false); const isConfirming = ref(false);
const newName = ref(""); const newName = ref("");
watch(isEditing, () => (newName.value = save.value.name || "")); watch(isEditing, () => (newName.value = save.value.name ?? ""));
const isActive = computed(() => save.value && save.value.id === player.id); const isActive = computed(() => save.value != null && save.value.id === player.id);
const currentTime = computed(() => const currentTime = computed(() =>
isActive.value ? player.time : (save.value && save.value.time) || 0 isActive.value ? player.time : (save.value != null && save.value.time) ?? 0
); );
const progressDisplay = computeComponent( const progressDisplay = computeComponent(

View file

@ -281,7 +281,7 @@ function newFromPreset(preset: string) {
function editSave(id: string, newName: string) { function editSave(id: string, newName: string) {
const currSave = saves.value[id]; const currSave = saves.value[id];
if (currSave) { if (currSave != null) {
currSave.name = newName; currSave.name = newName;
if (player.id === id) { if (player.id === id) {
player.name = newName; player.name = newName;

View file

@ -26,7 +26,7 @@ const emit = defineEmits<{
const value = computed({ const value = computed({
get() { get() {
return String(unref(props.modelValue) || 0); return String(unref(props.modelValue) ?? 0);
}, },
set(value: string) { set(value: string) {
emit("update:modelValue", Number(value)); emit("update:modelValue", Number(value));

View file

@ -55,7 +55,7 @@ onMounted(() => {
const value = computed({ const value = computed({
get() { get() {
return unref(props.modelValue) || ""; return unref(props.modelValue) ?? "";
}, },
set(value: string) { set(value: string) {
emit("update:modelValue", value); emit("update:modelValue", value);

View file

@ -19,7 +19,7 @@ const emit = defineEmits<{
(e: "update:modelValue", value: boolean): void; (e: "update:modelValue", value: boolean): void;
}>(); }>();
const component = computed(() => coerceComponent(unref(props.title) || "<span></span>", "span")); const component = computed(() => coerceComponent(unref(props.title) ?? "<span></span>", "span"));
const value = computed({ const value = computed({
get() { get() {

View file

@ -19,4 +19,4 @@
.fraction > :last-child { .fraction > :last-child {
border-top: 1px solid; border-top: 1px solid;
} }
</style> </style>

View file

@ -1,6 +1,8 @@
<template> <template>
<span style="white-space: nowrap"> <span style="white-space: nowrap">
<span style="font-size: larger; font-family: initial">&radic;</span <span style="font-size: larger; font-family: initial">&radic;</span>
><div style="display: inline-block; border-top: 1px solid; padding-left: .2em"><slot /></div> <div style="display: inline-block; border-top: 1px solid; padding-left: 0.2em">
<slot />
</div>
</span> </span>
</template> </template>

View file

@ -48,16 +48,15 @@
<script setup lang="ts"> <script setup lang="ts">
import Notif from "components/Notif.vue"; import Notif from "components/Notif.vue";
import Tooltip from "features/tooltips/Tooltip.vue"; import Tooltip from "features/tooltips/Tooltip.vue";
import Decimal from "util/bignum";
import { layers } from "game/layers"; import { layers } from "game/layers";
import { Direction } from "util/common"; import Decimal from "util/bignum";
import { formatTime } from "util/break_eternity"; import { formatTime } from "util/break_eternity";
import { Direction } from "util/common";
import { ProcessedComputable } from "util/computed"; import { ProcessedComputable } from "util/computed";
import { Ref, Transition } from "vue"; import { computed, Ref, Transition, unref } from "vue";
import { computed, unref } from "vue";
import { main } from "./projEntry";
import coal from "./layers/coal"; import coal from "./layers/coal";
import dyes from "./layers/dyes"; import dyes from "./layers/dyes";
import { main } from "./projEntry";
const props = defineProps<{ const props = defineProps<{
day: number; day: number;
@ -77,7 +76,7 @@ const emit = defineEmits<{
const canOpen = computed( const canOpen = computed(
() => () =>
props.layer && props.layer != null &&
Decimal.gte(main.day.value, props.day) && Decimal.gte(main.day.value, props.day) &&
new Date().getMonth() === 11 && new Date().getMonth() === 11 &&
new Date().getDate() >= props.day new Date().getDate() >= props.day
@ -88,14 +87,14 @@ const includeMastery = computed(
() => () =>
props.mastered.value || props.mastered.value ||
main.currentlyMastering.value == layers[props.layer ?? ""] || main.currentlyMastering.value == layers[props.layer ?? ""] ||
["wrappingPaper", "ribbon"].includes(props.layer || "") || ["wrappingPaper", "ribbon"].includes(props.layer ?? "") ||
(coal.mastered.value && props.layer == "elves") || (coal.mastered.value && props.layer == "elves") ||
(dyes.mastered.value && props.layer == "elves") (dyes.mastered.value && props.layer == "elves")
); );
const masteryLock = computed(() => isMastering.value && !includeMastery.value); const masteryLock = computed(() => isMastering.value && !includeMastery.value);
function tryUnlock() { function tryUnlock() {
if (canOpen.value) { if (canOpen.value === true) {
emit("unlockLayer"); emit("unlockLayer");
} }
} }

View file

@ -58,6 +58,7 @@
<img v-if="day >= 10" :src="dyes" class="scene-item" /> <img v-if="day >= 10" :src="dyes" class="scene-item" />
<img v-if="day >= 14" :src="wrappingPaper" class="scene-item" /> <img v-if="day >= 14" :src="wrappingPaper" class="scene-item" />
<img v-if="day >= 15" :src="ribbons" class="scene-item" /> <img v-if="day >= 15" :src="ribbons" class="scene-item" />
<img v-if="day >= 16" :src="toys" class="scene-item" />
</div> </div>
</div> </div>
</template> </template>
@ -79,6 +80,7 @@ import advManagement from "./symbols/workshopMansion.png";
import letters from "./symbols/letterbox.png"; import letters from "./symbols/letterbox.png";
import wrappingPaper from "./symbols/wrappingPaper.png"; import wrappingPaper from "./symbols/wrappingPaper.png";
import ribbons from "./symbols/ribbons.png"; import ribbons from "./symbols/ribbons.png";
import toys from "./symbols/truck.png";
defineProps<{ defineProps<{
day: number; day: number;

View file

@ -1,4 +1,5 @@
import Collapsible from "components/layout/Collapsible.vue"; import Collapsible from "components/layout/Collapsible.vue";
import "data/layers/styles/day-gradients.css";
import { createBar } from "features/bars/bar"; import { createBar } from "features/bars/bar";
import { GenericBuyable } from "features/buyable"; import { GenericBuyable } from "features/buyable";
import type { Clickable, ClickableOptions, GenericClickable } from "features/clickables/clickable"; import type { Clickable, ClickableOptions, GenericClickable } from "features/clickables/clickable";
@ -16,14 +17,12 @@ import { GenericMilestone } from "features/milestones/milestone";
import { displayResource, Resource, trackTotal } from "features/resources/resource"; import { displayResource, Resource, trackTotal } from "features/resources/resource";
import type { GenericTree, GenericTreeNode, TreeNode, TreeNodeOptions } from "features/trees/tree"; import type { GenericTree, GenericTreeNode, TreeNode, TreeNodeOptions } from "features/trees/tree";
import { createTreeNode } from "features/trees/tree"; import { createTreeNode } from "features/trees/tree";
import { BaseLayer, Layer } from "game/layers";
import type { Modifier } from "game/modifiers"; import type { Modifier } from "game/modifiers";
import type { Persistent } from "game/persistence"; import type { Persistent } from "game/persistence";
import { DefaultValue, persistent } from "game/persistence"; import { DefaultValue, persistent } from "game/persistence";
import player from "game/player"; import player from "game/player";
import settings from "game/settings"; import settings from "game/settings";
import { DecimalSource, formatSmall } from "util/bignum"; import Decimal, { DecimalSource, format, formatSmall } from "util/bignum";
import Decimal, { format } from "util/bignum";
import { formatWhole } from "util/break_eternity"; import { formatWhole } from "util/break_eternity";
import { Direction, WithRequired } from "util/common"; import { Direction, WithRequired } from "util/common";
import type { import type {
@ -34,10 +33,8 @@ import type {
} from "util/computed"; } from "util/computed";
import { convertComputable, processComputable } from "util/computed"; import { convertComputable, processComputable } from "util/computed";
import { getFirstFeature, render, renderColJSX, renderJSX, VueFeature } from "util/vue"; import { getFirstFeature, render, renderColJSX, renderJSX, VueFeature } from "util/vue";
import { Ref, watchEffect } from "vue"; import { computed, Ref, unref, watchEffect } from "vue";
import { computed, unref } from "vue";
import "./common.css"; import "./common.css";
import "data/layers/styles/day-gradients.css";
import { main } from "./projEntry"; import { main } from "./projEntry";
/** An object that configures a {@link ResetButton} */ /** An object that configures a {@link ResetButton} */
@ -138,7 +135,7 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
)} )}
</b>{" "} </b>{" "}
{resetButton.conversion.gainResource.displayName} {resetButton.conversion.gainResource.displayName}
{unref(resetButton.showNextAt) ? ( {unref(resetButton.showNextAt) != null ? (
<div> <div>
<br /> <br />
{unref(resetButton.conversion.buyMax) ? "Next:" : "Req:"}{" "} {unref(resetButton.conversion.buyMax) ? "Next:" : "Req:"}{" "}
@ -167,7 +164,7 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
const onClick = resetButton.onClick; const onClick = resetButton.onClick;
resetButton.onClick = function () { resetButton.onClick = function () {
if (!unref(resetButton.canClick)) { if (unref(resetButton.canClick) === false) {
return; return;
} }
resetButton.conversion.convert(); resetButton.conversion.convert();
@ -311,7 +308,7 @@ export function createCollapsibleModifierSections(
</span> </span>
{s.title} {s.title}
{s.subtitle ? <span class="subtitle"> ({s.subtitle})</span> : null} {s.subtitle != null ? <span class="subtitle"> ({s.subtitle})</span> : null}
</h3> </h3>
); );
@ -338,7 +335,8 @@ export function createCollapsibleModifierSections(
{hasPreviousSection ? <br /> : null} {hasPreviousSection ? <br /> : null}
<div <div
style={{ style={{
"--unit": settings.alignUnits && s.unit ? "'" + s.unit + "'" : "" "--unit":
settings.alignUnits && s.unit != null ? "'" + s.unit + "'" : ""
}} }}
> >
{header} {header}
@ -455,7 +453,7 @@ export function setUpDailyProgressTracker(options: {
animation: options.background.duration + " " + options.background.gradient + " linear infinite", animation: options.background.duration + " " + options.background.gradient + " linear infinite",
}, },
/* eslint-enable prettier/prettier */ /* eslint-enable prettier/prettier */
textStyle: options.textColor ? { color: options.textColor } : undefined, textStyle: options.textColor != null ? { color: options.textColor } : undefined,
progress: progressFunc, progress: progressFunc,
display: jsx(() => display: jsx(() =>
main.day.value === options.day || main.day.value === options.day ||

View file

@ -35,6 +35,7 @@ import management from "./management";
import oil from "./oil"; import oil from "./oil";
import paper from "./paper"; import paper from "./paper";
import trees from "./trees"; import trees from "./trees";
import toys from "./toys";
interface Dye { interface Dye {
name: string; name: string;
@ -373,6 +374,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
enabled: main.days[day - 1].opened enabled: main.days[day - 1].opened
})); }));
const visibility = convertComputable(options.visibility ?? Visibility.Visible);
return { return {
name: options.name, name: options.name,
amount, amount,
@ -380,15 +383,19 @@ const layer = createLayer(id, function (this: BaseLayer) {
hotkey, hotkey,
toGenerate, toGenerate,
computedToGenerate, computedToGenerate,
display: jsx(() => ( display: jsx(() =>
<MainDisplay unref(visibility) === Visibility.Visible ? (
resource={amount} <MainDisplay
color={options.color} resource={amount}
shadowColor={options.shadowColor ?? options.color} color={options.color}
style="margin: 0; width: 200px; width: 180px; padding: 10px;" shadowColor={options.shadowColor ?? options.color}
sticky={false} style="margin: 0; width: 200px; width: 180px; padding: 10px;"
/> sticky={false}
)) />
) : (
""
)
)
}; };
} }
@ -494,12 +501,12 @@ const layer = createLayer(id, function (this: BaseLayer) {
key: "a", key: "a",
costs: () => [ costs: () => [
{ {
base: "1e42", base: "1e60",
root: 5, root: 5,
res: trees.logs res: trees.logs
}, },
{ {
base: computed(() => (upgrades.yellowDyeUpg2.bought.value ? "1e15" : "2e15")), base: computed(() => (upgrades.yellowDyeUpg2.bought.value ? "1e17" : "2e17")),
root: 2, root: 2,
res: oil.oil res: oil.oil
} }
@ -507,10 +514,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
listedBoosts: [ listedBoosts: [
{ {
visible: true, visible: true,
desc: computed(() => `*${format(boosts.black1.value)} letters processed.`) desc: computed(() => `*${format(boosts.black1.value)} oil gain.`)
} }
], ],
dyesToReset: [] dyesToReset: [],
visibility: () => showIf(toys.milestones.milestone2.earned.value)
}), }),
orange: createDye({ orange: createDye({
name: "Orange Dye", name: "Orange Dye",

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,20 +1,23 @@
import { jsx } from "features/feature";
import { createLayer } from "game/layers";
import { Application } from "@pixi/app"; import { Application } from "@pixi/app";
import { Sprite } from "@pixi/sprite";
import { Graphics } from "@pixi/graphics";
import { Assets } from "@pixi/assets"; import { Assets } from "@pixi/assets";
import Factory from "./Factory.vue"; import { Resource, Texture } from "@pixi/core";
import conveyor from "./factory-components/conveyor.png"; import { Container } from "@pixi/display";
import cursor from "./factory-components/cursor.jpg"; import { Graphics } from "@pixi/graphics";
import square from "./factory-components/square.jpg"; import { Matrix } from "@pixi/math";
import { computed, ComputedRef, reactive, Ref, ref, watchEffect } from "vue"; import { Sprite } from "@pixi/sprite";
import { Direction } from "util/common"; import { jsx } from "features/feature";
import { globalBus } from "game/events";
import { createLayer } from "game/layers";
import { Persistent, persistent, State } from "game/persistence"; import { Persistent, persistent, State } from "game/persistence";
import player from "game/player"; import player from "game/player";
import { Direction } from "util/common";
import { computed, ComputedRef, reactive, ref, watchEffect } from "vue";
import conveyor from "./factory-components/conveyor.png";
import cursor from "./factory-components/cursor.jpg";
import rotate from "./factory-components/rotate_rectangle.png";
import square from "./factory-components/square.jpg";
import Factory from "./Factory.vue";
import "./styles/factory.css"; import "./styles/factory.css";
import { globalBus } from "game/events";
import { Container } from "@pixi/display";
const id = "factory"; const id = "factory";
@ -31,7 +34,7 @@ enum FactoryDirections {
type FactoryDirection = FactoryDirections | Direction; type FactoryDirection = FactoryDirections | Direction;
function roundDownTo(num: number, multiple: number) { function roundDownTo(num: number, multiple: number) {
return Math.floor(num / multiple) * multiple; return Math.floor((num + multiple / 2) / multiple) * multiple;
} }
function getRelativeCoords(e: MouseEvent) { function getRelativeCoords(e: MouseEvent) {
const rect = (e.target as HTMLElement).getBoundingClientRect(); const rect = (e.target as HTMLElement).getBoundingClientRect();
@ -54,6 +57,13 @@ function iterateDirection(dir: FactoryDirection, func: (dir: FactoryDirection) =
func(dir); func(dir);
} }
} }
function rotateDir(dir: Direction, relative = Direction.Right) {
const directions = [Direction.Up, Direction.Right, Direction.Down, Direction.Left];
let index = directions.indexOf(dir);
index += directions.indexOf(relative);
index = index % directions.length;
return directions[index];
}
function directionToNum(dir: Direction) { function directionToNum(dir: Direction) {
switch (dir) { switch (dir) {
case Direction.Left: case Direction.Left:
@ -86,6 +96,8 @@ const factory = createLayer(id, () => {
const name = "The Factory"; const name = "The Factory";
const color = "grey"; const color = "grey";
// ---------------------------------------------- Components
const FACTORY_COMPONENTS = { const FACTORY_COMPONENTS = {
cursor: { cursor: {
imageSrc: cursor, imageSrc: cursor,
@ -97,6 +109,16 @@ const factory = createLayer(id, () => {
production: {}, production: {},
productionStock: {} productionStock: {}
}, },
rotate: {
imageSrc: rotate,
name: "Rotate",
description: "Use this to rotate components.",
tick: 0,
consumption: {},
consumptionStock: {},
production: {},
productionStock: {}
},
conveyor: { conveyor: {
imageSrc: conveyor, imageSrc: conveyor,
name: "Conveyor", name: "Conveyor",
@ -105,7 +127,15 @@ const factory = createLayer(id, () => {
consumption: {}, consumption: {},
consumptionStock: {}, consumptionStock: {},
production: {}, production: {},
productionStock: {} productionStock: {},
ports: {
[Direction.Left]: {
type: "input"
},
[Direction.Right]: {
type: "output"
}
}
}, },
square: { square: {
imageSrc: square, imageSrc: square,
@ -121,14 +151,19 @@ const factory = createLayer(id, () => {
consumption: {}, consumption: {},
consumptionStock: {} consumptionStock: {}
} }
} as Record<"cursor" | "conveyor" | "square", FactoryComponentDeclaration>; } as Record<string, FactoryComponentDeclaration>;
const RESOURCES = { const RESOURCES = {
square: square square: square
} as Record<string, string>; } as Record<string, string>;
type FactoryCompNames = keyof typeof FACTORY_COMPONENTS; type FactoryCompNames = keyof typeof FACTORY_COMPONENTS;
type BuildableCompName = Exclude<FactoryCompNames, "cursor">; type BuildableCompName = Exclude<FactoryCompNames, "cursor">;
interface FactoryComponentProducers extends Record<string, State> {
interface FactoryComponentBase extends Record<string, State> {
direction: Direction;
}
interface FactoryComponentProducer extends FactoryComponentBase {
type: Exclude<BuildableCompName, "conveyor">; type: Exclude<BuildableCompName, "conveyor">;
consumptionStock: Record<string, number>; consumptionStock: Record<string, number>;
@ -136,11 +171,14 @@ const factory = createLayer(id, () => {
productionStock: Record<string, number>; productionStock: Record<string, number>;
ticksDone: number; ticksDone: number;
} }
interface FactoryComponentConveyor extends Record<string, State> {
interface FactoryComponentConveyor extends FactoryComponentBase {
type: "conveyor"; type: "conveyor";
directionOut: Direction;
} }
type FactoryComponent = FactoryComponentConveyor | FactoryComponentProducers;
type FactoryComponent = FactoryComponentBase &
(FactoryComponentConveyor | FactoryComponentProducer);
interface FactoryComponentDeclaration { interface FactoryComponentDeclaration {
tick: number; tick: number;
imageSrc: string; imageSrc: string;
@ -176,7 +214,6 @@ const factory = createLayer(id, () => {
} }
interface FactoryInternalProducer extends FactoryInternalBase { interface FactoryInternalProducer extends FactoryInternalBase {
type: Exclude<BuildableCompName, "conveyor">; type: Exclude<BuildableCompName, "conveyor">;
startingFrom: "up" | "right" | "down" | "left";
} }
type FactoryInternal = FactoryInternalConveyor | FactoryInternalProducer; type FactoryInternal = FactoryInternalConveyor | FactoryInternalProducer;
@ -200,7 +237,10 @@ const factory = createLayer(id, () => {
y: 0 y: 0
}); });
const isMouseHoverShown = ref(false); const isMouseHoverShown = ref(false);
const isComponentHover = ref(false);
const whatIsHovered = ref<FactoryCompNames | "">(""); const whatIsHovered = ref<FactoryCompNames | "">("");
const compSelected = ref<FactoryCompNames>("cursor"); const compSelected = ref<FactoryCompNames>("cursor");
const components: Persistent<{ [key: string]: FactoryComponent }> = persistent({}); const components: Persistent<{ [key: string]: FactoryComponent }> = persistent({});
const compInternalData: Record<string, FactoryInternal> = {}; const compInternalData: Record<string, FactoryInternal> = {};
@ -246,8 +286,8 @@ const factory = createLayer(id, () => {
const floorGraphics = new Graphics(); const floorGraphics = new Graphics();
floorGraphics.beginFill(0x70645d); floorGraphics.beginFill(0x70645d);
floorGraphics.drawRect( floorGraphics.drawRect(
-factorySize.width * blockSize, (-factorySize.width - 0.5) * blockSize,
-factorySize.height * blockSize, (-factorySize.height - 0.5) * blockSize,
factorySize.width * 2 * blockSize, factorySize.width * 2 * blockSize,
factorySize.height * 2 * blockSize factorySize.height * 2 * blockSize
); );
@ -257,18 +297,19 @@ const factory = createLayer(id, () => {
// load every sprite here so pixi doesn't complain about loading multiple times // load every sprite here so pixi doesn't complain about loading multiple times
await Assets.load(Object.values(FACTORY_COMPONENTS).map(x => x.imageSrc)); await Assets.load(Object.values(FACTORY_COMPONENTS).map(x => x.imageSrc));
if (Array.isArray(components.value)) components.value = {}; if (Array.isArray(components.value)) {
else components.value = {};
} else {
for (const id in components.value) { for (const id in components.value) {
const data = components.value[id]; const data = components.value[id];
console.log(id, data);
if (data?.type === undefined) { if (data?.type === undefined) {
delete components.value[id]; delete components.value[id];
continue; continue;
} }
const [x, y] = id.split("x").map(p => +p); const [x, y] = id.split("x").map(p => +p);
addFactoryComp(x, y, data.type); addFactoryComp(x, y, data);
} }
}
loaded = true; loaded = true;
}); });
@ -277,31 +318,31 @@ const factory = createLayer(id, () => {
(window as any).blocks = movingBlocks; (window as any).blocks = movingBlocks;
let taskIsRunning = false; let taskIsRunning = false;
globalBus.on("update", async diff => { globalBus.on("update", diff => {
if (taskIsRunning || !loaded) return; if (taskIsRunning || !loaded) return;
taskIsRunning = true;
//debugger //debugger
// will change soon:tm: // will change soon:tm:
const tick = diff; const tick = diff;
// make them produce // make them produce
for (const id in components.value) { for (const id in components.value) {
const [x, y] = id.split("x").map(p => +p); const [x, y] = id.split("x").map(p => +p);
const data = components.value[id]; const _data = components.value[id];
const compData = compInternalData[id]; const _compData = compInternalData[id];
//console.log(compData, data) if (_data === undefined || _compData === undefined) continue;
if (data === undefined || compData === undefined) continue; const factoryData = FACTORY_COMPONENTS[_data.type];
const factoryData = FACTORY_COMPONENTS[data.type]; // debugger;
//debugger; if (_data.type === "conveyor") {
if (data.type === "conveyor") { const data = _data as FactoryComponentConveyor;
const compData = _compData as FactoryInternalConveyor;
if (compData.type !== "conveyor") throw new TypeError("this should not happen"); if (compData.type !== "conveyor") throw new TypeError("this should not happen");
// conveyor part // conveyor part
// use a copy // use a copy
//console.log(compData);
compData.packages = compData.packages.concat(compData.nextPackages); compData.packages = compData.packages.concat(compData.nextPackages);
compData.nextPackages = []; compData.nextPackages = [];
for (const [key, block] of [...compData.packages].entries()) { for (const [key, block] of [...compData.packages].entries()) {
const dirType = getDirection(data.directionOut); const inputDirection = rotateDir(data.direction, Direction.Left);
const dirAmt = directionToNum(data.directionOut); const dirType = getDirection(inputDirection);
const dirAmt = directionToNum(inputDirection);
if (dirType === "h") { if (dirType === "h") {
if (block.x <= block.lastX + dirAmt) { if (block.x <= block.lastX + dirAmt) {
const compBehind = compInternalData[x + dirAmt + "x" + y]; const compBehind = compInternalData[x + dirAmt + "x" + y];
@ -316,14 +357,13 @@ const factory = createLayer(id, () => {
// push it to the next conveyor, kill it from the // push it to the next conveyor, kill it from the
// curent conveyor // curent conveyor
block.lastX += dirAmt; block.lastX += dirAmt;
compBehind.nextPackages.push(block); (compBehind as FactoryInternalConveyor).nextPackages.push(block);
compData.packages.splice(key, 1); compData.packages.splice(key, 1);
} else { } else {
// send it to the factory // send it to the factory
// destory its sprite and data // destory its sprite and data
(storedComp as FactoryComponentProducers).consumptionStock[ const factoryData = storedComp as FactoryComponentProducer;
block.type factoryData.consumptionStock[block.type]++;
]++;
movingBlocks.removeChild(block.sprite); movingBlocks.removeChild(block.sprite);
compData.packages.splice(key, 1); compData.packages.splice(key, 1);
} }
@ -347,12 +387,12 @@ const factory = createLayer(id, () => {
// push it to the next conveyor, kill it from the // push it to the next conveyor, kill it from the
// curent conveyor // curent conveyor
block.lastY += dirAmt; block.lastY += dirAmt;
compBehind.nextPackages.push(block); (compBehind as FactoryInternalConveyor).nextPackages.push(block);
compData.packages.splice(key, 1); compData.packages.splice(key, 1);
} else { } else {
// send it to the factory // send it to the factory
// destory its sprite and data // destory its sprite and data
const factoryData = storedComp as FactoryComponentProducers; const factoryData = storedComp as FactoryComponentProducer;
factoryData.consumptionStock[block.type]++; factoryData.consumptionStock[block.type]++;
movingBlocks.removeChild(block.sprite); movingBlocks.removeChild(block.sprite);
compData.packages.splice(key, 1); compData.packages.splice(key, 1);
@ -365,6 +405,8 @@ const factory = createLayer(id, () => {
} }
} }
} else { } else {
const data = _data as FactoryComponentProducer;
const compData = _compData as FactoryInternalProducer;
// factory part // factory part
// PRODUCTION // PRODUCTION
if (data.ticksDone >= factoryData.tick) { if (data.ticksDone >= factoryData.tick) {
@ -386,35 +428,30 @@ const factory = createLayer(id, () => {
let yInc = 0; let yInc = 0;
let xInc = 0; let xInc = 0;
//debugger;
if ( if (
components.value[x + "x" + (y + 1)]?.type === "conveyor" && components.value[x + "x" + (y + 1)]?.type === "conveyor" &&
(compInternalData[x + "x" + (y + 1)] as FactoryInternalProducer) components.value[x + "x" + (y + 1)].direction === Direction.Up
.startingFrom === "up"
) { ) {
yInc = 1; yInc = 1;
} else if ( } else if (
components.value[x + "x" + (y - 1)]?.type === "conveyor" && components.value[x + "x" + (y - 1)]?.type === "conveyor" &&
(compInternalData[x + "x" + (y - 1)] as FactoryInternalProducer) components.value[x + "x" + (y - 1)].direction === Direction.Down
.startingFrom === "down"
) { ) {
yInc = -1; yInc = -1;
} else if ( } else if (
components.value[x + 1 + "x" + y]?.type === "conveyor" && components.value[x + 1 + "x" + y]?.type === "conveyor" &&
(compInternalData[x + 1 + "x" + y] as FactoryInternalProducer).startingFrom === components.value[x + 1 + "x" + y].direction === Direction.Right
"right"
) { ) {
xInc = 1; xInc = 1;
} else if ( } else if (
components.value[x - 1 + "x" + y]?.type === "conveyor" && components.value[x - 1 + "x" + y]?.type === "conveyor" &&
(compInternalData[x - 1 + "x" + y] as FactoryInternalProducer).startingFrom === components.value[x - 1 + "x" + y].direction === Direction.Left
"left"
) { ) {
xInc = -1; xInc = -1;
} }
// no suitable location to dump stuff in // no suitable location to dump stuff in
//console.log(x, y) // console.log(x, y);
//debugger; // debugger;
if (xInc === 0 && yInc === 0) continue; if (xInc === 0 && yInc === 0) continue;
let itemToMove: [string, number] | undefined = undefined; let itemToMove: [string, number] | undefined = undefined;
for (const [name, amt] of Object.entries(data.productionStock)) { for (const [name, amt] of Object.entries(data.productionStock)) {
@ -468,11 +505,15 @@ const factory = createLayer(id, () => {
taskIsRunning = false; taskIsRunning = false;
}); });
function addFactoryComp(x: number, y: number, type: BuildableCompName) { function addFactoryComp(
x: number,
y: number,
data: Partial<FactoryComponent> & { type: BuildableCompName }
) {
if (x < -factorySize.width || x >= factorySize.width) return; if (x < -factorySize.width || x >= factorySize.width) return;
if (y < -factorySize.height || y >= factorySize.height) return; if (y < -factorySize.height || y >= factorySize.height) return;
const factoryBaseData = FACTORY_COMPONENTS[type]; const factoryBaseData = FACTORY_COMPONENTS[data.type];
const sheet = Assets.get(factoryBaseData.imageSrc); const sheet = Assets.get(factoryBaseData.imageSrc);
const sprite = new Sprite(sheet); const sprite = new Sprite(sheet);
@ -480,35 +521,42 @@ const factory = createLayer(id, () => {
sprite.y = y * blockSize; sprite.y = y * blockSize;
sprite.width = blockSize; sprite.width = blockSize;
sprite.height = blockSize; sprite.height = blockSize;
sprite.anchor.x = 0.5;
sprite.anchor.y = 0.5;
sprite.rotation =
([Direction.Right, Direction.Down, Direction.Left, Direction.Up].indexOf(
data.direction ?? Direction.Right
) *
Math.PI) /
2;
console.log("!!", data, sprite);
components.value[x + "x" + y] = { components.value[x + "x" + y] = {
type,
ticksDone: 0, ticksDone: 0,
directionIn: type === "conveyor" ? Direction.Right : undefined, direction: Direction.Right,
directionOut: type === "conveyor" ? Direction.Left : undefined,
consumptionStock: consumptionStock:
type === "conveyor" data.type === "conveyor"
? undefined ? undefined
: Object.fromEntries( : Object.fromEntries(
Object.keys(factoryBaseData.consumptionStock).map(i => [i, 0]) Object.keys(factoryBaseData.consumptionStock).map(i => [i, 0])
), ),
productionStock: productionStock:
type === "conveyor" data.type === "conveyor"
? undefined ? undefined
: Object.fromEntries( : Object.fromEntries(
Object.keys(factoryBaseData.productionStock).map(i => [i, 0]) Object.keys(factoryBaseData.productionStock).map(i => [i, 0])
) ),
...data
} as FactoryComponent; } as FactoryComponent;
const isConveyor = type === "conveyor"; const isConveyor = data.type === "conveyor";
compInternalData[x + "x" + y] = { compInternalData[x + "x" + y] = {
type, type: data.type,
packages: isConveyor ? [] : undefined, packages: isConveyor ? [] : undefined,
nextPackages: isConveyor ? [] : undefined, nextPackages: isConveyor ? [] : undefined,
startingFrom: "left",
canProduce: computed(() => { canProduce: computed(() => {
if (type === "conveyor") return true; if (data.type === "conveyor") return true;
if (!(factoryBaseData.canProduce?.value ?? true)) return false; if (!(factoryBaseData.canProduce?.value ?? true)) return false;
// this should NEVER be null // this should NEVER be null
const compData = components.value[x + "x" + y] as FactoryComponentProducers; const compData = components.value[x + "x" + y] as FactoryComponentProducer;
for (const [key, res] of Object.entries(compData.productionStock)) { for (const [key, res] of Object.entries(compData.productionStock)) {
// if the current stock + production is more than you can handle // if the current stock + production is more than you can handle
if ( if (
@ -524,7 +572,7 @@ const factory = createLayer(id, () => {
return true; return true;
}), }),
sprite sprite
} as FactoryInternal; } as FactoryInternalProducer;
spriteContainer.addChild(sprite); spriteContainer.addChild(sprite);
} }
@ -539,12 +587,16 @@ const factory = createLayer(id, () => {
spriteContainer.x = movingBlocks.x = calculatedX; spriteContainer.x = movingBlocks.x = calculatedX;
spriteContainer.y = movingBlocks.y = calculatedY; spriteContainer.y = movingBlocks.y = calculatedY;
if (isMouseHoverShown.value && compSelected.value !== "cursor") { if (
isMouseHoverShown.value &&
compSelected.value !== "cursor" &&
compSelected.value !== "rotate"
) {
const { tx, ty } = spriteContainer.localTransform; const { tx, ty } = spriteContainer.localTransform;
graphicContainer.beginFill(0x808080); graphicContainer.lineStyle(4, 0x808080, 1);
graphicContainer.drawRect( graphicContainer.drawRect(
roundDownTo(mouseCoords.x - tx, blockSize) + tx, roundDownTo(mouseCoords.x - tx, blockSize) + tx - blockSize / 2,
roundDownTo(mouseCoords.y - ty, blockSize) + ty, roundDownTo(mouseCoords.y - ty, blockSize) + ty - blockSize / 2,
blockSize, blockSize,
blockSize blockSize
); );
@ -563,18 +615,25 @@ const factory = createLayer(id, () => {
if ( if (
pointerDown.value && pointerDown.value &&
compSelected.value === "cursor" && (pointerDrag.value ||
(pointerDrag.value || Math.abs(e.movementX) > 2 || Math.abs(e.movementY) > 2) (compSelected.value === "cursor" &&
(Math.abs(e.movementX) > 2 || Math.abs(e.movementY) > 2)))
) { ) {
pointerDrag.value = true; pointerDrag.value = true;
mapOffset.x += e.movementX / blockSize; mapOffset.x += e.movementX / blockSize;
mapOffset.y += e.movementY / blockSize; mapOffset.y += e.movementY / blockSize;
// the maximum you can see currently // the maximum you can see currently
// total size of blocks - current size = amount you should move // total size of blocks - current size = amount you should move
mapOffset.x = Math.min(Math.max(mapOffset.x, -factorySize.width), factorySize.width); mapOffset.x = Math.min(
mapOffset.y = Math.min(Math.max(mapOffset.y, -factorySize.height), factorySize.height); Math.max(mapOffset.x, -factorySize.width + 0.5),
factorySize.width + 0.5
);
mapOffset.y = Math.min(
Math.max(mapOffset.y, -factorySize.height + 0.5),
factorySize.height + 0.5
);
} }
if (!pointerDown.value && !pointerDrag.value && compSelected.value === "cursor") { if (!pointerDown.value && !pointerDrag.value) {
const { tx, ty } = spriteContainer.localTransform; const { tx, ty } = spriteContainer.localTransform;
compHovered.value = compHovered.value =
components.value[ components.value[
@ -584,9 +643,12 @@ const factory = createLayer(id, () => {
]; ];
} }
} }
function onFactoryPointerDown() { function onFactoryPointerDown(e: PointerEvent) {
window.addEventListener("pointerup", onFactoryPointerUp); window.addEventListener("pointerup", onFactoryPointerUp);
pointerDown.value = true; pointerDown.value = true;
if (e.button === 1) {
pointerDrag.value = true;
}
} }
function onFactoryPointerUp(e: PointerEvent) { function onFactoryPointerUp(e: PointerEvent) {
// make sure they're not dragging and that // make sure they're not dragging and that
@ -597,14 +659,29 @@ const factory = createLayer(id, () => {
x = roundDownTo(x - tx, blockSize) / blockSize; x = roundDownTo(x - tx, blockSize) / blockSize;
y = roundDownTo(y - ty, blockSize) / blockSize; y = roundDownTo(y - ty, blockSize) / blockSize;
if (e.button === 0) { if (e.button === 0) {
if (compSelected.value !== "cursor") { if (compSelected.value === "rotate") {
if (!components.value[x + "x" + y]) addFactoryComp(x, y, compSelected.value); if (
components.value[x + "x" + y] != null &&
components.value[x + "x" + y].direction != null
) {
components.value[x + "x" + y] = {
...components.value[x + "x" + y],
direction: rotateDir(
(components.value[x + "x" + y] as FactoryComponentConveyor)
.direction
)
};
compInternalData[x + "x" + y].sprite.rotation += Math.PI / 2;
}
} else if (compSelected.value !== "cursor") {
if (components.value[x + "x" + y] == null) {
addFactoryComp(x, y, { type: compSelected.value });
}
} }
} else if (e.button === 2) { } else if (e.button === 2) {
const data = compInternalData[x + "x" + y]; const data = compInternalData[x + "x" + y];
if (data === undefined) return; if (data === undefined) return;
delete components.value[x + "x" + y]; delete components.value[x + "x" + y];
delete compInternalData[x + "x" + y];
spriteContainer.removeChild(data.sprite); spriteContainer.removeChild(data.sprite);
} }
} }
@ -619,15 +696,20 @@ const factory = createLayer(id, () => {
isMouseHoverShown.value = false; isMouseHoverShown.value = false;
} }
function goBack() { function onComponentMouseEnter(name: FactoryCompNames | "") {
player.tabs.splice(0, Infinity, "main");
}
function onComponentHover(name: FactoryCompNames | "") {
whatIsHovered.value = name; whatIsHovered.value = name;
isComponentHover.value = true;
}
function onComponentMouseLeave() {
isComponentHover.value = false;
} }
function onCompClick(name: FactoryCompNames) { function onCompClick(name: FactoryCompNames) {
compSelected.value = name; compSelected.value = name;
} }
function goBack() {
player.tabs.splice(0, Infinity, "main");
}
return { return {
name, name,
day, day,
@ -649,54 +731,83 @@ const factory = createLayer(id, () => {
onPointerleave={onFactoryMouseLeave} onPointerleave={onFactoryMouseLeave}
onContextmenu={(e: MouseEvent) => e.preventDefault()} onContextmenu={(e: MouseEvent) => e.preventDefault()}
/> />
<div class="info-container">
{compHovered.value !== undefined ? ( {compHovered.value !== undefined ? (
<> <div
<b>{FACTORY_COMPONENTS[compHovered.value.type].name}</b> class="info-container"
<br /> style={{
{FACTORY_COMPONENTS[compHovered.value.type].description} left: mouseCoords.x + "px",
<br /> top: mouseCoords.y + "px"
{compHovered.value.type !== "conveyor" ? ( }}
<> >
Stock:{" "} <h3>{FACTORY_COMPONENTS[compHovered.value.type].name}</h3>
{Object.entries({ <br />
...compHovered.value.productionStock, {FACTORY_COMPONENTS[compHovered.value.type].description}
...compHovered.value.consumptionStock <br />
}).map(i => { {compHovered.value.type !== "conveyor" ? (
return `${i[0]}: ${i[1]}/${ <>
FACTORY_COMPONENTS[compHovered.value?.type ?? "cursor"] Stock:{" "}
.consumptionStock[i[0]] ?? {Object.entries({
FACTORY_COMPONENTS[compHovered.value?.type ?? "cursor"] ...(compHovered.value.productionStock as Record<
.productionStock[i[0]] string,
}`; number
})} >),
</> ...(compHovered.value.consumptionStock as Record<
) : undefined} string,
</> number
) : undefined} >)
</div> }).map(i => {
<div class="container"> return `${i[0]}: ${i[1]}/${
<div style="line-height: 2.5em; min-height: 2.5em"> FACTORY_COMPONENTS[compHovered.value?.type ?? "cursor"]
{whatIsHovered.value === "" .consumptionStock[i[0]] ??
? undefined FACTORY_COMPONENTS[compHovered.value?.type ?? "cursor"]
: FACTORY_COMPONENTS[whatIsHovered.value].description} .productionStock[i[0]]
}`;
})}
</>
) : undefined}
</div> </div>
<div class="comps"> ) : undefined}
<div>
{Object.entries(FACTORY_COMPONENTS).map(value => { <div class="factory-container">
const key = value[0] as FactoryCompNames; <div
const item = value[1]; class={{
return ( "comp-info": true,
<img active: isComponentHover.value
src={item.imageSrc} }}
class={{ selected: compSelected.value === key }} style={{
onMouseenter={() => onComponentHover(key)} top:
onMouseleave={() => onComponentHover("")} Math.max(
onClick={() => onCompClick(key)} Object.keys(FACTORY_COMPONENTS).indexOf(whatIsHovered.value),
></img> 0
); ) *
})} 50 +
</div> 10 +
"px"
}}
>
{whatIsHovered.value === "" ? undefined : (
<>
<h3>{FACTORY_COMPONENTS[whatIsHovered.value].name}</h3>
<br />
{FACTORY_COMPONENTS[whatIsHovered.value].description}
</>
)}
</div>
<div class="comp-list">
{Object.entries(FACTORY_COMPONENTS).map(value => {
const key = value[0] as FactoryCompNames;
const item = value[1];
return (
<img
src={item.imageSrc}
class={{ selected: compSelected.value === key }}
onMouseenter={() => onComponentMouseEnter(key)}
onMouseleave={() => onComponentMouseLeave()}
onClick={() => onCompClick(key)}
></img>
);
})}
</div> </div>
</div> </div>
</div> </div>

View file

@ -79,7 +79,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
processingProgress.value, processingProgress.value,
computedProcessingCooldown.value computedProcessingCooldown.value
).floor(); ).floor();
letters.value = Decimal.times(amount, computedLettersGain.value).add(letters.value); letters.value = Decimal.times(amount, computedLettersGain.value)
.add(letters.value)
.min(8e9);
processingProgress.value = 0; processingProgress.value = 0;
} }
})); }));
@ -215,12 +217,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({ createMultiplicativeModifier(() => ({
multiplier: () => Decimal.div(paperBuyable.amount.value, 2).add(1), multiplier: () => Decimal.div(paperBuyable.amount.value, 2).add(1),
description: "Printed Labels" description: "Printed Labels"
})),
createMultiplicativeModifier(() => ({
multiplier: () => dyes.boosts.black1.value,
description: "Black Dye Boost"
})) }))
]); ]);
const computedLettersGain = computed(() => lettersGain.apply(1)); const computedLettersGain = computed(() => lettersGain.apply(1));
const processingCooldown = createSequentialModifier(() => [ const processingCooldown = createSequentialModifier(() => [

View file

@ -40,6 +40,7 @@ import management from "./management";
import workshop from "./workshop"; import workshop from "./workshop";
import { WithRequired } from "util/common"; import { WithRequired } from "util/common";
import { ElfBuyable } from "./elves"; import { ElfBuyable } from "./elves";
import toys from "./toys";
const id = "oil"; const id = "oil";
const day = 9; const day = 9;
@ -947,6 +948,15 @@ const layer = createLayer(id, function (this: BaseLayer) {
multiplier: 2, multiplier: 2,
description: "Cocoa Level 3", description: "Cocoa Level 3",
enabled: management.elfTraining.oilElfTraining.milestones[2].earned enabled: management.elfTraining.oilElfTraining.milestones[2].earned
})),
createMultiplicativeModifier(() => ({
multiplier: () => dyes.boosts.black1.value,
description: "Black Dye Boost"
})),
createMultiplicativeModifier(() => ({
multiplier: 50,
description: "350 toys",
enabled: toys.milestones.milestone4.earned
})) }))
]) as WithRequired<Modifier, "description" | "revert">; ]) as WithRequired<Modifier, "description" | "revert">;
const computedOilSpeed = computed(() => oilSpeed.apply(0)); const computedOilSpeed = computed(() => oilSpeed.apply(0));

View file

@ -36,6 +36,7 @@ import metal from "./metal";
import oil from "./oil"; import oil from "./oil";
import paper from "./paper"; import paper from "./paper";
import workshop from "./workshop"; import workshop from "./workshop";
import toys from "./toys";
const id = "plastic"; const id = "plastic";
const day = 10; const day = 10;
@ -373,6 +374,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
multiplier: () => Decimal.div(buildRefinery.amount.value, 100).add(1), multiplier: () => Decimal.div(buildRefinery.amount.value, 100).add(1),
description: "Tinsel Level 4", description: "Tinsel Level 4",
enabled: management.elfTraining.plasticElfTraining.milestones[3].earned enabled: management.elfTraining.plasticElfTraining.milestones[3].earned
})),
createMultiplicativeModifier(() => ({
multiplier: 50,
description: "350 toys",
enabled: toys.milestones.milestone4.earned
})) }))
]); ]);
const computedPlasticGain = computed(() => plasticGain.apply(0)); const computedPlasticGain = computed(() => plasticGain.apply(0));

View file

@ -41,7 +41,10 @@ const layer = createLayer(id, () => {
) )
); );
const currentDyeType = computed( const currentDyeType = computed(
() => Object.values(dyes.dyes)[new Decimal(ribbon.value).toNumber() % 6] () =>
Object.values(dyes.dyes).filter(d => d !== dyes.dyes.black)[
new Decimal(ribbon.value).toNumber() % 6
]
); );
const ribbonProgress = persistent<DecimalSource>(0); const ribbonProgress = persistent<DecimalSource>(0);
@ -60,8 +63,20 @@ const layer = createLayer(id, () => {
title: "Make Ribbon", title: "Make Ribbon",
description: jsx(() => ( description: jsx(() => (
<> <>
Create another ribbon with {format(currentDyeCost.value)}{" "} Create another ribbon with{" "}
{currentDyeType.value.name} and {format(1e9)} {cloth.cloth.displayName} <span
class={
Decimal.lt(currentDyeType.value.amount.value, currentDyeCost.value)
? "unaffordable"
: ""
}
>
{format(currentDyeCost.value)} {currentDyeType.value.name}
</span>{" "}
and{" "}
<span class={Decimal.lt(cloth.cloth.value, 1e9) ? "unaffordable" : ""}>
{format(1e9)} {cloth.cloth.displayName}
</span>
<br /> <br />
{render(ribbonProgressBar)} {render(ribbonProgressBar)}
</> </>

View file

@ -17,38 +17,71 @@
.info-container { .info-container {
position: absolute; position: absolute;
height: 100px; width: max-content;
top: 0; max-width: 300px;
left: 10%;
right: 10%; margin: 20px 0 0 10px;
transition: height ease 1s; padding: 5px 10px;
background: var(--raised-background);
border-radius: 0 0 var(--border-radius) var(--border-radius); background: var(--background);
box-shadow: 0 2px 10px black; border-radius: var(--border-radius);
margin: 0; box-shadow: 0 1px 5px black;
padding: 0;
text-align: left;
font-size: smaller;
pointer-events: none;
transition: height .3s;
} }
.container { .factory-container {
position: absolute; position: absolute;
bottom: -5px; top: calc(5% + 30px);
height: 100px; bottom: 5%;
left: 10%; left: 0%;
right: 10%; width: 70px;
background: var(--raised-background);
border-radius: var(--border-radius) var(--border-radius) 0 0;
box-shadow: 0 2px 10px black;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
.comps > div > img { .comp-info {
position: absolute;
right: 10px;
padding: 5px 10px;
width: max-content;
max-width: 300px;
background: var(--background);
border-radius: var(--border-radius);
box-shadow: 0 1px 5px #0007;
text-align: left;
font-size: smaller;
pointer-events: none;
transition: transform 0.3s;
}
.comp-info.active {
transform: translateX(calc(20px + 100%));
}
.comp-list {
position: relative;
height: 100%;
padding: 10px;
background: var(--raised-background);
border-radius: 0 var(--border-radius) var(--border-radius) 0;
box-shadow: 0 2px 10px black;
}
.comp-list > img {
display: block;
width: 50px; width: 50px;
height: 50px; height: 50px;
} }
.comps > div > img.selected { .comp-list > img.selected {
transform: translateY(-5px); transform: translate(-5px, -5px);
filter: drop-shadow(0 5px 5px #0007); filter: drop-shadow(2px 2px 0 var(--foreground)) drop-shadow(5px 5px 5px #0007);
} }

View file

@ -4,49 +4,38 @@
*/ */
import Spacer from "components/layout/Spacer.vue"; import Spacer from "components/layout/Spacer.vue";
import Modal from "components/Modal.vue"; import Modal from "components/Modal.vue";
import { main } from "data/projEntry";
import { createBar } from "features/bars/bar";
import { import {
createCollapsibleMilestones, createCollapsibleMilestones,
createCollapsibleModifierSections, createCollapsibleModifierSections,
setUpDailyProgressTracker setUpDailyProgressTracker
} from "data/common"; } from "data/common";
import { main } from "data/projEntry";
import { createBuyable, GenericBuyable } from "features/buyable"; import { createBuyable, GenericBuyable } from "features/buyable";
import { createClickable } from "features/clickables/clickable";
import { jsx, showIf } from "features/feature"; import { jsx, showIf } from "features/feature";
import { createHotkey } from "features/hotkey";
import MainDisplay from "features/resources/MainDisplay.vue";
import { createMilestone } from "features/milestones/milestone"; import { createMilestone } from "features/milestones/milestone";
import { createResource, Resource } from "features/resources/resource"; import MainDisplay from "features/resources/MainDisplay.vue";
import { createResource } from "features/resources/resource";
import { createUpgrade } from "features/upgrades/upgrade"; import { createUpgrade } from "features/upgrades/upgrade";
import { globalBus } from "game/events"; import { globalBus } from "game/events";
import { BaseLayer, createLayer } from "game/layers"; import { BaseLayer, createLayer } from "game/layers";
import { import { createSequentialModifier } from "game/modifiers";
createAdditiveModifier, import { noPersist } from "game/persistence";
createExponentialModifier, import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
createMultiplicativeModifier,
createSequentialModifier,
Modifier
} from "game/modifiers";
import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, format, formatGain, formatLimit, formatWhole } from "util/bignum";
import { Direction, WithRequired } from "util/common";
import { render, renderGrid, renderRow } from "util/vue"; import { render, renderGrid, renderRow } from "util/vue";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import cloth from "./cloth";
import dyes from "./dyes";
import metal from "./metal"; import metal from "./metal";
import plastic from "./plastic"; import plastic from "./plastic";
import cloth from "./cloth";
import trees from "./trees"; import trees from "./trees";
import dyes from "./dyes";
import paper from "./paper";
import workshop from "./workshop"; import workshop from "./workshop";
const id = "toys"; const id = "toys";
const day = 17; const day = 17;
const layer = createLayer(id, function (this: BaseLayer) { const layer = createLayer(id, function (this: BaseLayer) {
const name = "Toys"; const name = "Toys";
const colorBright = "#4BDC13"; const color = "cornflowerblue";
const colorDark = "green";
const clothes = createResource<DecimalSource>(0, "clothes"); const clothes = createResource<DecimalSource>(0, "clothes");
const woodenBlocks = createResource<DecimalSource>(0, " wooden blocks"); const woodenBlocks = createResource<DecimalSource>(0, " wooden blocks");
@ -59,14 +48,14 @@ const layer = createLayer(id, function (this: BaseLayer) {
const clothesCost = computed(() => { const clothesCost = computed(() => {
let clothFactor = Decimal.add(1, clothesBuyable.amount.value); let clothFactor = Decimal.add(1, clothesBuyable.amount.value);
if (milestones.milestone1.earned) { if (milestones.milestone1.earned.value) {
clothFactor = clothFactor.div( clothFactor = clothFactor.div(
Decimal.div(workshop.foundationProgress.value, 100).floor() Decimal.div(workshop.foundationProgress.value, 100).floor()
); );
} }
return { return {
cloth: clothFactor.mul(1e8), cloth: clothFactor.mul(1e13),
dye: clothFactor.mul(1e6) dye: clothFactor.mul(2e14)
}; };
}); });
const clothesBuyable = createBuyable(() => ({ const clothesBuyable = createBuyable(() => ({
@ -79,8 +68,28 @@ const layer = createLayer(id, function (this: BaseLayer) {
<div>You have {formatWhole(clothes.value)} clothes.</div> <div>You have {formatWhole(clothes.value)} clothes.</div>
<div> <div>
Costs {format(clothesCost.value.cloth)} cloth and requires{" "} Costs{" "}
{format(clothesCost.value.dye)} of red, yellow, and blue dye <span
class={
Decimal.lt(cloth.cloth.value, clothesCost.value.cloth)
? "unaffordable"
: ""
}
>
{format(clothesCost.value.cloth)} cloth
</span>{" "}
and requires{" "}
<span
class={
[dyes.dyes.red, dyes.dyes.yellow, dyes.dyes.blue].some(d =>
Decimal.lt(d.amount.value, clothesCost.value.dye)
)
? "unaffordable"
: ""
}
>
{format(clothesCost.value.dye)} of red, yellow, and blue dye
</span>
</div> </div>
</> </>
)), )),
@ -100,13 +109,13 @@ const layer = createLayer(id, function (this: BaseLayer) {
})) as GenericBuyable; })) as GenericBuyable;
const woodenBlocksCost = computed(() => { const woodenBlocksCost = computed(() => {
let woodFactor = Decimal.add(1, woodenBlocksBuyable.amount.value).pow(5); let woodFactor = Decimal.add(1, woodenBlocksBuyable.amount.value).pow(5);
if (milestones.milestone1.earned) { if (milestones.milestone1.earned.value) {
woodFactor = woodFactor.div( woodFactor = woodFactor.div(
Decimal.div(workshop.foundationProgress.value, 100).floor() Decimal.div(workshop.foundationProgress.value, 100).floor()
); );
} }
return { return {
wood: woodFactor.mul(1e40) wood: woodFactor.mul(1e63)
}; };
}); });
const woodenBlocksBuyable = createBuyable(() => ({ const woodenBlocksBuyable = createBuyable(() => ({
@ -133,15 +142,15 @@ const layer = createLayer(id, function (this: BaseLayer) {
const trucksCost = computed(() => { const trucksCost = computed(() => {
let factor = Decimal.add(1, trucksBuyable.amount.value).pow(3); let factor = Decimal.add(1, trucksBuyable.amount.value).pow(3);
let plasticFactor = Decimal.add(1, trucksBuyable.amount.value); let plasticFactor = Decimal.add(1, trucksBuyable.amount.value);
if (milestones.milestone1.earned) { if (milestones.milestone1.earned.value) {
factor = factor.div(Decimal.div(workshop.foundationProgress.value, 100).floor()); factor = factor.div(Decimal.div(workshop.foundationProgress.value, 100).floor());
plasticFactor = plasticFactor.div( plasticFactor = plasticFactor.div(
Decimal.div(workshop.foundationProgress.value, 100).floor() Decimal.div(workshop.foundationProgress.value, 100).floor()
); );
} }
return { return {
metal: factor.mul(1e25), metal: factor.mul(1e43),
plastic: plasticFactor.mul(1e10) plastic: plasticFactor.mul(1e14)
}; };
}); });
const trucksBuyable = createBuyable(() => ({ const trucksBuyable = createBuyable(() => ({
@ -154,8 +163,26 @@ const layer = createLayer(id, function (this: BaseLayer) {
<div>You have {formatWhole(trucks.value)} trucks.</div> <div>You have {formatWhole(trucks.value)} trucks.</div>
<div> <div>
Costs {format(trucksCost.value.metal)} metal and{" "} Costs{" "}
{format(trucksCost.value.plastic)} plastic <span
class={
Decimal.lt(metal.metal.value, trucksCost.value.metal)
? "unaffordable"
: ""
}
>
{format(trucksCost.value.metal)} metal
</span>{" "}
and{" "}
<span
class={
Decimal.lt(plastic.plastic.value, trucksCost.value.plastic)
? "unaffordable"
: ""
}
>
{format(trucksCost.value.plastic)} plastic
</span>
</div> </div>
</> </>
)), )),
@ -213,9 +240,27 @@ const layer = createLayer(id, function (this: BaseLayer) {
requirement: "100 toys", requirement: "100 toys",
effectDisplay: "Unlock black dyes." effectDisplay: "Unlock black dyes."
}, },
shouldEarn: () => Decimal.gte(toySum.value, 100) shouldEarn: () => Decimal.gte(toySum.value, 100),
visibility: () => showIf(milestone1.earned.value)
})); }));
const milestones = { milestone1, milestone2 };
const milestone3 = createMilestone(() => ({
display: {
requirement: "200 toys",
effectDisplay: "Beach wrapping paper is much more powerful."
},
shouldEarn: () => Decimal.gte(toySum.value, 200),
visibility: () => showIf(milestone2.earned.value)
}));
const milestone4 = createMilestone(() => ({
display: {
requirement: "350 toys",
effectDisplay: "Gain 50x oil and plastic."
},
shouldEarn: () => Decimal.gte(toySum.value, 350),
visibility: () => showIf(milestone3.earned.value)
}));
const milestones = { milestone1, milestone2, milestone3, milestone4 };
const { collapseMilestones, display: milestonesDisplay } = const { collapseMilestones, display: milestonesDisplay } =
createCollapsibleMilestones(milestones); createCollapsibleMilestones(milestones);
@ -256,9 +301,10 @@ const layer = createLayer(id, function (this: BaseLayer) {
const { total: totalToys, trackerDisplay } = setUpDailyProgressTracker({ const { total: totalToys, trackerDisplay } = setUpDailyProgressTracker({
resource: toySum, resource: toySum,
goal: 200, goal: 500,
name, name,
day, day,
textColor: "var(--feature-foreground)",
background: { background: {
gradient: "toys-bar", gradient: "toys-bar",
duration: "15s" duration: "15s"
@ -272,7 +318,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
return { return {
name, name,
day, day,
color: colorBright, color,
clothes, clothes,
woodenBlocks, woodenBlocks,
trucks, trucks,
@ -290,19 +336,19 @@ const layer = createLayer(id, function (this: BaseLayer) {
<Spacer /> <Spacer />
<MainDisplay <MainDisplay
resource={clothes} resource={clothes}
color={colorBright} color="lightblue"
style="margin-bottom: 0" style="margin-bottom: 0"
productionDisplay={undefined} productionDisplay={undefined}
/> />
<MainDisplay <MainDisplay
resource={woodenBlocks} resource={woodenBlocks}
color={colorDark} color="cornflowerblue"
style="margin-bottom: 0" style="margin-bottom: 0"
productionDisplay={undefined} productionDisplay={undefined}
/> />
<MainDisplay <MainDisplay
resource={trucks} resource={trucks}
color={colorDark} color="cadetblue"
style="margin-bottom: 0" style="margin-bottom: 0"
productionDisplay={undefined} productionDisplay={undefined}
/> />
@ -311,6 +357,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<Spacer /> <Spacer />
{renderGrid(row1Upgrades)} {renderGrid(row1Upgrades)}
<Spacer /> <Spacer />
<div>You have {formatWhole(toySum.value)} toys</div>
{milestonesDisplay()} {milestonesDisplay()}
</> </>
)), )),

View file

@ -404,7 +404,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createAdditiveModifier(() => ({ createAdditiveModifier(() => ({
addend: 1, addend: 1,
description: "Automated Spade", description: "Automated Spade",
enabled: autoPlantUpgrade1.bought.value enabled: autoPlantUpgrade1.bought
})), })),
createAdditiveModifier(() => ({ createAdditiveModifier(() => ({
addend: () => Decimal.div(autoPlantingBuyable1.amount.value, 2), addend: () => Decimal.div(autoPlantingBuyable1.amount.value, 2),

View file

@ -49,7 +49,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
scaling: addHardcap( scaling: addHardcap(
addSoftcap(addSoftcap(createPolynomialScaling(250, 1.5), 5423, 1 / 1e10), 1e20, 3e8), addSoftcap(addSoftcap(createPolynomialScaling(250, 1.5), 5423, 1 / 1e10), 1e20, 3e8),
computed(() => computed(() =>
toys.row1Upgrades[2].bought toys.row1Upgrades[2].bought.value
? 1200 ? 1200
: management.elfTraining.expandersElfTraining.milestones[2].earned.value : management.elfTraining.expandersElfTraining.milestones[2].earned.value
? 1000 ? 1000
@ -74,6 +74,16 @@ const layer = createLayer(id, function (this: BaseLayer) {
exponent: 1 / 0.99, exponent: 1 / 0.99,
description: "Holly Level 5", description: "Holly Level 5",
enabled: management.elfTraining.cutterElfTraining.milestones[4].earned 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))
})) }))
]) ])
})); }));
@ -89,12 +99,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<br /> <br />
<span style="font-size: large"> <span style="font-size: large">
{masteryEffectActive.value ? "Requirement" : "Cost"}:{" "} {masteryEffectActive.value ? "Requirement" : "Cost"}:{" "}
{displayResource( {displayResource(trees.logs, foundationConversion.nextAt.value)}{" "}
trees.logs,
Decimal.gte(foundationConversion.actualGain.value, 1)
? foundationConversion.currentAt.value
: foundationConversion.nextAt.value
)}{" "}
{trees.logs.displayName} {trees.logs.displayName}
</span> </span>
</> </>

View file

@ -16,6 +16,7 @@ import { computed, Ref, unref, watchEffect } from "vue";
import { main } from "../projEntry"; import { main } from "../projEntry";
import { default as dyes, type enumColor } from "./dyes"; import { default as dyes, type enumColor } from "./dyes";
import elves from "./elves"; import elves from "./elves";
import toys from "./toys";
const id = "wrappingPaper"; const id = "wrappingPaper";
const day = 15; const day = 15;
@ -277,7 +278,10 @@ const layer = createLayer(id, () => {
beach1: computed(() => beach1: computed(() =>
main.isMastery.value main.isMastery.value
? 1 ? 1
: Decimal.add(wrappingPaper.beach.buyable.amount.value, 1).log10().add(1) : Decimal.add(wrappingPaper.beach.buyable.amount.value, 1)
.log10()
.add(1)
.pow(toys.milestones.milestone3.earned.value ? 1.6 : 1)
) )
}; };
const wrappingPaperSum = createResource( const wrappingPaperSum = createResource(

View file

@ -49,6 +49,7 @@ import paperSymbol from "./symbols/paperStacks.png";
import plasticSymbol from "./symbols/plastic.png"; import plasticSymbol from "./symbols/plastic.png";
import ribbonsSymbol from "./symbols/ribbons.png"; import ribbonsSymbol from "./symbols/ribbons.png";
import workshopSymbol from "./symbols/sws.png"; import workshopSymbol from "./symbols/sws.png";
import toysSymbol from "./symbols/truck.png";
import treeSymbol from "./symbols/tree.png"; import treeSymbol from "./symbols/tree.png";
import advManagementSymbol from "./symbols/workshopMansion.png"; import advManagementSymbol from "./symbols/workshopMansion.png";
import wrappingPaperSymbol from "./symbols/wrappingPaper.png"; import wrappingPaperSymbol from "./symbols/wrappingPaper.png";
@ -244,7 +245,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
} }
}, },
onUnlockLayer() { onUnlockLayer() {
if (layer) { if (layer != null) {
opened.value = true; opened.value = true;
setTimeout(() => { setTimeout(() => {
loreScene.value = -1; loreScene.value = -1;
@ -437,16 +438,17 @@ export const main = createLayer("main", function (this: BaseLayer) {
createDay(() => ({ createDay(() => ({
day: 17, day: 17,
shouldNotify: false, shouldNotify: false,
layer: "toys", // "toys1" layer: "toys",
symbol: "", symbol: toysSymbol,
story: "", story: "You've had enough of this running around and stalling - it is time to create some toys NOW! You have everything you need and then some, so let's finally just sit down and get this process started!",
completedStory: "", completedStory:
"In your haste you may have been a bit wasteful with resources, but it feels really good to finally make some meaningful process on making toys for Santa. You already envision plans on how to get elves to help you out and start pumping out these toys, but for now... Good Job!",
masteredStory: "" masteredStory: ""
})), })),
createDay(() => ({ createDay(() => ({
day: 18, day: 18,
shouldNotify: false, shouldNotify: false,
layer: null, // "toys2" layer: "factory",
symbol: "", symbol: "",
story: "", story: "",
completedStory: "", completedStory: "",
@ -558,10 +560,10 @@ export const main = createLayer("main", function (this: BaseLayer) {
display: jsx(() => ( display: jsx(() => (
<> <>
{player.devSpeed === 0 ? <div>Game Paused</div> : null} {player.devSpeed === 0 ? <div>Game Paused</div> : null}
{player.devSpeed && player.devSpeed !== 1 ? ( {player.devSpeed != null && player.devSpeed !== 0 && player.devSpeed !== 1 ? (
<div>Dev Speed: {format(player.devSpeed)}x</div> <div>Dev Speed: {format(player.devSpeed)}x</div>
) : null} ) : null}
{player.offlineTime ? ( {player.offlineTime != null && player.offlineTime !== 0 ? (
<div>Offline Time: {formatTime(player.offlineTime)}</div> <div>Offline Time: {formatTime(player.offlineTime)}</div>
) : null} ) : null}
<Spacer /> <Spacer />
@ -635,29 +637,5 @@ export function fixOldSave(
oldVersion: string | undefined, oldVersion: string | undefined,
player: Partial<PlayerData> player: Partial<PlayerData>
// eslint-disable-next-line @typescript-eslint/no-empty-function // eslint-disable-next-line @typescript-eslint/no-empty-function
): void { ): void {}
if (!["0.0", "0.1", "0.2", "0.3", "0.4"].includes(oldVersion ?? "")) {
return;
}
if ((player.layers?.workshop as LayerData<typeof workshop> | undefined)?.foundationProgress) {
(player.layers?.workshop as LayerData<typeof workshop> | undefined)!.foundationProgress =
Decimal.min(
(player.layers!.workshop as LayerData<typeof workshop> | undefined)!
.foundationProgress!,
1000
);
}
/*player.offlineProd = false;
delete player.layers?.management;
if ((player.layers?.main as LayerData<typeof main> | undefined)?.days?.[11]) {
(player.layers!.main as LayerData<typeof main>).days![11].opened = false;
}
if ((player.layers?.main as LayerData<typeof main> | undefined)?.day === 12) {
(player.layers!.main as LayerData<typeof main>).day === 11;
player.devSpeed = 0;
}
if (player.tabs) {
player.tabs = player.tabs.filter(l => l !== "management");
}*/
}
/* eslint-enable @typescript-eslint/no-unused-vars */ /* eslint-enable @typescript-eslint/no-unused-vars */

BIN
src/data/symbols/truck.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -109,7 +109,7 @@ export function createAchievement<T extends AchievementOptions>(
) { ) {
genericAchievement.earned.value = true; genericAchievement.earned.value = true;
genericAchievement.onComplete?.(); genericAchievement.onComplete?.();
if (genericAchievement.display) { if (genericAchievement.display != null) {
const Display = coerceComponent(unref(genericAchievement.display)); const Display = coerceComponent(unref(genericAchievement.display));
toast.info( toast.info(
<div> <div>

View file

@ -1,5 +1,11 @@
import BarComponent from "features/bars/Bar.vue"; import BarComponent from "features/bars/Bar.vue";
import type { CoercableComponent, GenericComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import type {
CoercableComponent,
GenericComponent,
OptionsFunc,
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature"; import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature";
import type { DecimalSource } from "util/bignum"; import type { DecimalSource } from "util/bignum";
import { Direction } from "util/common"; import { Direction } from "util/common";

View file

@ -210,7 +210,7 @@ function drag(e: MouseEvent | TouchEvent) {
hasDragged.value = true; hasDragged.value = true;
} }
if (dragging.value) { if (dragging.value != null) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
} }

View file

@ -234,17 +234,17 @@ const title = computed(() => getNodeProperty(props.nodeType.value.title, unref(p
const label = computed(() => getNodeProperty(props.nodeType.value.label, unref(props.node))); const label = computed(() => getNodeProperty(props.nodeType.value.label, unref(props.node)));
const size = computed(() => getNodeProperty(props.nodeType.value.size, unref(props.node))); const size = computed(() => getNodeProperty(props.nodeType.value.size, unref(props.node)));
const progress = computed( const progress = computed(
() => getNodeProperty(props.nodeType.value.progress, unref(props.node)) || 0 () => getNodeProperty(props.nodeType.value.progress, unref(props.node)) ?? 0
); );
const backgroundColor = computed(() => themes[settings.theme].variables["--background"]); const backgroundColor = computed(() => themes[settings.theme].variables["--background"]);
const outlineColor = computed( const outlineColor = computed(
() => () =>
getNodeProperty(props.nodeType.value.outlineColor, unref(props.node)) || getNodeProperty(props.nodeType.value.outlineColor, unref(props.node)) ??
themes[settings.theme].variables["--outline"] themes[settings.theme].variables["--outline"]
); );
const fillColor = computed( const fillColor = computed(
() => () =>
getNodeProperty(props.nodeType.value.fillColor, unref(props.node)) || getNodeProperty(props.nodeType.value.fillColor, unref(props.node)) ??
themes[settings.theme].variables["--raised-background"] themes[settings.theme].variables["--raised-background"]
); );
const progressColor = computed(() => const progressColor = computed(() =>
@ -252,7 +252,7 @@ const progressColor = computed(() =>
); );
const titleColor = computed( const titleColor = computed(
() => () =>
getNodeProperty(props.nodeType.value.titleColor, unref(props.node)) || getNodeProperty(props.nodeType.value.titleColor, unref(props.node)) ??
themes[settings.theme].variables["--foreground"] themes[settings.theme].variables["--foreground"]
); );
const progressDisplay = computed(() => const progressDisplay = computed(() =>

View file

@ -1,5 +1,11 @@
import ClickableComponent from "features/clickables/Clickable.vue"; import ClickableComponent from "features/clickables/Clickable.vue";
import type { CoercableComponent, GenericComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import type {
CoercableComponent,
GenericComponent,
OptionsFunc,
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature"; import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature";
import type { Resource } from "features/resources/resource"; import type { Resource } from "features/resources/resource";
import { DefaultValue, Persistent } from "game/persistence"; import { DefaultValue, Persistent } from "game/persistence";
@ -170,18 +176,18 @@ export function createBuyable<T extends BuyableOptions>(
} }
if (currDisplay != null && buyable.cost != null && buyable.resource != null) { if (currDisplay != null && buyable.cost != null && buyable.resource != null) {
const genericBuyable = buyable as GenericBuyable; const genericBuyable = buyable as GenericBuyable;
const Title = coerceComponent(currDisplay.title || "", "h3"); const Title = coerceComponent(currDisplay.title ?? "", "h3");
const Description = coerceComponent(currDisplay.description || ""); const Description = coerceComponent(currDisplay.description ?? "");
const EffectDisplay = coerceComponent(currDisplay.effectDisplay || ""); const EffectDisplay = coerceComponent(currDisplay.effectDisplay ?? "");
return ( return (
<span> <span>
{currDisplay.title ? ( {currDisplay.title == null ? null : (
<div> <div>
<Title /> <Title />
</div> </div>
) : null} )}
{currDisplay.description ? <Description /> : null} {currDisplay.description == null ? null : <Description />}
{currDisplay.showAmount === false ? null : ( {currDisplay.showAmount === false ? null : (
<div> <div>
<br /> <br />
@ -195,15 +201,15 @@ export function createBuyable<T extends BuyableOptions>(
)} )}
</div> </div>
)} )}
{currDisplay.effectDisplay ? ( {currDisplay.effectDisplay == null ? null : (
<div> <div>
<br /> <br />
Currently: <EffectDisplay /> Currently: <EffectDisplay />
</div> </div>
) : null} )}
{genericBuyable.cost && !genericBuyable.maxed.value ? ( {genericBuyable.cost != null && !genericBuyable.maxed.value ? (
<div> <div>
Cost: {format(unref(genericBuyable.cost) || 0)}{" "} Cost: {format(unref(genericBuyable.cost))}{" "}
{buyable.resource.displayName} {buyable.resource.displayName}
</div> </div>
) : null} ) : null}

View file

@ -134,25 +134,25 @@ export default defineComponent({
comp.value = coerceComponent( comp.value = coerceComponent(
jsx(() => ( jsx(() => (
<span> <span>
{currDisplay.title ? ( {currDisplay.title != null ? (
<div> <div>
<Title /> <Title />
</div> </div>
) : null} ) : null}
<Description /> <Description />
{currDisplay.goal ? ( {currDisplay.goal != null ? (
<div> <div>
<br /> <br />
Goal: <Goal /> Goal: <Goal />
</div> </div>
) : null} ) : null}
{currDisplay.reward ? ( {currDisplay.reward != null ? (
<div> <div>
<br /> <br />
Reward: <Reward /> Reward: <Reward />
</div> </div>
) : null} ) : null}
{currDisplay.effectDisplay ? ( {currDisplay.effectDisplay != null ? (
<div> <div>
Currently: <EffectDisplay /> Currently: <EffectDisplay />
</div> </div>

View file

@ -126,7 +126,10 @@ export function createChallenge<T extends ChallengeOptions>(
challenge.toggle = function () { challenge.toggle = function () {
const genericChallenge = challenge as GenericChallenge; const genericChallenge = challenge as GenericChallenge;
if (genericChallenge.active.value) { if (genericChallenge.active.value) {
if (unref(genericChallenge.canComplete) && !genericChallenge.maxed.value) { if (
unref(genericChallenge.canComplete) !== false &&
!genericChallenge.maxed.value
) {
let completions: boolean | DecimalSource = unref(genericChallenge.canComplete); let completions: boolean | DecimalSource = unref(genericChallenge.canComplete);
if (typeof completions === "boolean") { if (typeof completions === "boolean") {
completions = 1; completions = 1;
@ -264,11 +267,14 @@ export function setupAutoComplete(
exitOnComplete = true exitOnComplete = true
): WatchStopHandle { ): WatchStopHandle {
const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive; const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive;
return watch([challenge.canComplete, isActive], ([canComplete, isActive]) => { return watch(
if (canComplete && isActive) { [challenge.canComplete as Ref<boolean>, isActive as Ref<boolean>],
challenge.complete(!exitOnComplete); ([canComplete, isActive]) => {
if (canComplete && isActive) {
challenge.complete(!exitOnComplete);
}
} }
}); );
} }
export function createActiveChallenge( export function createActiveChallenge(

View file

@ -98,7 +98,7 @@ export default defineComponent({
comp.value = coerceComponent( comp.value = coerceComponent(
jsx(() => ( jsx(() => (
<span> <span>
{currDisplay.title ? ( {currDisplay.title != null ? (
<div> <div>
<Title /> <Title />
</div> </div>

View file

@ -1,5 +1,11 @@
import ClickableComponent from "features/clickables/Clickable.vue"; import ClickableComponent from "features/clickables/Clickable.vue";
import type { CoercableComponent, GenericComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import type {
CoercableComponent,
GenericComponent,
OptionsFunc,
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature"; import { Component, GatherProps, getUniqueID, setDefault, Visibility } from "features/feature";
import type { BaseLayer } from "game/layers"; import type { BaseLayer } from "game/layers";
import type { Unsubscribe } from "nanoevents"; import type { Unsubscribe } from "nanoevents";
@ -84,7 +90,7 @@ export function createClickable<T extends ClickableOptions>(
if (clickable.onClick) { if (clickable.onClick) {
const onClick = clickable.onClick.bind(clickable); const onClick = clickable.onClick.bind(clickable);
clickable.onClick = function (e) { clickable.onClick = function (e) {
if (unref(clickable.canClick)) { if (unref(clickable.canClick) !== false) {
onClick(e); onClick(e);
} }
}; };
@ -92,7 +98,7 @@ export function createClickable<T extends ClickableOptions>(
if (clickable.onHold) { if (clickable.onHold) {
const onHold = clickable.onHold.bind(clickable); const onHold = clickable.onHold.bind(clickable);
clickable.onHold = function () { clickable.onHold = function () {
if (unref(clickable.canClick)) { if (unref(clickable.canClick) !== false) {
onHold(); onHold();
} }
}; };
@ -136,7 +142,8 @@ export function setupAutoClick(
clickable: GenericClickable, clickable: GenericClickable,
autoActive: Computable<boolean> = true autoActive: Computable<boolean> = true
): Unsubscribe { ): Unsubscribe {
const isActive = typeof autoActive === "function" ? computed(autoActive) : autoActive; const isActive: ProcessedComputable<boolean> =
typeof autoActive === "function" ? computed(autoActive) : autoActive;
return layer.on("update", () => { return layer.on("update", () => {
if (unref(isActive) && unref(clickable.canClick)) { if (unref(isActive) && unref(clickable.canClick)) {
clickable.onClick?.(); clickable.onClick?.();

View file

@ -151,7 +151,7 @@ export function createConversion<T extends ConversionOptions>(
: conversion.scaling.currentGain(conversion as GenericConversion); : conversion.scaling.currentGain(conversion as GenericConversion);
gain = Decimal.floor(gain).max(0); gain = Decimal.floor(gain).max(0);
if (!unref(conversion.buyMax)) { if (unref(conversion.buyMax) === false) {
gain = gain.min(1); gain = gain.min(1);
} }
return gain; return gain;
@ -163,14 +163,15 @@ export function createConversion<T extends ConversionOptions>(
if (conversion.currentAt == null) { if (conversion.currentAt == null) {
conversion.currentAt = computed(() => { conversion.currentAt = computed(() => {
let current = conversion.scaling.currentAt(conversion as GenericConversion); let current = conversion.scaling.currentAt(conversion as GenericConversion);
if (conversion.roundUpCost) current = Decimal.ceil(current); if (unref((conversion as GenericConversion).roundUpCost))
current = Decimal.ceil(current);
return current; return current;
}); });
} }
if (conversion.nextAt == null) { if (conversion.nextAt == null) {
conversion.nextAt = computed(() => { conversion.nextAt = computed(() => {
let next = conversion.scaling.nextAt(conversion as GenericConversion); let next = conversion.scaling.nextAt(conversion as GenericConversion);
if (conversion.roundUpCost) next = Decimal.ceil(next); if (unref((conversion as GenericConversion).roundUpCost)) next = Decimal.ceil(next);
return next; return next;
}); });
} }
@ -405,7 +406,7 @@ export function createIndependentConversion<S extends ConversionOptions>(
: conversion.scaling.currentGain(conversion as GenericConversion); : conversion.scaling.currentGain(conversion as GenericConversion);
gain = Decimal.floor(gain).max(conversion.gainResource.value); gain = Decimal.floor(gain).max(conversion.gainResource.value);
if (!unref(conversion.buyMax)) { if (unref(conversion.buyMax) === false) {
gain = gain.min(Decimal.add(conversion.gainResource.value, 1)); gain = gain.min(Decimal.add(conversion.gainResource.value, 1));
} }
return gain; return gain;
@ -418,7 +419,7 @@ export function createIndependentConversion<S extends ConversionOptions>(
conversion.gainResource.value conversion.gainResource.value
).max(0); ).max(0);
if (!unref(conversion.buyMax)) { if (unref(conversion.buyMax) === false) {
gain = gain.min(1); gain = gain.min(1);
} }
return gain; return gain;
@ -511,8 +512,10 @@ export function addSoftcap(
): ScalingFunction { ): ScalingFunction {
return { return {
...scaling, ...scaling,
currentAt: conversion => softcap(scaling.currentAt(conversion), unref(cap), Decimal.recip(unref(power))), currentAt: conversion =>
nextAt: conversion => softcap(scaling.nextAt(conversion), unref(cap), Decimal.recip(unref(power))), softcap(scaling.currentAt(conversion), unref(cap), Decimal.recip(unref(power))),
nextAt: conversion =>
softcap(scaling.nextAt(conversion), unref(cap), Decimal.recip(unref(power))),
currentGain: conversion => currentGain: conversion =>
softcap(scaling.currentGain(conversion), unref(cap), unref(power)) softcap(scaling.currentGain(conversion), unref(cap), unref(power))
}; };

View file

@ -102,7 +102,7 @@ export function findFeatures(obj: Record<string, unknown>, ...types: symbol[]):
const handleObject = (obj: Record<string, unknown>) => { const handleObject = (obj: Record<string, unknown>) => {
Object.keys(obj).forEach(key => { Object.keys(obj).forEach(key => {
const value = obj[key]; const value = obj[key];
if (value && typeof value === "object") { if (value != null && typeof value === "object") {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
if (types.includes((value as Record<string, any>).type)) { if (types.includes((value as Record<string, any>).type)) {
objects.push(value); objects.push(value);
@ -127,7 +127,7 @@ export function excludeFeatures(obj: Record<string, unknown>, ...types: symbol[]
const handleObject = (obj: Record<string, unknown>) => { const handleObject = (obj: Record<string, unknown>) => {
Object.keys(obj).forEach(key => { Object.keys(obj).forEach(key => {
const value = obj[key]; const value = obj[key];
if (value && typeof value === "object") { if (value != null && typeof value === "object") {
if ( if (
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (value as Record<string, any>).type == "symbol" && typeof (value as Record<string, any>).type == "symbol" &&

View file

@ -74,12 +74,12 @@ export default defineComponent({
jsx(() => ( jsx(() => (
<span> <span>
<Requirement /> <Requirement />
{currDisplay.effectDisplay ? ( {currDisplay.effectDisplay != null ? (
<div> <div>
<EffectDisplay /> <EffectDisplay />
</div> </div>
) : null} ) : null}
{currDisplay.optionsDisplay ? ( {currDisplay.optionsDisplay != null ? (
<div class="equal-spaced"> <div class="equal-spaced">
<OptionsDisplay /> <OptionsDisplay />
</div> </div>

View file

@ -1,5 +1,11 @@
import Select from "components/fields/Select.vue"; import Select from "components/fields/Select.vue";
import type { CoercableComponent, GenericComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import type {
CoercableComponent,
GenericComponent,
OptionsFunc,
Replace,
StyleValue
} from "features/feature";
import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature"; import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature";
import MilestoneComponent from "features/milestones/Milestone.vue"; import MilestoneComponent from "features/milestones/Milestone.vue";
import { globalBus } from "game/events"; import { globalBus } from "game/events";
@ -92,7 +98,7 @@ export function createMilestone<T extends MilestoneOptions>(
const genericMilestone = milestone as GenericMilestone; const genericMilestone = milestone as GenericMilestone;
earned.value = true; earned.value = true;
genericMilestone.onComplete?.(); genericMilestone.onComplete?.();
if (genericMilestone.display && unref(genericMilestone.showPopups) === true) { if (genericMilestone.display != null && unref(genericMilestone.showPopups) === true) {
const display = unref(genericMilestone.display); const display = unref(genericMilestone.display);
const Display = coerceComponent( const Display = coerceComponent(
isCoercableComponent(display) ? display : display.requirement isCoercableComponent(display) ? display : display.requirement
@ -162,7 +168,10 @@ export function createMilestone<T extends MilestoneOptions>(
) { ) {
genericMilestone.earned.value = true; genericMilestone.earned.value = true;
genericMilestone.onComplete?.(); genericMilestone.onComplete?.();
if (genericMilestone.display && unref(genericMilestone.showPopups) === true) { if (
genericMilestone.display != null &&
unref(genericMilestone.showPopups) === true
) {
const display = unref(genericMilestone.display); const display = unref(genericMilestone.display);
const Display = coerceComponent( const Display = coerceComponent(
isCoercableComponent(display) ? display : display.requirement isCoercableComponent(display) ? display : display.requirement

View file

@ -43,7 +43,7 @@ export function createReset<T extends ResetOptions>(
reset.reset = function () { reset.reset = function () {
const handleObject = (obj: unknown) => { const handleObject = (obj: unknown) => {
if (obj && typeof obj === "object") { if (obj != null && typeof obj === "object") {
if (DefaultValue in obj) { if (DefaultValue in obj) {
const persistent = obj as NonPersistent; const persistent = obj as NonPersistent;
persistent.value = persistent[DefaultValue]; persistent.value = persistent[DefaultValue];

View file

@ -88,7 +88,7 @@ export function createTreeNode<T extends TreeNodeOptions>(
if (treeNode.onClick) { if (treeNode.onClick) {
const onClick = treeNode.onClick.bind(treeNode); const onClick = treeNode.onClick.bind(treeNode);
treeNode.onClick = function () { treeNode.onClick = function () {
if (unref(treeNode.canClick)) { if (unref(treeNode.canClick) !== false) {
onClick(); onClick();
} }
}; };
@ -96,7 +96,7 @@ export function createTreeNode<T extends TreeNodeOptions>(
if (treeNode.onHold) { if (treeNode.onHold) {
const onHold = treeNode.onHold.bind(treeNode); const onHold = treeNode.onHold.bind(treeNode);
treeNode.onHold = function () { treeNode.onHold = function () {
if (unref(treeNode.canClick)) { if (unref(treeNode.canClick) !== false) {
onHold(); onHold();
} }
}; };

View file

@ -96,13 +96,13 @@ export default defineComponent({
component.value = coerceComponent( component.value = coerceComponent(
jsx(() => ( jsx(() => (
<span> <span>
{currDisplay.title ? ( {currDisplay.title != null ? (
<div> <div>
<Title /> <Title />
</div> </div>
) : null} ) : null}
<Description /> <Description />
{currDisplay.effectDisplay ? ( {currDisplay.effectDisplay != null ? (
<div> <div>
Currently: <EffectDisplay /> Currently: <EffectDisplay />
</div> </div>

View file

@ -187,8 +187,11 @@ export function setupAutoPurchase(
autoActive: Computable<boolean>, autoActive: Computable<boolean>,
upgrades: GenericUpgrade[] = [] upgrades: GenericUpgrade[] = []
): void { ): void {
upgrades = upgrades || findFeatures(layer, UpgradeType); upgrades =
const isAutoActive = isFunction(autoActive) ? computed(autoActive) : autoActive; upgrades.length === 0 ? (findFeatures(layer, UpgradeType) as GenericUpgrade[]) : upgrades;
const isAutoActive: ProcessedComputable<boolean> = isFunction(autoActive)
? computed(autoActive)
: autoActive;
layer.on("update", () => { layer.on("update", () => {
if (unref(isAutoActive)) { if (unref(isAutoActive)) {
upgrades.forEach(upgrade => upgrade.purchase()); upgrades.forEach(upgrade => upgrade.purchase());

View file

@ -78,7 +78,7 @@ export function createAdditiveModifier<T extends AdditiveModifierOptions>(
? undefined ? undefined
: jsx(() => ( : jsx(() => (
<div class="modifier-container"> <div class="modifier-container">
{unref(processedDescription) ? ( {unref(processedDescription) != null ? (
<span class="modifier-description"> <span class="modifier-description">
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */} {/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
{renderJSX(unref(processedDescription)!)} {renderJSX(unref(processedDescription)!)}
@ -126,7 +126,7 @@ export function createMultiplicativeModifier<T extends MultiplicativeModifierOpt
? undefined ? undefined
: jsx(() => ( : jsx(() => (
<div class="modifier-container"> <div class="modifier-container">
{unref(processedDescription) ? ( {unref(processedDescription) != null ? (
<span class="modifier-description"> <span class="modifier-description">
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */} {/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
{renderJSX(unref(processedDescription)!)} {renderJSX(unref(processedDescription)!)}
@ -195,7 +195,7 @@ export function createExponentialModifier<T extends ExponentialModifierOptions>(
? undefined ? undefined
: jsx(() => ( : jsx(() => (
<div class="modifier-container"> <div class="modifier-container">
{unref(processedDescription) ? ( {unref(processedDescription) != null ? (
<span class="modifier-description"> <span class="modifier-description">
{/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */} {/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */}
{renderJSX(unref(processedDescription)!)} {renderJSX(unref(processedDescription)!)}

View file

@ -85,7 +85,7 @@ function getStackTrace() {
?.split("\n") ?.split("\n")
.slice(3, 5) .slice(3, 5)
.map(line => line.trim()) .map(line => line.trim())
.join("\n") || "" .join("\n") ?? ""
); );
} }
@ -134,7 +134,7 @@ export function persistent<T extends State>(defaultValue: T | Ref<T>): Persisten
*/ */
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export function isPersistent(value: any): value is Persistent { export function isPersistent(value: any): value is Persistent {
return value && typeof value === "object" && PersistentState in value; return value != null && typeof value === "object" && PersistentState in value;
} }
/** /**
@ -168,7 +168,7 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record<string, unknown>
let foundPersistent = false; let foundPersistent = false;
Object.keys(obj).forEach(key => { Object.keys(obj).forEach(key => {
let value = obj[key]; let value = obj[key];
if (value && typeof value === "object") { if (value != null && typeof value === "object") {
if (ProxyState in value) { if (ProxyState in value) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
value = (value as any)[ProxyState] as object; value = (value as any)[ProxyState] as object;

View file

@ -70,7 +70,7 @@ const state = reactive<PlayerData>({
modVersion: "", modVersion: "",
layers: {}, layers: {},
autoPause: true, autoPause: true
}); });
/** Convert a player save data object into a JSON string. Unwraps refs. */ /** Convert a player save data object into a JSON string. Unwraps refs. */

View file

@ -33,9 +33,9 @@ const state = reactive<Partial<Settings>>({
showTPS: true, showTPS: true,
theme: Themes.Nordic, theme: Themes.Nordic,
unthrottled: false, unthrottled: false,
usingLog: false, usingLog: false,
alignUnits: false, alignUnits: false
}); });
watch( watch(
@ -68,9 +68,9 @@ export const hardResetSettings = (window.hardResetSettings = () => {
saves: [], saves: [],
showTPS: true, showTPS: true,
theme: Themes.Nordic, theme: Themes.Nordic,
usingLog: false, usingLog: false,
alignUnits: false, alignUnits: false
}; };
globalBus.emit("loadSettings", settings); globalBus.emit("loadSettings", settings);
Object.assign(state, settings); Object.assign(state, settings);

View file

@ -33,7 +33,7 @@ declare global {
formatSmall: (x: DecimalSource, precision?: number) => string; formatSmall: (x: DecimalSource, precision?: number) => string;
formatLimit: (list: [DecimalSource, string][], unit: string) => string; formatLimit: (list: [DecimalSource, string][], unit: string) => string;
invertOOM: (x: DecimalSource) => Decimal; invertOOM: (x: DecimalSource) => Decimal;
formatGain: (x: DecimalSource) => string formatGain: (x: DecimalSource) => string;
} }
} }
window.Decimal = Decimal; window.Decimal = Decimal;
@ -47,6 +47,6 @@ window.toPlaces = toPlaces;
window.formatSmall = formatSmall; window.formatSmall = formatSmall;
window.formatLimit = formatLimit; window.formatLimit = formatLimit;
window.invertOOM = invertOOM; window.invertOOM = invertOOM;
window.formatGain = formatGain window.formatGain = formatGain;
export default Decimal; export default Decimal;

View file

@ -196,7 +196,11 @@ export function invertOOM(x: DecimalSource): Decimal {
return x; return x;
} }
export function formatLimit(list: [DecimalSource, string][], unit: string, gainMultiplier: DecimalSource = Decimal.dOne): string { export function formatLimit(
list: [DecimalSource, string][],
unit: string,
gainMultiplier: DecimalSource = Decimal.dOne
): string {
let num = list[0][0]; let num = list[0][0];
let str = list[0][1]; let str = list[0][1];
for (let i = 1; i < list.length; i++) { for (let i = 1; i < list.length; i++) {

View file

@ -39,7 +39,7 @@ export function createLazyProxy<T extends object, S extends T>(
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const val = (calculateObj() as any)[key]; const val = (calculateObj() as any)[key];
if (val && typeof val === "object" && NonPersistent in val) { if (val != null && typeof val === "object" && NonPersistent in val) {
return val[NonPersistent]; return val[NonPersistent];
} }
return val; return val;

View file

@ -86,7 +86,7 @@ export function getUniqueID(): string {
i = 0; i = 0;
do { do {
id = `${projInfo.id}-${i++}`; id = `${projInfo.id}-${i++}`;
} while (localStorage.getItem(id)); } while (localStorage.getItem(id) != null);
return id; return id;
} }
@ -107,7 +107,12 @@ export async function loadSave(playerObj: Partial<PlayerData>): Promise<void> {
getInitialLayers(playerObj).forEach(layer => addLayer(layer, playerObj)); getInitialLayers(playerObj).forEach(layer => addLayer(layer, playerObj));
playerObj = setupInitialStore(playerObj); playerObj = setupInitialStore(playerObj);
if (playerObj.offlineProd && playerObj.time && playerObj.devSpeed !== 0) { if (
playerObj.offlineProd &&
playerObj.time != null &&
playerObj.time &&
playerObj.devSpeed !== 0
) {
if (playerObj.offlineTime == undefined) playerObj.offlineTime = 0; if (playerObj.offlineTime == undefined) playerObj.offlineTime = 0;
playerObj.offlineTime += Math.min( playerObj.offlineTime += Math.min(
playerObj.offlineTime + (Date.now() - playerObj.time) / 1000, playerObj.offlineTime + (Date.now() - playerObj.time) / 1000,

View file

@ -229,7 +229,10 @@ export function computeOptionalComponent(
const comp = shallowRef<Component | "" | null>(null); const comp = shallowRef<Component | "" | null>(null);
watchEffect(() => { watchEffect(() => {
const currComponent = unwrapRef(component); const currComponent = unwrapRef(component);
comp.value = !currComponent ? null : coerceComponent(currComponent, defaultWrapper); comp.value =
currComponent == "" || currComponent == null
? null
: coerceComponent(currComponent, defaultWrapper);
}); });
return comp; return comp;
} }