Exact source used by this build. SHA-256: 9f97820692c69a49f1451daaddd385366221ddcf9d504cb6b2e0a9444d443729.

1 import json from "../../../data/tools/tools.json";
2 import { ITEMS } from "../items";
3 import { ToolsSchema } from "./schema";
4 import type { ContentDomain } from "../types";
5 
6 export * from "./schema";
7 export const TOOLS = ToolsSchema.parse(json);
8 export function validateTools(input: unknown, itemIds: ReadonlySet<string>): void {
9   const data = ToolsSchema.parse(input);
10   if (new Set(data.tools.map((tool) => tool.id)).size !== data.tools.length) throw new Error("Tool ids must be unique");
11   for (const tool of data.tools) for (const [index, tier] of tool.tiers.entries()) {
12     if (index !== tier.tier) throw new Error(`Tool ${tool.id} tiers must be in order`);
13     if (tier.barId && !itemIds.has(tier.barId)) throw new Error(`Unknown upgrade item ${tier.barId}`);
14   }
15   const debris = new Set(data.debris.map((entry) => entry.id));
16   if (debris.size !== data.debris.length) throw new Error("Debris ids must be unique");
17   for (const entry of data.debris) for (const drop of entry.drops) if (!itemIds.has(drop.id)) throw new Error(`Unknown debris item ${drop.id}`);
18   const placements = new Set<string>();
19   for (const placement of data.placements) {
20     if (placements.has(placement.id)) throw new Error("Debris placement ids must be unique");
21     placements.add(placement.id);
22     if (!debris.has(placement.kind)) throw new Error(`Unknown debris kind ${placement.kind}`);
23   }
24 }
25 export const toolsDomain: ContentDomain = { id: "tools", data: TOOLS, validate() { validateTools(json, new Set(ITEMS.map((item) => item.id))); } };
26 toolsDomain.validate();
27