From ac47d45d70ebb4e4d00a0b9515ba25ecfaf82946 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 24 Dec 2022 03:56:26 -0800 Subject: [PATCH] Added Ultima display to WeaponUnit --- components/WeaponUnit/index.tsx | 61 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx index 84598500..51fd7c52 100644 --- a/components/WeaponUnit/index.tsx +++ b/components/WeaponUnit/index.tsx @@ -119,7 +119,8 @@ const WeaponUnit = (props: Props) => { return ( {`${altText}`} @@ -127,6 +128,59 @@ const WeaponUnit = (props: Props) => { } } + function ultimaImage(index: number) { + const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` + let filename = '' + let altText = '' + + // If there is a grid weapon, it is a Dark Opus Weapon and it has keys + if ( + props.gridWeapon && + props.gridWeapon.object.series === 17 && + props.gridWeapon.weapon_keys + ) { + if ( + props.gridWeapon.weapon_keys[index] && + (props.gridWeapon.weapon_keys[index].slot === 1 || + props.gridWeapon.weapon_keys[index].slot === 2) + ) { + altText = `${props.gridWeapon.weapon_keys[index].name[locale]}` + filename = `${props.gridWeapon.weapon_keys[index].slug}.png` + } else if ( + props.gridWeapon.weapon_keys[index] && + props.gridWeapon.weapon_keys[index].slot === 0 + ) { + altText = `${props.gridWeapon.weapon_keys[index].name[locale]}` + + const weapon = props.gridWeapon.object.proficiency + + const suffix = `${weapon}` + filename = `${props.gridWeapon.weapon_keys[index].slug}-${suffix}.png` + } + } + + return ( + {`${altText}`} + ) + } + + function ultimaImages() { + let images: JSX.Element[] = [] + if ( + props.gridWeapon && + props.gridWeapon.object.series === 17 && + props.gridWeapon.weapon_keys && + props.gridWeapon.weapon_keys.length > 0 + ) { + for (let i = 0; i < props.gridWeapon.weapon_keys.length; i++) { + const image = ultimaImage(i) + if (image) images.push(image) + } + } + + return images + } + function opusImage(index: number) { const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` let filename = '' @@ -176,7 +230,8 @@ const WeaponUnit = (props: Props) => { return ( {`${altText}`} @@ -188,6 +243,7 @@ const WeaponUnit = (props: Props) => { let images: JSX.Element[] = [] if ( props.gridWeapon && + props.gridWeapon.object.series === 2 && props.gridWeapon.weapon_keys && props.gridWeapon.weapon_keys.length > 0 ) { @@ -268,6 +324,7 @@ const WeaponUnit = (props: Props) => { {telumaImage(0)} {telumaImage(1)} {opusImages()} + {ultimaImages()} {weapon?.name.en}