MCPcopy Create free account
hub / github.com/dailydotdev/apps / resolveTarget

Function resolveTarget

packages/world-cli/bin/world.js:88–122  ·  view source on GitHub ↗

Resolve which district and family we are authoring for, against the real world.

(handle, { district, family })

Source from the content-addressed store, hash-verified

86
87/** Resolve which district and family we are authoring for, against the real world. */
88async function resolveTarget(handle, { district, family }) {
89 const { user, districts } = await fetchWorld(handle, { api: DEFAULT_API });
90 if (!districts.length) {
91 die(
92 `${user.name}'s world is empty or private. A private world returns nothing to an anonymous reader, which is what this is.`
93 );
94 }
95 const target = district
96 ? districts.find((d) => d.niche === district)
97 : districts[0];
98 if (!target) {
99 die(
100 `No district "${district}" in this world. Try one of: ${districts
101 .slice(0, 12)
102 .map((d) => d.niche)
103 .join(", ")}`
104 );
105 }
106 const realm = realmOf(target.niche);
107 if (!realm) die(`"${target.niche}" is not a district the renderer knows.`);
108
109 const open = unlockedFamilies(target.level);
110 const fam =
111 family ?? (open.includes("house") ? "house" : open[open.length - 1]);
112 if (!FAMILY_KINDS.includes(fam))
113 die(`Unknown family "${fam}". Available: ${FAMILY_KINDS.join(", ")}`);
114 if (!open.includes(fam)) {
115 die(
116 `"${fam}" is not unlocked in ${target.niche} at level ${
117 target.level
118 }. Unlocked here: ${open.join(", ")}`
119 );
120 }
121 return { user, realm, ...target, family: fam, districts };
122}
123
124async function builderSource(realm, family) {
125 /* Filled in with the REALM's own material names. A starting file that says

Callers 2

resolveRealmTargetFunction · 0.85
runCheckFunction · 0.85

Calls 4

fetchWorldFunction · 0.90
realmOfFunction · 0.90
unlockedFamiliesFunction · 0.90
dieFunction · 0.85

Tested by

no test coverage detected