2022-03-04 03:39:48 +00:00
|
|
|
import Spacer from "components/layout/Spacer.vue";
|
|
|
|
import { jsx } from "features/feature";
|
|
|
|
import { createResource, trackBest, trackOOMPS, trackTotal } from "features/resources/resource";
|
2022-06-27 00:17:22 +00:00
|
|
|
import type { GenericTree } from "features/trees/tree";
|
|
|
|
import { branchedResetPropagation, createTree } from "features/trees/tree";
|
2022-03-04 03:39:48 +00:00
|
|
|
import { globalBus } from "game/events";
|
2023-04-02 04:42:12 +00:00
|
|
|
import Formula, {
|
|
|
|
calculateCost,
|
|
|
|
calculateMaxAffordable,
|
2023-04-02 05:48:48 +00:00
|
|
|
findNonInvertible,
|
|
|
|
printFormula
|
2023-04-02 04:42:12 +00:00
|
|
|
} from "game/formulas/formulas";
|
2022-07-22 23:59:52 +00:00
|
|
|
import type { BaseLayer, GenericLayer } from "game/layers";
|
2022-06-27 00:17:22 +00:00
|
|
|
import { createLayer } from "game/layers";
|
2022-12-28 15:03:51 +00:00
|
|
|
import type { Player } from "game/player";
|
2022-06-27 00:17:22 +00:00
|
|
|
import player from "game/player";
|
|
|
|
import type { DecimalSource } from "util/bignum";
|
|
|
|
import Decimal, { format, formatTime } from "util/bignum";
|
2022-03-04 03:39:48 +00:00
|
|
|
import { render } from "util/vue";
|
2023-03-24 01:22:03 +00:00
|
|
|
import { computed, ref, toRaw, unref } from "vue";
|
2022-02-28 00:31:51 +00:00
|
|
|
import prestige from "./layers/prestige";
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2023-03-24 01:22:03 +00:00
|
|
|
window.Formula = Formula;
|
|
|
|
window.calculateMaxAffordable = calculateMaxAffordable;
|
|
|
|
window.calculateCost = calculateCost;
|
2023-04-02 04:42:12 +00:00
|
|
|
window.findNonInvertible = findNonInvertible;
|
2023-04-02 05:48:48 +00:00
|
|
|
window.printFormula = printFormula;
|
2023-03-24 01:22:03 +00:00
|
|
|
window.unref = unref;
|
|
|
|
window.ref = ref;
|
|
|
|
window.createResource = createResource;
|
|
|
|
|
2022-03-08 06:25:08 +00:00
|
|
|
/**
|
|
|
|
* @hidden
|
|
|
|
*/
|
2022-07-22 23:59:52 +00:00
|
|
|
export const main = createLayer("main", function (this: BaseLayer) {
|
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-01-14 04:25:47 +00:00
|
|
|
|
2022-01-28 04:47:26 +00:00
|
|
|
const pointGain = computed(() => {
|
2022-02-28 04:10:42 +00:00
|
|
|
// eslint-disable-next-line prefer-const
|
2022-02-28 00:31:51 +00:00
|
|
|
let gain = new Decimal(1);
|
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-02-27 19:49:34 +00:00
|
|
|
const tree = createTree(() => ({
|
2022-02-28 00:31:51 +00:00
|
|
|
nodes: [[prestige.treeNode]],
|
|
|
|
branches: [],
|
2022-02-27 19:49:34 +00:00
|
|
|
onReset() {
|
2022-02-28 00:31:51 +00:00
|
|
|
points.value = toRaw(this.resettingNode.value) === toRaw(prestige.treeNode) ? 0 : 10;
|
2022-02-27 19:49:34 +00:00
|
|
|
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
|
|
|
return {
|
|
|
|
name: "Tree",
|
|
|
|
links: tree.links,
|
2022-02-27 19:49:34 +00:00
|
|
|
display: jsx(() => (
|
|
|
|
<>
|
2022-04-24 03:13:56 +00:00
|
|
|
{player.devSpeed === 0 ? <div>Game Paused</div> : null}
|
2022-12-21 03:56:41 +00:00
|
|
|
{player.devSpeed != null && player.devSpeed !== 0 && player.devSpeed !== 1 ? (
|
2022-05-11 02:01:57 +00:00
|
|
|
<div>Dev Speed: {format(player.devSpeed)}x</div>
|
2022-04-24 03:13:56 +00:00
|
|
|
) : null}
|
2022-12-21 03:26:25 +00:00
|
|
|
{player.offlineTime != null && player.offlineTime !== 0 ? (
|
2022-05-11 02:01:57 +00:00
|
|
|
<div>Offline Time: {formatTime(player.offlineTime)}</div>
|
2022-04-24 03:13:56 +00:00
|
|
|
) : null}
|
2022-01-28 04:47:26 +00:00
|
|
|
<div>
|
2022-04-24 03:13:56 +00:00
|
|
|
{Decimal.lt(points.value, "1e1000") ? <span>You have </span> : null}
|
2022-01-28 04:47:26 +00:00
|
|
|
<h2>{format(points.value)}</h2>
|
2022-04-24 03:13:56 +00:00
|
|
|
{Decimal.lt(points.value, "1e1e6") ? <span> points</span> : null}
|
2022-01-28 04:47:26 +00:00
|
|
|
</div>
|
2022-04-24 03:13:56 +00:00
|
|
|
{Decimal.gt(pointGain.value, 0) ? <div>({oomps.value})</div> : null}
|
2022-01-28 04:47:26 +00:00
|
|
|
<Spacer />
|
|
|
|
{render(tree)}
|
2022-02-27 19:49:34 +00:00
|
|
|
</>
|
|
|
|
)),
|
2022-01-28 04:47:26 +00:00
|
|
|
points,
|
|
|
|
best,
|
|
|
|
total,
|
|
|
|
oomps,
|
2022-02-28 00:31:51 +00:00
|
|
|
tree
|
2022-01-28 04:47:26 +00:00
|
|
|
};
|
2022-01-14 04:25:47 +00:00
|
|
|
});
|
|
|
|
|
2022-07-10 06:44:45 +00:00
|
|
|
/**
|
|
|
|
* Given a player save data object being loaded, return a list of layers that should currently be enabled.
|
|
|
|
* If your project does not use dynamic layers, this should just return all layers.
|
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
export const getInitialLayers = (
|
|
|
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
2022-12-28 15:03:51 +00:00
|
|
|
player: Partial<Player>
|
2022-02-28 00:31:51 +00:00
|
|
|
): Array<GenericLayer> => [main, prestige];
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-07-10 06:44:45 +00:00
|
|
|
/**
|
|
|
|
* A computed ref whose value is true whenever the game is over.
|
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
export const hasWon = computed(() => {
|
2022-02-28 00:31:51 +00:00
|
|
|
return false;
|
2022-01-14 04:25:47 +00:00
|
|
|
});
|
|
|
|
|
2022-07-10 06:44:45 +00:00
|
|
|
/**
|
|
|
|
* Given a player save data object being loaded with a different version, update the save data object to match the structure of the current version.
|
|
|
|
* @param oldVersion The version of the save being loaded in
|
|
|
|
* @param player The save data being loaded in
|
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
|
|
export function fixOldSave(
|
|
|
|
oldVersion: string | undefined,
|
2022-12-28 15:03:51 +00:00
|
|
|
player: Partial<Player>
|
2022-01-14 04:25:47 +00:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
): void {}
|
|
|
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|