2022-02-27 22:04:56 +00:00
|
|
|
import Modal from "@/components/Modal.vue";
|
|
|
|
import Profectus from "@/components/Profectus.vue";
|
|
|
|
import Spacer from "@/components/layout/Spacer.vue";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { jsx } from "@/features/feature";
|
2022-02-27 22:04:56 +00:00
|
|
|
import { createResource, trackBest, trackOOMPS, trackTotal } from "@/features/resources/resource";
|
|
|
|
import { branchedResetPropagation, createTree, GenericTree } from "@/features/trees/tree";
|
2022-01-14 04:25:47 +00:00
|
|
|
import { globalBus } from "@/game/events";
|
|
|
|
import { createLayer, GenericLayer } from "@/game/layers";
|
|
|
|
import player, { PlayerData } from "@/game/player";
|
|
|
|
import { DecimalSource } from "@/lib/break_eternity";
|
2022-02-27 19:49:34 +00:00
|
|
|
import Decimal, { format, formatTime } from "@/util/bignum";
|
2022-01-25 04:23:30 +00:00
|
|
|
import { render } from "@/util/vue";
|
2022-02-27 19:49:34 +00:00
|
|
|
import { computed, ref, toRaw } from "vue";
|
2022-01-14 04:25:47 +00:00
|
|
|
import a from "./layers/aca/a";
|
2022-01-28 04:47:26 +00:00
|
|
|
import c from "./layers/aca/c";
|
2022-01-14 04:25:47 +00:00
|
|
|
import f from "./layers/aca/f";
|
|
|
|
|
2022-01-28 04:47:26 +00:00
|
|
|
export const main = createLayer(() => {
|
2022-02-27 19:49:34 +00:00
|
|
|
const points = createResource<DecimalSource>(10);
|
2022-01-28 04:47:26 +00:00
|
|
|
const best = trackBest(points);
|
|
|
|
const total = trackTotal(points);
|
2022-02-27 19:49:34 +00:00
|
|
|
const showAchievements = ref(false);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-28 04:47:26 +00:00
|
|
|
const pointGain = computed(() => {
|
2022-02-27 19:49:34 +00:00
|
|
|
if (!c.generatorUpgrade.bought.value) return new Decimal(0);
|
2022-01-28 04:47:26 +00:00
|
|
|
let gain = new Decimal(3.19);
|
2022-02-27 19:49:34 +00:00
|
|
|
if (c.lollipopMultiplierUpgrade.bought.value)
|
|
|
|
gain = gain.times(c.lollipopMultiplierEffect.value);
|
2022-01-28 04:47:26 +00:00
|
|
|
return gain;
|
|
|
|
});
|
|
|
|
globalBus.on("update", diff => {
|
|
|
|
points.value = Decimal.add(points.value, Decimal.times(pointGain.value, diff));
|
|
|
|
});
|
2022-02-27 19:49:34 +00:00
|
|
|
const oomps = trackOOMPS(points, pointGain);
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-28 04:47:26 +00:00
|
|
|
// Note: Casting as generic tree to avoid recursive type definitions
|
2022-02-27 19:49:34 +00:00
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[c.treeNode], [f.treeNode, c.spook]],
|
|
|
|
leftSideNodes: [a.treeNode, c.h],
|
2022-01-28 04:47:26 +00:00
|
|
|
branches: [
|
|
|
|
{
|
2022-02-27 19:49:34 +00:00
|
|
|
startNode: f.treeNode,
|
|
|
|
endNode: c.treeNode,
|
2022-01-28 04:47:26 +00:00
|
|
|
stroke: "blue",
|
|
|
|
"stroke-width": "25px",
|
|
|
|
style: {
|
|
|
|
filter: "blur(5px)"
|
|
|
|
}
|
|
|
|
},
|
2022-02-27 19:49:34 +00:00
|
|
|
{ startNode: c.treeNode, endNode: c.g }
|
|
|
|
],
|
|
|
|
onReset() {
|
|
|
|
points.value = toRaw(this.resettingNode.value) === toRaw(c.treeNode) ? 0 : 10;
|
|
|
|
best.value = points.value;
|
|
|
|
total.value = points.value;
|
|
|
|
},
|
|
|
|
resetPropagation: branchedResetPropagation
|
|
|
|
})) as GenericTree;
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-01-28 04:47:26 +00:00
|
|
|
// Note: layers don't _need_ a reference to everything,
|
|
|
|
// but I'd recommend it over trying to remember what does and doesn't need to be included.
|
|
|
|
// Officially all you need are anything with persistency or that you want to access elsewhere
|
|
|
|
return {
|
|
|
|
id: "main",
|
|
|
|
name: "Tree",
|
|
|
|
links: tree.links,
|
2022-02-27 19:49:34 +00:00
|
|
|
display: jsx(() => (
|
|
|
|
<>
|
2022-01-28 04:47:26 +00:00
|
|
|
<div v-show={player.devSpeed === 0}>Game Paused</div>
|
|
|
|
<div v-show={player.devSpeed && player.devSpeed !== 1}>
|
|
|
|
Dev Speed: {format(player.devSpeed || 0)}x
|
|
|
|
</div>
|
|
|
|
<div v-show={player.offlineTime != undefined}>
|
|
|
|
Offline Time: {formatTime(player.offlineTime || 0)}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<span v-show={Decimal.lt(points.value, "1e1000")}>You have </span>
|
|
|
|
<h2>{format(points.value)}</h2>
|
|
|
|
<span v-show={Decimal.lt(points.value, "1e1e6")}> points</span>
|
|
|
|
</div>
|
2022-02-27 19:49:34 +00:00
|
|
|
<div v-show={Decimal.gt(pointGain.value, 0)}>({oomps.value})</div>
|
2022-01-28 04:47:26 +00:00
|
|
|
<Spacer />
|
2022-02-27 19:49:34 +00:00
|
|
|
<button onClick={() => (showAchievements.value = true)}>open achievements</button>
|
2022-01-28 04:47:26 +00:00
|
|
|
<Modal
|
2022-02-27 19:49:34 +00:00
|
|
|
modelValue={showAchievements.value}
|
|
|
|
onUpdate:modelValue={value => (showAchievements.value = value)}
|
|
|
|
v-slots={{
|
|
|
|
header: () => <h2>Achievements</h2>,
|
|
|
|
body: a.display
|
|
|
|
}}
|
|
|
|
/>
|
2022-01-28 04:47:26 +00:00
|
|
|
{render(tree)}
|
2022-02-27 20:24:48 +00:00
|
|
|
<Profectus height="200px" style="margin: 10px auto; display: block" />
|
2022-02-27 19:49:34 +00:00
|
|
|
</>
|
|
|
|
)),
|
2022-01-28 04:47:26 +00:00
|
|
|
points,
|
|
|
|
best,
|
|
|
|
total,
|
|
|
|
oomps,
|
2022-02-27 19:49:34 +00:00
|
|
|
tree,
|
|
|
|
showAchievements
|
2022-01-28 04:47:26 +00:00
|
|
|
};
|
2022-01-14 04:25:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export const getInitialLayers = (
|
|
|
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
|
|
|
player: Partial<PlayerData>
|
2022-02-27 19:49:34 +00:00
|
|
|
): Array<GenericLayer> => [main, f, c, a];
|
2022-01-14 04:25:47 +00:00
|
|
|
|
|
|
|
export const hasWon = computed(() => {
|
2022-02-27 22:55:43 +00:00
|
|
|
return Decimal.gt(main.points.value, 25);
|
2022-01-14 04:25:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
|
|
export function fixOldSave(
|
|
|
|
oldVersion: string | undefined,
|
|
|
|
player: Partial<PlayerData>
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
): void {}
|
|
|
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|