mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2025-04-01 05:21:07 +00:00
Implement treasures doing things on earn, per tick, and showing links
This commit is contained in:
parent
df01c32454
commit
da393b7f5a
2 changed files with 51 additions and 4 deletions
|
@ -18,14 +18,15 @@ import Decimal, { DecimalSource } from "util/bignum";
|
||||||
import { format } from "util/break_eternity";
|
import { format } from "util/break_eternity";
|
||||||
import { Direction, WithRequired, camelToTitle } from "util/common";
|
import { Direction, WithRequired, camelToTitle } from "util/common";
|
||||||
import { VueFeature, render, renderRow, trackHover } from "util/vue";
|
import { VueFeature, render, renderRow, trackHover } from "util/vue";
|
||||||
import { Ref, computed, ref } from "vue";
|
import { ComputedRef, Ref, computed, ref } from "vue";
|
||||||
import { createCollapsibleModifierSections, createFormulaPreview, estimateTime } from "./common";
|
import { createCollapsibleModifierSections, createFormulaPreview, estimateTime } from "./common";
|
||||||
import { Resources, resourceNames } from "./projEntry";
|
import { main, Resources, resourceNames } from "./projEntry";
|
||||||
import { getColor, getName, sfc32 } from "./utils";
|
import { getColor, getName, sfc32 } from "./utils";
|
||||||
import ModalVue from "components/Modal.vue";
|
import ModalVue from "components/Modal.vue";
|
||||||
import { addTooltip } from "features/tooltips/tooltip";
|
import { addTooltip } from "features/tooltips/tooltip";
|
||||||
import { GenericAchievement, createAchievement } from "features/achievements/achievement";
|
import { GenericAchievement, createAchievement } from "features/achievements/achievement";
|
||||||
import { Computable } from "util/computed";
|
import { Computable } from "util/computed";
|
||||||
|
import { BoardNode } from "features/boards/board";
|
||||||
|
|
||||||
export function createPlane(id: string, tier: Resources, seed: number) {
|
export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
return createLayer(id, function (this: BaseLayer) {
|
return createLayer(id, function (this: BaseLayer) {
|
||||||
|
@ -205,9 +206,14 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
continue; // Should not happen
|
continue; // Should not happen
|
||||||
}
|
}
|
||||||
let description = "";
|
let description = "";
|
||||||
|
let update: (diff: number) => void;
|
||||||
|
let onComplete: VoidFunction;
|
||||||
|
let link: ComputedRef<BoardNode>;
|
||||||
switch (treasureType) {
|
switch (treasureType) {
|
||||||
case "dirtGeneration":
|
case "dirtGeneration":
|
||||||
description = `Gain ${format(difficulty)} dirt/s while plane is active`;
|
description = `Gain ${format(difficulty)} dirt/s while plane is active`;
|
||||||
|
update = diff => main.grantResource("dirt", Decimal.times(diff, difficulty));
|
||||||
|
link = computed(() => main.resourceNodes.value["dirt"]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const cost = Decimal.times(difficulty, random() + 0.5)
|
const cost = Decimal.times(difficulty, random() + 0.5)
|
||||||
|
@ -228,7 +234,10 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
style: "width: 100%",
|
style: "width: 100%",
|
||||||
classes: {
|
classes: {
|
||||||
final: i === length - 1
|
final: i === length - 1
|
||||||
}
|
},
|
||||||
|
update,
|
||||||
|
onComplete,
|
||||||
|
link
|
||||||
})) as GenericAchievement;
|
})) as GenericAchievement;
|
||||||
features.push([milestone]);
|
features.push([milestone]);
|
||||||
visibility = milestone.earned;
|
visibility = milestone.earned;
|
||||||
|
@ -256,6 +265,15 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
|
|
||||||
this.on("preUpdate", diff => {
|
this.on("preUpdate", diff => {
|
||||||
resource.value = Decimal.times(computedResourceGain.value, diff).add(resource.value);
|
resource.value = Decimal.times(computedResourceGain.value, diff).add(resource.value);
|
||||||
|
|
||||||
|
for (let i = 1; i < features.length; i += 2) {
|
||||||
|
const treasure = features[i][0] as GenericAchievement & {
|
||||||
|
update?: (diff: number) => void;
|
||||||
|
};
|
||||||
|
if (treasure.earned.value) {
|
||||||
|
treasure.update?.(diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourceChange = computed(() => {
|
const resourceChange = computed(() => {
|
||||||
|
@ -286,6 +304,19 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
resourceProductionChange
|
resourceProductionChange
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const links = computed(() => {
|
||||||
|
const links = [];
|
||||||
|
for (let i = 1; i < features.length; i += 2) {
|
||||||
|
const treasure = features[i][0] as GenericAchievement & {
|
||||||
|
link?: ComputedRef<BoardNode>;
|
||||||
|
};
|
||||||
|
if (treasure.earned.value && treasure.link) {
|
||||||
|
links.push(treasure.link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return links;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tier: persistent(tier),
|
tier: persistent(tier),
|
||||||
seed: persistent(seed),
|
seed: persistent(seed),
|
||||||
|
@ -299,6 +330,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
},
|
},
|
||||||
features,
|
features,
|
||||||
resourceTabCollapsed,
|
resourceTabCollapsed,
|
||||||
|
links,
|
||||||
display: jsx(() => (
|
display: jsx(() => (
|
||||||
<>
|
<>
|
||||||
<StickyVue class="nav-container">
|
<StickyVue class="nav-container">
|
||||||
|
|
|
@ -1105,8 +1105,22 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
stroke: "var(--foreground)",
|
stroke: "var(--foreground)",
|
||||||
strokeWidth: 4
|
strokeWidth: 4
|
||||||
});
|
});
|
||||||
|
// TODO link to influences
|
||||||
}
|
}
|
||||||
// TODO link to influences
|
links.push(
|
||||||
|
...activePortals.value
|
||||||
|
.map(node =>
|
||||||
|
(
|
||||||
|
layers[(node.state as unknown as PortalState).id] as GenericPlane
|
||||||
|
).links.value.map(n => ({
|
||||||
|
startNode: node,
|
||||||
|
endNode: n.value,
|
||||||
|
stroke: "var(--accent3)",
|
||||||
|
strokeWidth: 4
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
.reduce((a, b) => [...a, ...b], [])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
@ -1507,6 +1521,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
||||||
passives,
|
passives,
|
||||||
resourceNodes,
|
resourceNodes,
|
||||||
toolNodes,
|
toolNodes,
|
||||||
|
grantResource,
|
||||||
display: jsx(() => (
|
display: jsx(() => (
|
||||||
<>
|
<>
|
||||||
<StickyVue class="nav-container">
|
<StickyVue class="nav-container">
|
||||||
|
|
Loading…
Add table
Reference in a new issue