fix : use correct icon for % stats
This commit is contained in:
@@ -39,6 +39,7 @@ function statLabel(key: string): string {
|
|||||||
|
|
||||||
function statIconName(key: string): string | null {
|
function statIconName(key: string): string | null {
|
||||||
const normalized = key.toLowerCase().replace(/[^a-z]/gu, "");
|
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 (["hp", "atk", "def", "em", "er"].includes(normalized)) return normalized;
|
||||||
if (["critrate", "crit", "criticalrate"].includes(normalized)) return "critrate";
|
if (["critrate", "crit", "criticalrate"].includes(normalized)) return "critrate";
|
||||||
if (["critdmg", "critdamage", "criticaldamage"].includes(normalized)) return "critdmg";
|
if (["critdmg", "critdamage", "criticaldamage"].includes(normalized)) return "critdmg";
|
||||||
|
|||||||
@@ -323,6 +323,13 @@
|
|||||||
"when": 1789637567192,
|
"when": 1789637567192,
|
||||||
"tag": "0045_simple_argent",
|
"tag": "0045_simple_argent",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 46,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1789641217244,
|
||||||
|
"tag": "0046_spicy_lucky_pierre",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -104,12 +104,15 @@ describe("structured guide validation", () => {
|
|||||||
expect(artifactSectionSchema.safeParse({ ...base, recommendedGroups: [{ ...first, note: "x".repeat(2_001) }] }).success).toBe(false);
|
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 });
|
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(result.success).toBe(true);
|
||||||
expect(targetStatIconName("ATK")).toBe(recommendedStatIconName("ATK%"));
|
expect(recommendedStatIconName("ATK%")).toBe("atk-percent");
|
||||||
expect(targetStatIconName("HP")).toBe(recommendedStatIconName("HP%"));
|
expect(recommendedStatIconName("HP%")).toBe("hp-percent");
|
||||||
expect(targetStatIconName("DEF")).toBe(recommendedStatIconName("DEF%"));
|
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", () => {
|
it("maps elemental damage recommendations to Lunaris element icons", () => {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export function recommendedStatIconName(value: string): string | null {
|
|||||||
if (value.endsWith(" DMG%")) return "elemental-bonus";
|
if (value.endsWith(" DMG%")) return "elemental-bonus";
|
||||||
|
|
||||||
const base = value.replace(/%$/, "").toLowerCase();
|
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;
|
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 |
Reference in New Issue
Block a user