From 9de50b525e7a59e8998df1cc9c24c583baac372b Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 16 Sep 2023 11:33:22 +0300 Subject: [PATCH] Fix Hero Shot link 404 Closes #1477 --- app/components/BuildCard.tsx | 6 +++++- app/modules/in-game-lists/weapon-ids.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/BuildCard.tsx b/app/components/BuildCard.tsx index 9defbb9b0..d18e39c59 100644 --- a/app/components/BuildCard.tsx +++ b/app/components/BuildCard.tsx @@ -36,6 +36,7 @@ import { Popover } from "./Popover"; import { InfoIcon } from "./icons/Info"; import { LockIcon } from "./icons/Lock"; import type { BuildWeaponWithTop500Info } from "~/features/builds"; +import { altWeaponIdToId } from "~/modules/in-game-lists/weapon-ids"; interface BuildProps { build: Pick< @@ -231,9 +232,12 @@ export function BuildCard({ build, owner, canEdit = false }: BuildProps) { function RoundWeaponImage({ weapon }: { weapon: BuildWeaponWithTop500Info }) { const { weaponSplId, maxPower, minRank } = weapon; + const normalizedWeaponSplId = altWeaponIdToId.get(weaponSplId) ?? weaponSplId; const { t } = useTranslation(["weapons"]); - const slug = mySlugify(t(`weapons:MAIN_${weaponSplId}`, { lng: "en" })); + const slug = mySlugify( + t(`weapons:MAIN_${normalizedWeaponSplId}`, { lng: "en" }), + ); const isTop500 = typeof maxPower === "number" && typeof minRank === "number"; diff --git a/app/modules/in-game-lists/weapon-ids.ts b/app/modules/in-game-lists/weapon-ids.ts index 96ebed604..79d53231a 100644 --- a/app/modules/in-game-lists/weapon-ids.ts +++ b/app/modules/in-game-lists/weapon-ids.ts @@ -58,6 +58,7 @@ export const mainWeaponIds = weaponCategories .sort((a, b) => a - b); export const weaponIdToAltId = new Map([[40, 45]]); +export const altWeaponIdToId = new Map([[45, 40]]); const altWeaponIds = new Set(weaponIdToAltId.values()); export const weaponIdIsNotAlt = (weaponId: MainWeaponId) =>