fix : correct color
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { rarityGradient, rarityGradientClass, rarityTextClass, rarityTextColor } from "@/lib/catalog/rarity";
|
||||
import { characterRarityGradientClass, rarityGradient, rarityGradientClass, rarityTextClass, rarityTextColor } from "@/lib/catalog/rarity";
|
||||
|
||||
describe("catalog rarity backgrounds", () => {
|
||||
it("maps every weapon and artifact rarity to its Tailwind gradient", () => {
|
||||
expect(rarityGradientClass(1)).toContain("rgba(23,25,28,1)");
|
||||
expect(rarityGradientClass(2)).toContain("rgba(11,43,24,1)");
|
||||
expect(rarityGradientClass(1)).toBe("bg-[#697177] bg-[linear-gradient(90deg,rgba(105,113,119,1)_0%,rgba(137,144,147,1)_100%)]");
|
||||
expect(rarityGradientClass(2)).toBe("bg-[#5D8972] bg-[linear-gradient(90deg,rgba(93,137,114,1)_0%,rgba(121,167,127,1)_100%)]");
|
||||
expect(rarityGradient(1)).toBe("linear-gradient(90deg, rgba(105, 113, 119, 1) 0%, rgba(137, 144, 147, 1) 100%)");
|
||||
expect(rarityGradient(2)).toBe("linear-gradient(90deg, rgba(93, 137, 114, 1) 0%, rgba(121, 167, 127, 1) 100%)");
|
||||
expect(rarityGradientClass(3)).toBe("bg-[#4D7691] bg-[linear-gradient(90deg,rgba(77,118,145,1)_0%,rgba(71,135,165,1)_100%)]");
|
||||
expect(rarityGradientClass(4)).toBe("bg-[#6D6A9C] bg-[linear-gradient(90deg,rgba(109,106,156,1)_0%,rgba(150,122,179,1)_100%)]");
|
||||
expect(rarityGradientClass(5)).toBe("bg-[#A67B34] bg-[linear-gradient(90deg,rgba(166,123,52,1)_0%,rgba(178,123,44,1)_100%)]");
|
||||
@@ -26,4 +28,14 @@ describe("catalog rarity backgrounds", () => {
|
||||
expect(rarityTextClass(undefined)).toBeUndefined();
|
||||
expect(rarityTextColor(undefined)).toBe("#17171c");
|
||||
});
|
||||
|
||||
it("uses red for special characters without changing other rarity backgrounds", () => {
|
||||
for (const key of ["10000062", "10000117", "10000118"]) {
|
||||
expect(characterRarityGradientClass(key, 5)).toBe("bg-[#9A424E] bg-[linear-gradient(90deg,#9A424E_0%,#B85D67_100%)]");
|
||||
expect(characterRarityGradientClass(key, null)).toBe(characterRarityGradientClass(key, 5));
|
||||
}
|
||||
expect(characterRarityGradientClass("ordinary-character", 5)).toBe(rarityGradientClass(5));
|
||||
expect(characterRarityGradientClass("ordinary-character", 1)).toBe(rarityGradientClass(1));
|
||||
expect(characterRarityGradientClass("ordinary-character", 2)).toBe(rarityGradientClass(2));
|
||||
});
|
||||
});
|
||||
|
||||
+11
-4
@@ -1,14 +1,17 @@
|
||||
const rarityGradientClasses: Record<number, string> = {
|
||||
1: "bg-[linear-gradient(90deg,rgba(23,25,28,1)_0%,rgba(19,20,23,1)_100%)]",
|
||||
2: "bg-[linear-gradient(90deg,rgba(11,43,24,1)_0%,rgba(7,18,13,1)_100%)]",
|
||||
1: "bg-[#697177] bg-[linear-gradient(90deg,rgba(105,113,119,1)_0%,rgba(137,144,147,1)_100%)]",
|
||||
2: "bg-[#5D8972] bg-[linear-gradient(90deg,rgba(93,137,114,1)_0%,rgba(121,167,127,1)_100%)]",
|
||||
3: "bg-[#4D7691] bg-[linear-gradient(90deg,rgba(77,118,145,1)_0%,rgba(71,135,165,1)_100%)]",
|
||||
4: "bg-[#6D6A9C] bg-[linear-gradient(90deg,rgba(109,106,156,1)_0%,rgba(150,122,179,1)_100%)]",
|
||||
5: "bg-[#A67B34] bg-[linear-gradient(90deg,rgba(166,123,52,1)_0%,rgba(178,123,44,1)_100%)]",
|
||||
};
|
||||
|
||||
const specialCharacterKeys = new Set(["10000062", "10000117", "10000118"]);
|
||||
const specialCharacterGradientClass = "bg-[#9A424E] bg-[linear-gradient(90deg,#9A424E_0%,#B85D67_100%)]";
|
||||
|
||||
const rarityGradients: Record<number, string> = {
|
||||
1: "linear-gradient(90deg, rgba(23, 25, 28, 1) 0%, rgba(19, 20, 23, 1) 100%)",
|
||||
2: "linear-gradient(90deg, rgba(11, 43, 24, 1) 0%, rgba(7, 18, 13, 1) 100%)",
|
||||
1: "linear-gradient(90deg, rgba(105, 113, 119, 1) 0%, rgba(137, 144, 147, 1) 100%)",
|
||||
2: "linear-gradient(90deg, rgba(93, 137, 114, 1) 0%, rgba(121, 167, 127, 1) 100%)",
|
||||
3: "linear-gradient(90deg, rgba(77, 118, 145, 1) 0%, rgba(71, 135, 165, 1) 100%)",
|
||||
4: "linear-gradient(90deg, rgba(109, 106, 156, 1) 0%, rgba(150, 122, 179, 1) 100%)",
|
||||
5: "linear-gradient(90deg, rgba(166, 123, 52, 1) 0%, rgba(178, 123, 44, 1) 100%)",
|
||||
@@ -30,6 +33,10 @@ export function rarityGradientClass(rarity: number | null | undefined): string |
|
||||
return rarity ? rarityGradientClasses[rarity] : undefined;
|
||||
}
|
||||
|
||||
export function characterRarityGradientClass(key: string | null | undefined, rarity: number | null | undefined): string | undefined {
|
||||
return key && specialCharacterKeys.has(key) ? specialCharacterGradientClass : rarityGradientClass(rarity);
|
||||
}
|
||||
|
||||
export function rarityGradient(rarity: number | null | undefined): string {
|
||||
return (rarity && rarityGradients[rarity]) || "#17383d";
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ function rarity(value: string | undefined): number | null {
|
||||
QUALITY_BLUE: 3,
|
||||
QUALITY_PURPLE: 4,
|
||||
QUALITY_ORANGE: 5,
|
||||
QUALITY_ORANGE_SP: 5,
|
||||
}[value] ?? null
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as z from "zod";
|
||||
|
||||
export const lunarisVersionSchema = z.string().regex(/^\d+(?:\.\d+)+$/u);
|
||||
export const catalogFormatVersion = 2;
|
||||
export const catalogFormatVersion = 3;
|
||||
|
||||
export interface LunarisVersionChange {
|
||||
previousVersion: string;
|
||||
|
||||
Reference in New Issue
Block a user