fix: translate internal element name correctly before using in props

This commit is contained in:
2026-03-20 13:04:45 +07:00 Unverified
parent 9d2ea8ba91
commit f8fe13ec2d
+6 -9
View File
@@ -1,4 +1,4 @@
import { ResolvedAvatarInfo } from "enka.ts"; import { AvatarElement, ResolvedAvatarInfo } from "enka.ts";
import { EnkaLocs } from "@/type/enka"; import { EnkaLocs } from "@/type/enka";
import { FightPropMapEnum, PercentageFightProp } from "@/type/fightPropMap"; import { FightPropMapEnum, PercentageFightProp } from "@/type/fightPropMap";
@@ -38,13 +38,7 @@ const DEFAULT_WHITELIST: (keyof typeof FightPropMapEnum)[] = [
"FIGHT_PROP_CRITICAL", "FIGHT_PROP_CRITICAL",
"FIGHT_PROP_CRITICAL_HURT", "FIGHT_PROP_CRITICAL_HURT",
"FIGHT_PROP_CHARGE_EFFICIENCY", "FIGHT_PROP_CHARGE_EFFICIENCY",
"FIGHT_PROP_FIRE_ADD_HURT", "FIGHT_PROP_PHYSICAL_ADD_HURT",
"FIGHT_PROP_ELEC_ADD_HURT",
"FIGHT_PROP_WATER_ADD_HURT",
"FIGHT_PROP_GRASS_ADD_HURT",
"FIGHT_PROP_WIND_ADD_HURT",
"FIGHT_PROP_ROCK_ADD_HURT",
"FIGHT_PROP_ICE_ADD_HURT",
]; ];
const ELEMENT_TO_PROP: Record<string, string> = { const ELEMENT_TO_PROP: Record<string, string> = {
@@ -145,7 +139,10 @@ export function buildDisplayRows(
const showAll = !!opts.showAll; const showAll = !!opts.showAll;
// element bonus key // element bonus key
const element = (apiPayload.avatar?.element || "").toUpperCase(); const elementEnka = apiPayload.avatar?.element || "";
const element = (
Object.entries(AvatarElement).find((e) => elementEnka === e[1])?.[0] || ""
).toUpperCase();
const elemPrefix = ELEMENT_TO_PROP[element] || null; const elemPrefix = ELEMENT_TO_PROP[element] || null;
const elementBonusKey = elemPrefix const elementBonusKey = elemPrefix
? (`FIGHT_PROP_${elemPrefix}_ADD_HURT` as keyof typeof FightPropMapEnum) ? (`FIGHT_PROP_${elemPrefix}_ADD_HURT` as keyof typeof FightPropMapEnum)