From e785771b15128b8405c2c2bd54fb03819933e4cd Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 30 Dec 2023 07:27:07 -0800 Subject: [PATCH] Show key images in hovercard --- .../weapon/WeaponHovercard/index.module.scss | 18 ++- components/weapon/WeaponHovercard/index.tsx | 130 +++++++++++++++--- 2 files changed, 131 insertions(+), 17 deletions(-) diff --git a/components/weapon/WeaponHovercard/index.module.scss b/components/weapon/WeaponHovercard/index.module.scss index af652470..e6f8fef9 100644 --- a/components/weapon/WeaponHovercard/index.module.scss +++ b/components/weapon/WeaponHovercard/index.module.scss @@ -66,6 +66,22 @@ display: flex; flex-direction: column; font-size: $normal; - gap: $unit-half; + gap: $unit; + + .weaponKey { + align-items: center; + display: flex; + flex-direction: row; + gap: $unit; + + .icon img { + width: $unit-3x; + height: $unit-3x; + } + + span { + font-weight: $medium; + } + } } } diff --git a/components/weapon/WeaponHovercard/index.tsx b/components/weapon/WeaponHovercard/index.tsx index fb1c8ddd..177a76b4 100644 --- a/components/weapon/WeaponHovercard/index.tsx +++ b/components/weapon/WeaponHovercard/index.tsx @@ -54,6 +54,10 @@ const WeaponHovercard = (props: Props) => { en: 'Emblem', ja: 'エンブレム', }, + '34': { + en: 'Teluma', + ja: 'テルマ', + }, } const tintElement = @@ -75,6 +79,100 @@ const WeaponHovercard = (props: Props) => { else return 'bottom' } + function telumaImage(index: number) { + const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` + + // If there is a grid weapon, it is a Draconic Weapon and it has keys + if ( + (props.gridWeapon.object.series === 3 || + props.gridWeapon.object.series == 34) && + props.gridWeapon.weapon_keys + ) { + const weaponKey = props.gridWeapon.weapon_keys[index] + const altText = weaponKey.name[locale] + let filename = `${weaponKey.slug}` + + if ( + index === 1 || + (index === 2 && parseInt(weaponKey.granblue_id) === 15008) + ) { + filename += `-${props.gridWeapon.object.element}` + } + + return ( + {altText} + ) + } + } + + function opusImage(index: number) { + const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` + + // If there is a grid weapon, it is a Dark Opus Weapon and it has keys + if (props.gridWeapon.object.series === 2 && props.gridWeapon.weapon_keys) { + const weaponKey = props.gridWeapon.weapon_keys[index] + const altText = weaponKey.name[locale] + let filename = weaponKey.slug + + if (weaponKey.slot === 1) { + const element = props.gridWeapon.object.element + const mod = props.gridWeapon.object.name.en.includes('Repudiation') + ? 'primal' + : 'magna' + const suffixes = [ + 'pendulum-strength', + 'pendulum-zeal', + 'pendulum-strife', + 'chain-temperament', + 'chain-restoration', + 'chain-glorification', + ] + + if (suffixes.includes(weaponKey.slug)) { + filename += `-${mod}-${element}` + } + } + + return ( + {altText} + ) + } + } + + function ultimaImage(index: number) { + const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` + + // If there is a grid weapon, it is a Dark Opus Weapon and it has keys + if (props.gridWeapon.object.series === 17 && props.gridWeapon.weapon_keys) { + const weaponKey = props.gridWeapon.weapon_keys[index] + const altText = weaponKey.name[locale] + let filename = weaponKey.slug + + if (weaponKey.slot === 0) { + filename += `-${props.gridWeapon.object.proficiency}` + } + + return ( + {altText} + ) + } + } + const createPrimaryAxSkillString = () => { const primaryAxSkills = ax[props.gridWeapon.object.ax_type - 1] @@ -135,27 +233,27 @@ const WeaponHovercard = (props: Props) => { const keysSection = (
- {WeaponKeyNames[props.gridWeapon.object.series] ? ( + {WeaponKeyNames[props.gridWeapon.object.series] && (
{WeaponKeyNames[props.gridWeapon.object.series][locale]} - {locale === 'en' ? 's' : ''} + {locale === 'en' && 's'}
- ) : ( - '' )} - {props.gridWeapon.weapon_keys - ? Array.from(Array(props.gridWeapon.weapon_keys.length)).map((x, i) => { - return ( -
- {props.gridWeapon.weapon_keys![i].name[locale]} -
- ) - }) - : ''} + {props.gridWeapon.weapon_keys?.map((weaponKey, i) => ( +
+ {[3, 34].includes(props.gridWeapon.object.series) && ( + {telumaImage(i)} + )} + {props.gridWeapon.object.series === 17 && ( + {ultimaImage(i)} + )} + {props.gridWeapon.object.series === 2 && ( + {opusImage(i)} + )} + {weaponKey.name[locale]} +
+ ))}
)