UNPKG

endfield-mcp

Version:

MCP Server for Arknights: Endfield (TypeScript / stdio + Streamable HTTP)

94 lines • 3.51 kB
/** * Worldview category listing — the browse entry points. * * Exposes the two top-level trees of the worldview domain: * - PRTS archive categories (collection/document/media/...) and their * first-level groups (the unit a player opens to read documents) * - In-game wiki categories and the groups under each * * Both trees are eager-loaded and cached in `worldviewCore`; this module * just shapes them for tool consumption (resolving display names through * i18n). Depends on `./worldviewCore.js` for the catalog loaders and * `./texts.js` for name resolution. */ import { resolveText } from "./texts.js"; import { firstLvGroups, prtsCategories, wikiCategories, wikiGroups, } from "./worldviewCore.js"; /** * List the PRTS archive's top-level categories. * * Each category is annotated with how many first-level groups it contains, * so a caller can see the browse depth without a second round-trip. */ export function listLoreCategories() { const groups = firstLvGroups(); const countByCat = new Map(); for (const g of groups) { countByCat.set(g.categoryId, (countByCat.get(g.categoryId) ?? 0) + 1); } return prtsCategories().map((c) => ({ categoryId: c.categoryId, displayName: resolveText(c.name, undefined, c.categoryId), order: c.order, groupCount: countByCat.get(c.categoryId) ?? 0, })); } /** * List first-level groups within a PRTS category. * * Returns an empty array if the category id is unknown. */ export function listLoreGroups(categoryId) { const lower = categoryId.toLowerCase(); return firstLvGroups() .filter((g) => g.categoryId.toLowerCase() === lower) .map((g) => ({ firstLvId: g.firstLvId, categoryId: g.categoryId, displayName: resolveText(g.name, undefined, g.firstLvId), subtitle: resolveText(g.subName), order: g.order, itemCount: g.itemIds.length, })); } /** * List the in-game wiki's top-level categories. */ export function listWikiCategories() { const groups = wikiGroups(); return wikiCategories().map((c) => ({ categoryId: c.categoryId, displayName: resolveText(c.categoryName, undefined, c.categoryId), priority: c.categoryPriority, groupCount: groups.get(c.categoryId)?.length ?? 0, })); } /** * List wiki groups within a category. * * Returns an empty array if the category id is unknown. Matching is * case-insensitive, but the returned `categoryId` is always the canonical * casing from the data (the actual map key), so callers see a stable value * regardless of how they cased their input. */ export function listWikiGroups(categoryId) { const groups = wikiGroups(); // Find the canonical key with a case-insensitive scan (wikiGroups keys are // stored verbatim, e.g. "wiki_type_monster"). This avoids returning two // different casings depending on which branch resolved. let canonicalKey = null; for (const key of groups.keys()) { if (key.toLowerCase() === categoryId.toLowerCase()) { canonicalKey = key; break; } } const list = canonicalKey !== null ? groups.get(canonicalKey) : undefined; if (!list || canonicalKey === null) return []; return list.map((g) => ({ groupId: g.groupId, categoryId: canonicalKey, displayName: resolveText(g.groupName, undefined, g.groupId), })); } //# sourceMappingURL=worldviewCategories.js.map