import React from 'react' import { useRouter } from 'next/router' import { useTranslation } from 'next-i18next' import { Hovercard, HovercardContent, HovercardTrigger, } from '~components/Hovercard' import Button from '~components/Button' import WeaponLabelIcon from '~components/WeaponLabelIcon' import UncapIndicator from '~components/UncapIndicator' import { overMastery, aetherialMastery, permanentMastery, } from '~data/overMastery' import { characterAwakening } from '~data/awakening' import { ExtendedMastery } from '~types' import './index.scss' interface Props { gridCharacter: GridCharacter children: React.ReactNode onTriggerClick: () => void } interface KeyNames { [key: string]: { en: string jp: string } } const CharacterHovercard = (props: Props) => { const router = useRouter() const { t } = useTranslation('common') const locale = router.locale && ['en', 'ja'].includes(router.locale) ? router.locale : 'en' const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light'] const Proficiency = [ 'none', 'sword', 'dagger', 'axe', 'spear', 'bow', 'staff', 'fist', 'harp', 'gun', 'katana', ] const tintElement = Element[props.gridCharacter.object.element] function goTo() { const urlSafeName = props.gridCharacter.object.name.en.replaceAll(' ', '_') const url = `https://gbf.wiki/${urlSafeName}` window.open(url, '_blank') } const perpetuity = () => { if (props.gridCharacter && props.gridCharacter.perpetuity) { return } } function characterImage() { let imgSrc = '' if (props.gridCharacter) { const character = props.gridCharacter.object // Change the image based on the uncap level let suffix = '01' if (props.gridCharacter.uncap_level == 6) suffix = '04' else if (props.gridCharacter.uncap_level == 5) suffix = '03' else if (props.gridCharacter.uncap_level > 2) suffix = '02' imgSrc = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/chara-grid/${character.granblue_id}_${suffix}.jpg` } return imgSrc } function masteryElement(dictionary: ItemSkill[], mastery: ExtendedMastery) { const canonicalMastery = dictionary.find( (item) => item.id === mastery.modifier ) if (canonicalMastery) { return (
{canonicalMastery.name[locale]}
{`+${mastery.strength}${canonicalMastery.suffix}`}
) : (
''
)}
{`${awakening.name[locale]}`}
{`Lv${gridAwakening.level}`}