Fix typing cycle

This commit is contained in:
thepaperpilot 2022-12-22 22:54:02 -06:00
parent 5cae3ea040
commit c4abf0cd5a
2 changed files with 139 additions and 129 deletions

View file

@ -18,17 +18,18 @@ import { createResource, Resource } from "features/resources/resource";
import { createTab } from "features/tabs/tab"; import { createTab } from "features/tabs/tab";
import { createTabFamily } from "features/tabs/tabFamily"; import { createTabFamily } from "features/tabs/tabFamily";
import Tooltip from "features/tooltips/Tooltip.vue"; import Tooltip from "features/tooltips/Tooltip.vue";
import { createUpgrade } from "features/upgrades/upgrade";
import { globalBus } from "game/events"; import { globalBus } from "game/events";
import { createLayer } from "game/layers"; import { createLayer } from "game/layers";
import { createUpgrade, GenericUpgrade } from "features/upgrades/upgrade";
import { import {
createAdditiveModifier, createAdditiveModifier,
createMultiplicativeModifier, createMultiplicativeModifier,
createSequentialModifier createSequentialModifier,
Modifier
} from "game/modifiers"; } from "game/modifiers";
import { noPersist, Persistent, persistent, State } from "game/persistence"; import { noPersist, Persistent, persistent, State } from "game/persistence";
import Decimal, { DecimalSource, format, formatWhole } from "util/bignum"; import Decimal, { DecimalSource, format, formatWhole } from "util/bignum";
import { Direction } from "util/common"; import { Direction, WithRequired } from "util/common";
import { ProcessedComputable } from "util/computed"; import { ProcessedComputable } from "util/computed";
import { render, renderGrid, renderRow, VueFeature } from "util/vue"; import { render, renderGrid, renderRow, VueFeature } from "util/vue";
import { computed, ComputedRef, reactive, ref, unref, watchEffect } from "vue"; import { computed, ComputedRef, reactive, ref, unref, watchEffect } from "vue";
@ -38,22 +39,23 @@ import _metal from "../symbols/metal.png";
import _plastic from "../symbols/plastic.png"; import _plastic from "../symbols/plastic.png";
import boxes from "./boxes"; import boxes from "./boxes";
import coal from "./coal"; import coal from "./coal";
import dyes from "./dyes";
import _bear from "./factory-components/bear.svg"; import _bear from "./factory-components/bear.svg";
import _bearMaker from "./factory-components/bearmaker.svg"; import _bearMaker from "./factory-components/bearmaker.svg";
import _stuffing from "./factory-components/stuffing.svg";
import _console from "./factory-components/console.svg";
import _circuitBoard from "./factory-components/circuit.svg";
import _stuffingMaker from "./factory-components/stuffingmaker.svg";
import _consoleMaker from "./factory-components/consolemaker.svg";
import _circuitBoardMaker from "./factory-components/circuitmaker.svg";
import _block from "./factory-components/block.svg"; import _block from "./factory-components/block.svg";
import _blockMaker from "./factory-components/blockmaker.svg"; import _blockMaker from "./factory-components/blockmaker.svg";
import _bucket from "./factory-components/bucket.svg"; import _bucket from "./factory-components/bucket.svg";
import _bucketMaker from "./factory-components/bucketmaker.svg"; import _bucketMaker from "./factory-components/bucketmaker.svg";
import _bucketShovel from "./factory-components/bucketshovel.svg"; import _bucketShovel from "./factory-components/bucketshovel.svg";
import _bucketShovelMaker from "./factory-components/bucketshovelmaker.svg"; import _bucketShovelMaker from "./factory-components/bucketshovelmaker.svg";
import _button from "./factory-components/button.svg";
import _buttonMaker from "./factory-components/buttonmaker.svg";
import _circuitBoard from "./factory-components/circuit.svg";
import _circuitBoardMaker from "./factory-components/circuitmaker.svg";
import _clothes from "./factory-components/clothes.svg"; import _clothes from "./factory-components/clothes.svg";
import _clothesMaker from "./factory-components/clothesmaker.svg"; import _clothesMaker from "./factory-components/clothesmaker.svg";
import _console from "./factory-components/console.svg";
import _consoleMaker from "./factory-components/consolemaker.svg";
import _conveyor from "./factory-components/conveyor.png"; import _conveyor from "./factory-components/conveyor.png";
import _cursor from "./factory-components/cursor.svg"; import _cursor from "./factory-components/cursor.svg";
import _delete from "./factory-components/delete.svg"; import _delete from "./factory-components/delete.svg";
@ -63,10 +65,10 @@ import _rotateLeft from "./factory-components/rotateLeft.svg";
import _rotateRight from "./factory-components/rotateRight.svg"; import _rotateRight from "./factory-components/rotateRight.svg";
import _plankMaker from "./factory-components/sawmill.svg"; import _plankMaker from "./factory-components/sawmill.svg";
import _shed from "./factory-components/shed.svg"; import _shed from "./factory-components/shed.svg";
import _button from "./factory-components/button.svg";
import _shovel from "./factory-components/shovel.svg"; import _shovel from "./factory-components/shovel.svg";
import _shovelMaker from "./factory-components/shovelmaker.svg"; import _shovelMaker from "./factory-components/shovelmaker.svg";
import _buttonMaker from "./factory-components/buttonmaker.svg"; import _stuffing from "./factory-components/stuffing.svg";
import _stuffingMaker from "./factory-components/stuffingmaker.svg";
import _thread from "./factory-components/thread.svg"; import _thread from "./factory-components/thread.svg";
import _threadMaker from "./factory-components/threadmaker.svg"; import _threadMaker from "./factory-components/threadmaker.svg";
import _truck from "./factory-components/truck.svg"; import _truck from "./factory-components/truck.svg";
@ -74,16 +76,15 @@ import _truckMaker from "./factory-components/truckmaker.svg";
import _wheel from "./factory-components/wheel.svg"; import _wheel from "./factory-components/wheel.svg";
import _wheelMaker from "./factory-components/wheelmaker.svg"; import _wheelMaker from "./factory-components/wheelmaker.svg";
import Factory from "./Factory.vue"; import Factory from "./Factory.vue";
import metal from "./metal";
import oil from "./oil"; import oil from "./oil";
import paper from "./paper";
import plastic from "./plastic";
import "./styles/factory.css"; import "./styles/factory.css";
import Toy from "./Toy.vue"; import Toy from "./Toy.vue";
import toys from "./toys"; import toys from "./toys";
import trees from "./trees"; import trees from "./trees";
import workshop from "./workshop"; import workshop from "./workshop";
import paper from "./paper";
import metal from "./metal";
import dyes from "./dyes";
import plastic from "./plastic";
const id = "factory"; const id = "factory";
@ -172,7 +173,7 @@ const factory = createLayer(id, () => {
description: "6000 toys", description: "6000 toys",
enabled: toys.milestones.milestone6.earned enabled: toys.milestones.milestone6.earned
})) }))
]); ]) as WithRequired<Modifier, "revert" | "description">;
const computedEnergy = computed(() => energy.apply(0)); const computedEnergy = computed(() => energy.apply(0));
const energyConsumption = computed(() => const energyConsumption = computed(() =>
Object.values(components.value) Object.values(components.value)
@ -1057,116 +1058,124 @@ const factory = createLayer(id, () => {
visible: () => showIf(main.days[advancedDay - 1].opened.value) visible: () => showIf(main.days[advancedDay - 1].opened.value)
})) as GenericBuyable; })) as GenericBuyable;
const factoryBuyables = { expandFactory, oilFuel, carryToys }; const factoryBuyables = { expandFactory, oilFuel, carryToys };
const upgrades = [[createUpgrade(() => ({ const upgrades = [
resource: trees.logs, [
cost: () =>Decimal.pow(5, upgradeAmount.value).mul(1e75), createUpgrade(() => ({
display: { resource: trees.logs,
title: "Sawmill Efficiency", cost: () => Decimal.pow(5, upgradeAmount.value).mul(1e75),
description: "Double sawmill consumption and production and metal supplier efficiency" display: {
}, title: "Sawmill Efficiency",
visible: () => showIf(main.days[advancedDay - 1].opened.value) description:
})), "Double sawmill consumption and production and metal supplier efficiency"
createUpgrade(() => ({ },
resource: paper.paper, visible: () => showIf(main.days[advancedDay - 1].opened.value)
cost: () =>Decimal.pow(5, upgradeAmount.value).mul(1e90), })),
display: { createUpgrade(() => ({
title: "News Ticker", resource: paper.paper,
description: "Paper boosts tick speed" cost: () => Decimal.pow(5, upgradeAmount.value).mul(1e90),
}, display: {
visible: () => showIf(main.days[advancedDay - 1].opened.value) title: "News Ticker",
})), description: "Paper boosts tick speed"
createUpgrade(() => ({ },
resource: toys.trucks, visible: () => showIf(main.days[advancedDay - 1].opened.value)
cost: () =>Decimal.pow(1.2, upgradeAmount.value).mul(1000), })),
display: { createUpgrade(() => ({
title: "Haul wood in trucks", resource: toys.trucks,
description: "Trucks multiply wood gain" cost: () => Decimal.pow(1.2, upgradeAmount.value).mul(1000),
}, display: {
visible: () => showIf(main.days[advancedDay - 1].opened.value) title: "Haul wood in trucks",
})), description: "Trucks multiply wood gain"
createUpgrade(() => ({ },
resource: metal.metal, visible: () => showIf(main.days[advancedDay - 1].opened.value)
cost: () =>Decimal.pow(3, upgradeAmount.value).mul(1e53), })),
display: { createUpgrade(() => ({
title: "Diamond-tipped drills", resource: metal.metal,
description: "Drill power ^1.2" cost: () => Decimal.pow(3, upgradeAmount.value).mul(1e53),
}, display: {
visible: () => showIf(main.days[advancedDay - 1].opened.value) title: "Diamond-tipped drills",
}))], description: "Drill power ^1.2"
[createUpgrade(() => ({ },
resource: toys.woodenBlocks, visible: () => showIf(main.days[advancedDay - 1].opened.value)
cost: () =>Decimal.pow(1.2, upgradeAmount.value).mul(2000), }))
display: { ],
title: "Larger wood pieces", [
description: "Wooden block producers produce 3x as much" createUpgrade(() => ({
}, resource: toys.woodenBlocks,
visible: () => showIf(main.days[advancedDay - 1].opened.value) cost: () => Decimal.pow(1.2, upgradeAmount.value).mul(2000),
})), display: {
createUpgrade(() => ({ title: "Larger wood pieces",
resource: dyes.dyes.red.amount, description: "Wooden block producers produce 3x as much"
cost: () =>Decimal.pow(1.5, upgradeAmount.value).mul(4e16), },
display: { visible: () => showIf(main.days[advancedDay - 1].opened.value)
title: "Colorful clothes", })),
description: "Dye producers produce 4x as much" createUpgrade(() => ({
}, resource: dyes.dyes.red.amount,
visible: () => showIf(main.days[advancedDay - 1].opened.value) cost: () => Decimal.pow(1.5, upgradeAmount.value).mul(4e16),
})), display: {
createUpgrade(() => ({ title: "Colorful clothes",
resource: plastic.plastic, description: "Dye producers produce 4x as much"
cost: () =>Decimal.pow(2, upgradeAmount.value).mul(1e17), },
display: { visible: () => showIf(main.days[advancedDay - 1].opened.value)
title: "Improved plastic producers", })),
description: "Plastic producers produce 4x as much" createUpgrade(() => ({
}, resource: plastic.plastic,
visible: () => showIf(main.days[advancedDay - 1].opened.value) cost: () => Decimal.pow(2, upgradeAmount.value).mul(1e17),
})), display: {
createUpgrade(() => ({ title: "Improved plastic producers",
resource: oil.oil, description: "Plastic producers produce 4x as much"
cost: () =>Decimal.pow(1.5, upgradeAmount.value).mul(1e22), },
display: { visible: () => showIf(main.days[advancedDay - 1].opened.value)
title: "Capitalism", })),
description: "Console production is tripled" createUpgrade(() => ({
}, resource: oil.oil,
visible: () => showIf(main.days[advancedDay - 1].opened.value) cost: () => Decimal.pow(1.5, upgradeAmount.value).mul(1e22),
}))], display: {
[createUpgrade(() => ({ title: "Capitalism",
resource: coal.coal, description: "Console production is tripled"
cost: () =>Decimal.pow(5, upgradeAmount.value).mul(1e130), },
display: { visible: () => showIf(main.days[advancedDay - 1].opened.value)
title: "Brighter work rooms", }))
description: "Unused electricity makes ticks faster" ],
}, [
visible: () => showIf(main.days[advancedDay - 1].opened.value) createUpgrade(() => ({
})), resource: coal.coal,
createUpgrade(() => ({ cost: () => Decimal.pow(5, upgradeAmount.value).mul(1e130),
resource: dyes.dyes.blue.amount, display: {
cost: () =>Decimal.pow(1.4, upgradeAmount.value).mul(1e15), title: "Brighter work rooms",
display: { description: "Unused electricity makes ticks faster"
title: "Colorful teddy bears", },
description: "Teddy bears produce 2x as much" visible: () => showIf(main.days[advancedDay - 1].opened.value)
}, })),
visible: () => showIf(main.days[advancedDay - 1].opened.value) createUpgrade(() => ({
})), resource: dyes.dyes.blue.amount,
createUpgrade(() => ({ cost: () => Decimal.pow(1.4, upgradeAmount.value).mul(1e15),
resource: dyes.dyes.black.amount, display: {
cost: () =>Decimal.pow(1.5, upgradeAmount.value).mul(1e6), title: "Colorful teddy bears",
display: { description: "Teddy bears produce 2x as much"
title: "New Colors", },
description: "Unlock white dye" visible: () => showIf(main.days[advancedDay - 1].opened.value)
}, })),
visible: () => showIf(main.days[advancedDay - 1].opened.value) createUpgrade(() => ({
})), resource: dyes.dyes.black.amount,
createUpgrade(() => ({ cost: () => Decimal.pow(1.5, upgradeAmount.value).mul(1e6),
resource: boxes.boxes, display: {
cost: () =>Decimal.pow(3, upgradeAmount.value).mul(1e80), title: "New Colors",
display: { description: "Unlock white dye"
title: "Carry ticks in boxes", },
description: "Tick speed x1.5" visible: () => showIf(main.days[advancedDay - 1].opened.value)
}, })),
visible: () => showIf(main.days[advancedDay - 1].opened.value) createUpgrade(() => ({
}))], resource: boxes.boxes,
] cost: () => Decimal.pow(3, upgradeAmount.value).mul(1e80),
display: {
title: "Carry ticks in boxes",
description: "Tick speed x1.5"
},
visible: () => showIf(main.days[advancedDay - 1].opened.value)
}))
]
];
// pixi // pixi
const upgradeAmount = computed( const upgradeAmount = computed(
() => upgrades.flat().filter(u => u.bought.value).length () => upgrades.flat().filter(u => u.bought.value).length

View file

@ -24,11 +24,12 @@ import {
createAdditiveModifier, createAdditiveModifier,
createExponentialModifier, createExponentialModifier,
createMultiplicativeModifier, createMultiplicativeModifier,
createSequentialModifier createSequentialModifier,
Modifier
} from "game/modifiers"; } from "game/modifiers";
import { noPersist, persistent } from "game/persistence"; import { noPersist, persistent } from "game/persistence";
import Decimal, { DecimalSource, formatWhole } from "util/bignum"; import Decimal, { DecimalSource, formatWhole } from "util/bignum";
import { Direction } from "util/common"; import { Direction, WithRequired } from "util/common";
import { render } from "util/vue"; import { render } from "util/vue";
import { computed, ref, unref, watchEffect } from "vue"; import { computed, ref, unref, watchEffect } from "vue";
import elves from "./elves"; import elves from "./elves";
@ -63,7 +64,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
description: "Expand Factory", description: "Expand Factory",
enabled: () => Decimal.gt(factory.factoryBuyables.expandFactory.amount.value, 0) enabled: () => Decimal.gt(factory.factoryBuyables.expandFactory.amount.value, 0)
})) }))
]); ]) as WithRequired<Modifier, "revert" | "description">;
const computedMaxFoundation = computed(() => maxFoundation.apply(100)); const computedMaxFoundation = computed(() => maxFoundation.apply(100));
const foundationConversion = createIndependentConversion(() => ({ const foundationConversion = createIndependentConversion(() => ({