diff --git a/src/lib/server/constants/skills.ts b/src/lib/server/constants/skills.ts index 99263c8b..83bcb2fc 100644 --- a/src/lib/server/constants/skills.ts +++ b/src/lib/server/constants/skills.ts @@ -228,7 +228,7 @@ export const SKILL_ICONS = { carpentry: "/api/item/CRAFTING_TABLE", social: "/api/item/EMERALD", dungeoneering: "/api/head/964e1c3e315c8d8fffc37985b6681c5bd16a6f97ffd07199e8a05efbef103793", - healer: "/api/potion/normal/10", + healer: "/api/potion/normal/2", mage: "/api/item/BLAZE_ROD", archer: "/api/item/BOW", berserk: "/api/item/IRON_SWORD", diff --git a/src/lib/shared/constants/items.ts b/src/lib/shared/constants/items.ts index 091ede8f..baf53584 100644 --- a/src/lib/shared/constants/items.ts +++ b/src/lib/shared/constants/items.ts @@ -35,7 +35,7 @@ export const POTION_COLORS = { 13: "2f549c", // Water Breathing 14: "818595", // Invisibility 15: "f500f5" // Uncraftable -}; +} as Record; export const TYPE_TO_CATEGORIES = { helmet: ["armor", "helmet"], diff --git a/src/params/potionColor.ts b/src/params/potionColor.ts new file mode 100644 index 00000000..60ca1eed --- /dev/null +++ b/src/params/potionColor.ts @@ -0,0 +1,7 @@ +import type { ParamMatcher } from "@sveltejs/kit"; + +export const isPotionColor = ((param) => { + return typeof param === "string" && parseInt(param) >= 0 && parseInt(param) <= 15; +}) satisfies ParamMatcher; + +export const match = isPotionColor; diff --git a/src/routes/api/potion/[type=potion]/[color=color]/+server.ts b/src/routes/api/potion/[type=potion]/[color=potionColor]/+server.ts similarity index 73% rename from src/routes/api/potion/[type=potion]/[color=color]/+server.ts rename to src/routes/api/potion/[type=potion]/[color=potionColor]/+server.ts index 569f9bd5..8bb7c4dc 100644 --- a/src/routes/api/potion/[type=potion]/[color=color]/+server.ts +++ b/src/routes/api/potion/[type=potion]/[color=potionColor]/+server.ts @@ -1,12 +1,15 @@ +import { POTION_COLORS } from "$constants/constants"; import { getPotion } from "$lib/renderer"; -import type { RequestHandler } from "./$types"; import { error } from "@sveltejs/kit"; +import type { RequestHandler } from "./$types"; export const GET: RequestHandler = async ({ params }) => { const { type, color } = params; + const potionColor = POTION_COLORS[color]; + try { - const attachment = await getPotion(type, color); + const attachment = await getPotion(type, potionColor); return new Response(attachment, { headers: { "Content-Type": "image/png" } }); } catch (errorMsg) {