Add support for weapon transcendence

Refactors return to be clearer
This commit is contained in:
Justin Edmund 2024-01-13 11:21:54 -08:00
parent efb1a8ccf4
commit e31ecf736c
2 changed files with 29 additions and 29 deletions

View file

@ -16,7 +16,7 @@ interface Props
React.DialogHTMLAttributes<HTMLDivElement>, React.DialogHTMLAttributes<HTMLDivElement>,
HTMLDivElement HTMLDivElement
> { > {
type: 'character' | 'summon' type: 'character' | 'summon' | 'weapon'
starRef: React.RefObject<HTMLDivElement> starRef: React.RefObject<HTMLDivElement>
open: boolean open: boolean
stage: number stage: number
@ -56,7 +56,7 @@ const TranscendencePopover = ({
useEffect(() => { useEffect(() => {
if (type === 'character') setBaseLevel(100) if (type === 'character') setBaseLevel(100)
else if (type === 'summon') setBaseLevel(200) else if (['weapon', 'summon'].includes(type)) setBaseLevel(200)
}, [type]) }, [type])
function handleFragmentClicked(newStage: number) { function handleFragmentClicked(newStage: number) {

View file

@ -15,7 +15,7 @@ interface Props extends React.ComponentProps<'div'> {
editable: boolean editable: boolean
flb: boolean flb: boolean
ulb: boolean ulb: boolean
xlb?: boolean transcendence?: boolean
special: boolean special: boolean
updateUncap?: (index: number) => void updateUncap?: (index: number) => void
updateTranscendence?: (index: number) => void updateTranscendence?: (index: number) => void
@ -57,7 +57,7 @@ const UncapIndicator = (props: Props) => {
} }
} }
} else { } else {
if (props.xlb) { if (props.transcendence) {
numStars = 6 numStars = 6
} else if (props.ulb) { } else if (props.ulb) {
numStars = 5 numStars = 5
@ -93,7 +93,7 @@ const UncapIndicator = (props: Props) => {
const transcendence = (i: number) => { const transcendence = (i: number) => {
const tabIndex = props.position ? props.position * 7 + i + 1 : 0 const tabIndex = props.position ? props.position * 7 + i + 1 : 0
return props.type === 'character' || props.type === 'summon' ? ( return (
<TranscendencePopover <TranscendencePopover
open={popoverOpen} open={popoverOpen}
stage={props.transcendenceStage || 0} stage={props.transcendenceStage || 0}
@ -113,14 +113,6 @@ const UncapIndicator = (props: Props) => {
onStarClick={handleStarClicked} onStarClick={handleStarClicked}
/> />
</TranscendencePopover> </TranscendencePopover>
) : (
<TranscendenceStar
key={`star_${i}`}
stage={props.transcendenceStage || 0}
editable={props.editable}
interactive={false}
tabIndex={tabIndex}
/>
) )
} }
@ -165,25 +157,33 @@ const UncapIndicator = (props: Props) => {
) )
} }
return ( const renderStar = (i: number) => {
<div className={classes}> if (props.type === 'weapon' && i > 4) {
<ul className={styles.indicator}>
{Array.from(Array(numStars)).map((x, i) => {
if (props.type === 'character' && i > 4) {
if (props.special) return ulb(i)
else return transcendence(i)
} else if (props.type === 'summon' && i > 4) {
return transcendence(i) return transcendence(i)
} else if ( }
(props.special && props.type === 'character' && i == 3) ||
(props.type === 'character' && i == 4) || if (props.type === 'character' && i > 4) {
return props.special ? ulb(i) : transcendence(i)
}
if (props.type === 'summon' && i > 4) {
return transcendence(i)
}
if (
(props.special && props.type === 'character' && i === 3) ||
(props.type === 'character' && i === 4) ||
(props.type !== 'character' && i > 2) (props.type !== 'character' && i > 2)
) { ) {
return flb(i) return flb(i)
} else { }
return mlb(i) return mlb(i)
} }
})}
return (
<div className={classes}>
<ul className={styles.indicator}>
{Array.from(Array(numStars)).map((_, i) => renderStar(i))}
</ul> </ul>
</div> </div>
) )