mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-22 00:21:31 +00:00
Show number of treasures on minimized planes
Also simplified earned treasures
This commit is contained in:
parent
89a1737283
commit
189cac6942
1 changed files with 39 additions and 27 deletions
|
@ -28,6 +28,13 @@ import { GenericAchievement, createAchievement } from "features/achievements/ach
|
||||||
import { Computable } from "util/computed";
|
import { Computable } from "util/computed";
|
||||||
import { BoardNode } from "features/boards/board";
|
import { BoardNode } from "features/boards/board";
|
||||||
|
|
||||||
|
export type Treasure = GenericAchievement & {
|
||||||
|
update?: (diff: number) => void;
|
||||||
|
link?: ComputedRef<BoardNode>;
|
||||||
|
effectedResource?: Resources | "energy";
|
||||||
|
resourceMulti: DecimalSource;
|
||||||
|
};
|
||||||
|
|
||||||
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) {
|
||||||
const random = sfc32(0, seed >> 0, seed >> 32, 1);
|
const random = sfc32(0, seed >> 0, seed >> 32, 1);
|
||||||
|
@ -275,7 +282,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
link,
|
link,
|
||||||
effectedResource,
|
effectedResource,
|
||||||
resourceMulti
|
resourceMulti
|
||||||
})) as GenericAchievement;
|
})) satisfies Treasure as GenericAchievement;
|
||||||
const eta = estimateTime(resource, computedResourceGain, cost);
|
const eta = estimateTime(resource, computedResourceGain, cost);
|
||||||
addTooltip(milestone, {
|
addTooltip(milestone, {
|
||||||
display: () => (milestone.earned.value ? "" : eta.value),
|
display: () => (milestone.earned.value ? "" : eta.value),
|
||||||
|
@ -308,14 +315,9 @@ 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) {
|
earnedTreasures.value.forEach(treasure => {
|
||||||
const treasure = features[i][0] as GenericAchievement & {
|
treasure.update?.(diff);
|
||||||
update?: (diff: number) => void;
|
});
|
||||||
};
|
|
||||||
if (treasure.earned.value) {
|
|
||||||
treasure.update?.(diff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourceChange = computed(() => {
|
const resourceChange = computed(() => {
|
||||||
|
@ -347,30 +349,19 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const links = computed(() => {
|
const links = computed(() => {
|
||||||
const links = [];
|
const links: ComputedRef<BoardNode>[] = [];
|
||||||
for (let i = 1; i < features.length; i += 2) {
|
earnedTreasures.value.forEach(treasure => {
|
||||||
const treasure = features[i][0] as GenericAchievement & {
|
if (treasure.link) {
|
||||||
link?: ComputedRef<BoardNode>;
|
|
||||||
};
|
|
||||||
if (treasure.earned.value && treasure.link) {
|
|
||||||
links.push(treasure.link);
|
links.push(treasure.link);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return links;
|
return links;
|
||||||
});
|
});
|
||||||
|
|
||||||
const resourceMultis = computed(() => {
|
const resourceMultis = computed(() => {
|
||||||
const multis: Partial<Record<Resources | "energy", DecimalSource>> = {};
|
const multis: Partial<Record<Resources | "energy", DecimalSource>> = {};
|
||||||
for (let i = 1; i < features.length; i += 2) {
|
earnedTreasures.value.forEach(treasure => {
|
||||||
const treasure = features[i][0] as GenericAchievement & {
|
if (treasure.effectedResource != null && treasure.resourceMulti != null) {
|
||||||
effectedResource?: Resources | "energy";
|
|
||||||
resourceMulti: DecimalSource;
|
|
||||||
};
|
|
||||||
if (
|
|
||||||
treasure.earned.value &&
|
|
||||||
treasure.effectedResource != null &&
|
|
||||||
treasure.resourceMulti != null
|
|
||||||
) {
|
|
||||||
if (multis[treasure.effectedResource] != null) {
|
if (multis[treasure.effectedResource] != null) {
|
||||||
multis[treasure.effectedResource] = Decimal.times(
|
multis[treasure.effectedResource] = Decimal.times(
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
@ -381,10 +372,21 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
multis[treasure.effectedResource] = treasure.resourceMulti;
|
multis[treasure.effectedResource] = treasure.resourceMulti;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return multis;
|
return multis;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const earnedTreasures = computed(() => {
|
||||||
|
const earned: Treasure[] = [];
|
||||||
|
for (let i = 1; i < features.length; i += 2) {
|
||||||
|
const treasure = features[i][0] as Treasure;
|
||||||
|
if (treasure.earned.value) {
|
||||||
|
earned.push(treasure);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return earned;
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tier: persistent(tier),
|
tier: persistent(tier),
|
||||||
seed: persistent(seed),
|
seed: persistent(seed),
|
||||||
|
@ -400,6 +402,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
resourceTabCollapsed,
|
resourceTabCollapsed,
|
||||||
links,
|
links,
|
||||||
resourceMultis,
|
resourceMultis,
|
||||||
|
earnedTreasures,
|
||||||
display: jsx(() => (
|
display: jsx(() => (
|
||||||
<>
|
<>
|
||||||
<StickyVue class="nav-container">
|
<StickyVue class="nav-container">
|
||||||
|
@ -439,6 +442,15 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
{features.map(row => renderRow(...row))}
|
{features.map(row => renderRow(...row))}
|
||||||
{render(modifiersModal)}
|
{render(modifiersModal)}
|
||||||
</>
|
</>
|
||||||
|
)),
|
||||||
|
minimizedDisplay: jsx(() => (
|
||||||
|
<div>
|
||||||
|
<span>{name}</span>
|
||||||
|
<span style="font-size: large; vertical-align: sub;">
|
||||||
|
{" "}
|
||||||
|
{earnedTreasures.value.length}/{length} treasures
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue