fix : use correct icon for % stats

This commit is contained in:
2026-09-17 17:53:26 +07:00 Unverified
parent d5f067627b
commit a0574c987c
7 changed files with 17 additions and 5 deletions
+1
View File
@@ -39,6 +39,7 @@ function statLabel(key: string): string {
function statIconName(key: string): string | null {
const normalized = key.toLowerCase().replace(/[^a-z]/gu, "");
if (key.includes("%") && ["hp", "atk", "def"].includes(normalized)) return `${normalized}-percent`;
if (["hp", "atk", "def", "em", "er"].includes(normalized)) return normalized;
if (["critrate", "crit", "criticalrate"].includes(normalized)) return "critrate";
if (["critdmg", "critdamage", "criticaldamage"].includes(normalized)) return "critdmg";
+7
View File
@@ -323,6 +323,13 @@
"when": 1789637567192,
"tag": "0045_simple_argent",
"breakpoints": true
},
{
"idx": 46,
"version": "7",
"when": 1789641217244,
"tag": "0046_spicy_lucky_pierre",
"breakpoints": true
}
]
}
+7 -4
View File
@@ -104,12 +104,15 @@ describe("structured guide validation", () => {
expect(artifactSectionSchema.safeParse({ ...base, recommendedGroups: [{ ...first, note: "x".repeat(2_001) }] }).success).toBe(false);
});
it("accepts flat artifact substats with the same icons as their percentage variants", () => {
it("uses distinct icons for flat and percentage HP, ATK, and DEF stats", () => {
const result = artifactSectionSchema.safeParse({ expectedVersion: 1, groups: artifactGroups, sands: [], goblet: [], circlet: [], substats: ["ATK", "HP", "DEF"], targetGroups: [], talents: [], note: null });
expect(result.success).toBe(true);
expect(targetStatIconName("ATK")).toBe(recommendedStatIconName("ATK%"));
expect(targetStatIconName("HP")).toBe(recommendedStatIconName("HP%"));
expect(targetStatIconName("DEF")).toBe(recommendedStatIconName("DEF%"));
expect(recommendedStatIconName("ATK%")).toBe("atk-percent");
expect(recommendedStatIconName("HP%")).toBe("hp-percent");
expect(recommendedStatIconName("DEF%")).toBe("def-percent");
expect(targetStatIconName("ATK")).toBe("atk");
expect(targetStatIconName("HP")).toBe("hp");
expect(targetStatIconName("DEF")).toBe("def");
});
it("maps elemental damage recommendations to Lunaris element icons", () => {
+1
View File
@@ -48,6 +48,7 @@ export function recommendedStatIconName(value: string): string | null {
if (value.endsWith(" DMG%")) return "elemental-bonus";
const base = value.replace(/%$/, "").toLowerCase();
if (value.endsWith("%") && ["hp", "atk", "def"].includes(base)) return `${base}-percent`;
return ["hp", "atk", "def", "em", "er"].includes(base) ? base : null;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B