|
1 | 1 | <script lang="ts"> |
2 | 2 | import { t } from "@transifex/native"; |
3 | | -import type { CBNData } from "src/data"; |
4 | 3 | import type { ActivityDataCommon } from "src/types"; |
5 | | -import { getContext } from "svelte"; |
6 | 4 | import ThingLink from "./ThingLink.svelte"; |
| 5 | +import { untrack } from "svelte"; |
7 | 6 |
|
8 | 7 | interface Props { |
9 | | - act: ActivityDataCommon & { result?: string }; |
| 8 | + act: ActivityDataCommon; |
10 | 9 | resultType: "terrain" | "furniture"; |
11 | 10 | } |
12 | 11 |
|
13 | 12 | let { act, resultType }: Props = $props(); |
14 | 13 |
|
15 | | -const data = getContext<CBNData>("data"); |
| 14 | +function visibleResult( |
| 15 | + value: ActivityDataCommon, |
| 16 | + resultType: "terrain" | "furniture", |
| 17 | +): string | undefined { |
| 18 | + if (value.result === (resultType === "terrain" ? "t_null" : "f_null")) { |
| 19 | + return undefined; |
| 20 | + } |
| 21 | + return value.result; |
| 22 | +} |
| 23 | +
|
| 24 | +const activity = untrack(() => act); |
| 25 | +const result = untrack(() => visibleResult(act, resultType)); |
16 | 26 |
|
17 | 27 | const _context = "Terrain / Furniture"; |
18 | | -const _comment = "activity (prying, hacksawing, etc.)"; |
| 28 | +const _comment = "activity (oxytorch, hacksaw, boltcut, etc.)"; |
19 | 29 | </script> |
20 | 30 |
|
21 | | -<ul class="comma-separated"> |
22 | | - {#each act.byproducts ?? [] as { item: i, count }} |
23 | | - <li> |
24 | | - <ThingLink |
25 | | - id={i} |
26 | | - type="item" |
27 | | - showIcon={false} />{#if typeof count === "number"} ({count}){:else if Array.isArray(count)} ({count[0]}–{count[1]}){/if} |
28 | | - </li> |
29 | | - {/each} |
30 | | -</ul> |
31 | 31 | <dl> |
32 | 32 | <dt>{t("Duration", { _context, _comment })}</dt> |
33 | | - <dd>{act.duration ?? "1 s"}</dd> |
34 | | - {#if act.prying_data} |
35 | | - <dt>{t("Difficulty", { _context, _comment })}</dt> |
36 | | - <dd>{act.prying_data.difficulty ?? 0}</dd> |
37 | | - <dt>{t("Requires", { _context, _comment })}</dt> |
| 33 | + <dd>{activity.duration ?? "1 s"}</dd> |
| 34 | + {#if result} |
| 35 | + <dt>{t("Becomes", { _context, _comment })}</dt> |
38 | 36 | <dd> |
39 | | - <ThingLink id="PRY" type="tool_quality" showIcon={false} /> |
40 | | - {act.prying_data.prying_level ?? 0}{#if act.prying_data.prying_nails}, <ThingLink |
41 | | - id="PRYING_NAIL" |
42 | | - type="tool_quality" |
43 | | - showIcon={false} /> 1{/if} |
| 37 | + <ThingLink id={result} type={resultType} showIcon={false} /> |
44 | 38 | </dd> |
45 | | - <dt>{t("Noisy", { _context, _comment })}</dt> |
46 | | - <dd>{act.prying_data.noisy ? t("Yes") : t("No")}</dd> |
47 | | - <dt>{t("Alarm", { _context, _comment })}</dt> |
48 | | - <dd>{act.prying_data.alarm ? t("Yes") : t("No")}</dd> |
49 | | - <dt>{t("Breakable", { _context, _comment })}</dt> |
50 | | - <dd>{act.prying_data.breakable ? t("Yes") : t("No")}</dd> |
51 | 39 | {/if} |
52 | | - {#if act.result && act.result !== "t_null"} |
53 | | - <dt>{t("Result", { _context, _comment })}</dt> |
| 40 | + {#if activity.byproducts} |
| 41 | + <dt>{t("Byproducts", { _context, _comment })}</dt> |
54 | 42 | <dd> |
55 | | - <ThingLink id={act.result} type={resultType} /> |
| 43 | + <ul class="comma-separated"> |
| 44 | + {#each activity.byproducts ?? [] as { item: i, count }} |
| 45 | + <li> |
| 46 | + <ThingLink id={i} type="item" showIcon={false} {count} /> |
| 47 | + </li> |
| 48 | + {/each} |
| 49 | + </ul> |
56 | 50 | </dd> |
57 | 51 | {/if} |
58 | 52 | </dl> |
0 commit comments