fix: improve fuzzy handling
This commit is contained in:
@@ -55,7 +55,8 @@ export function endfieldCard(app: App) {
|
||||
params: t.Object({ uid: t.String() }),
|
||||
detail: {
|
||||
tags: ["Endfield"],
|
||||
description: "Preload data required to render an Endfield template card.",
|
||||
description:
|
||||
"Preload data required to render an Endfield template card.",
|
||||
},
|
||||
afterResponse: ({ log }) => log`Data preload complete`,
|
||||
},
|
||||
@@ -121,7 +122,8 @@ export function endfieldCard(app: App) {
|
||||
{ http: "http", card: "card" },
|
||||
{
|
||||
default: "http",
|
||||
description: "Type of error to return when card fails to render.",
|
||||
description:
|
||||
"Type of error to return when card fails to render.",
|
||||
},
|
||||
),
|
||||
debug: t.Boolean({
|
||||
@@ -134,7 +136,8 @@ export function endfieldCard(app: App) {
|
||||
),
|
||||
detail: {
|
||||
tags: ["Endfield"],
|
||||
description: "Generate a placeholder Endfield profile card image from a UID.",
|
||||
description:
|
||||
"Generate a placeholder Endfield profile card image from a UID.",
|
||||
},
|
||||
afterResponse: ({ log }) => log`Rendering completed`,
|
||||
},
|
||||
|
||||
@@ -61,7 +61,9 @@ export function EndfieldTemplate({
|
||||
<div tw="text-[1.55em] leading-[1.15] font-semibold">
|
||||
Route + Card Shell
|
||||
</div>
|
||||
<div tw="text-white/60 mt-[.35em]">Ready for game-specific layout work</div>
|
||||
<div tw="text-white/60 mt-[.35em]">
|
||||
Ready for game-specific layout work
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div tw="rounded-[1em] border border-white/10 bg-black/20 p-[1.2em]">
|
||||
@@ -71,7 +73,9 @@ export function EndfieldTemplate({
|
||||
<div tw="text-[1.55em] leading-[1.15] font-semibold">
|
||||
Character Grid
|
||||
</div>
|
||||
<div tw="text-white/60 mt-[.35em]">Replace placeholder sections with Endfield data</div>
|
||||
<div tw="text-white/60 mt-[.35em]">
|
||||
Replace placeholder sections with Endfield data
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -80,7 +84,8 @@ export function EndfieldTemplate({
|
||||
Signature
|
||||
</div>
|
||||
<div tw="text-[1.05em] leading-[1.45] text-white/82 whitespace-pre-wrap">
|
||||
{signature?.trim() || "No signature available in the fetched payload yet."}
|
||||
{signature?.trim() ||
|
||||
"No signature available in the fetched payload yet."}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mkdir, readdir, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { file, hash, write } from "bun";
|
||||
import type { ResolvedPlayerInfo} from "enka.ts";
|
||||
import type { ResolvedPlayerInfo } from "enka.ts";
|
||||
import { TTLCache } from "enka.ts";
|
||||
|
||||
import type {
|
||||
@@ -13,11 +13,9 @@ import type {
|
||||
EnkaNamecards,
|
||||
EnkaPfps,
|
||||
RelicStore,
|
||||
WeaponStore} from "@/games/genshin/types/enka";
|
||||
import {
|
||||
ElementList
|
||||
WeaponStore,
|
||||
} from "@/games/genshin/types/enka";
|
||||
|
||||
import { ElementList } from "@/games/genshin/types/enka";
|
||||
import { Deduplicator } from "@/lib/dedupe";
|
||||
import { createLogger } from "@/lib/logger";
|
||||
|
||||
@@ -210,10 +208,11 @@ export async function getEnkaStore<K extends keyof StoreTypeMap>(
|
||||
return data;
|
||||
}
|
||||
|
||||
// DEPRECATED: No longer needed
|
||||
export function getAvatar(
|
||||
store: AvatarStore,
|
||||
playerInfo: ResolvedPlayerInfo,
|
||||
id: number,
|
||||
id: string | number,
|
||||
) {
|
||||
return (
|
||||
Object.entries(store).find(
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { BaseAvatar } from "enka.ts";
|
||||
import { distance } from "fastest-levenshtein";
|
||||
|
||||
function shortAvatarId(id: number) {
|
||||
function shortAvatarId(id: string | number) {
|
||||
// 10000120 -> 120
|
||||
return String(id).replace(/^10*/, "");
|
||||
return String(id).replace(/^10*/, "").replace(/^-\d+/, "");
|
||||
}
|
||||
|
||||
function norm(s: string) {
|
||||
@@ -60,5 +60,8 @@ function fuzzyNameMatch<T extends { avatar: BaseAvatar }>(
|
||||
}
|
||||
|
||||
function avatarAliases(name: string) {
|
||||
return [name, ...name.split(" ")];
|
||||
const aliases: Record<string, string[]> = {
|
||||
Traveler: ["Aether", "Lumine"],
|
||||
};
|
||||
return [name, ...name.split(" "), ...(aliases[name] ?? [])];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ import type { ResolvedAvatarInfo } from "enka.ts";
|
||||
import { AvatarElement } from "enka.ts";
|
||||
|
||||
import type { EnkaLocsLanguage } from "@/games/genshin/types/enka";
|
||||
import { FightPropMapEnum, PercentageFightProp } from "@/games/genshin/types/fightPropMap";
|
||||
import {
|
||||
FightPropMapEnum,
|
||||
PercentageFightProp,
|
||||
} from "@/games/genshin/types/fightPropMap";
|
||||
|
||||
// Types
|
||||
interface DisplayRow {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { Affix } from "@/games/genshin/types/enka";
|
||||
import { FightPropMapEnum, PercentageFightProp } from "@/games/genshin/types/fightPropMap";
|
||||
import {
|
||||
FightPropMapEnum,
|
||||
PercentageFightProp,
|
||||
} from "@/games/genshin/types/fightPropMap";
|
||||
|
||||
export type RollSummary = {
|
||||
id: string;
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
} from "@/games/genshin/types/enka";
|
||||
import type { Logger } from "@/lib/logger";
|
||||
import { arrRandom } from "@/lib/util";
|
||||
|
||||
import { CardResponse } from "@/v1/response";
|
||||
|
||||
export async function ListPage(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { t } from "elysia";
|
||||
|
||||
export type AvatarStore = Record<number, Avatar>;
|
||||
export type AvatarStore = Record<string | number, Avatar>;
|
||||
|
||||
export interface Avatar {
|
||||
Element: ElementType;
|
||||
|
||||
Reference in New Issue
Block a user