From e0eb0fdf212fc79693d7d468ed16bb77b5c16534 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 25 Dec 2022 23:00:39 -0800 Subject: [PATCH] Fix uncap levels Shit was really broken Since 0 is a valid value, we needed to check if it was null, because Javascript --- components/UncapIndicator/index.tsx | 18 +++++++++--------- components/UncapStar/index.tsx | 2 +- components/WeaponGrid/index.tsx | 1 + components/WeaponUnit/index.tsx | 5 ++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/UncapIndicator/index.tsx b/components/UncapIndicator/index.tsx index d71a6043..296e85da 100644 --- a/components/UncapIndicator/index.tsx +++ b/components/UncapIndicator/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect } from 'react' import UncapStar from '~components/UncapStar' import './index.scss' @@ -10,12 +10,10 @@ interface Props { flb: boolean ulb: boolean special: boolean - updateUncap?: (uncap: number) => void + updateUncap?: (index: number) => void } const UncapIndicator = (props: Props) => { - const [uncap, setUncap] = useState(props.uncapLevel) - const numStars = setNumStars() function setNumStars() { let numStars @@ -53,7 +51,7 @@ const UncapIndicator = (props: Props) => { function toggleStar(index: number, empty: boolean) { if (props.updateUncap) { - if (empty) props.updateUncap(index + 1) + if (empty && index > 0) props.updateUncap(index + 1) else props.updateUncap(index) } } @@ -71,10 +69,11 @@ const UncapIndicator = (props: Props) => { } const ulb = (i: number) => { + // console.log('ULB; Number of stars:', props.uncapLevel) return ( = props.uncapLevel : false} + empty={props.uncapLevel != null ? i >= props.uncapLevel : false} key={`star_${i}`} index={i} onClick={toggleStar} @@ -83,10 +82,11 @@ const UncapIndicator = (props: Props) => { } const flb = (i: number) => { + // console.log('FLB; Number of stars:', props.uncapLevel) return ( = props.uncapLevel : false} + empty={props.uncapLevel != null ? i >= props.uncapLevel : false} key={`star_${i}`} index={i} onClick={toggleStar} @@ -95,10 +95,10 @@ const UncapIndicator = (props: Props) => { } const mlb = (i: number) => { - // console.log("MLB; Number of stars:", props.uncapLevel) + // console.log('MLB; Number of stars:', props.uncapLevel) return ( = props.uncapLevel : false} + empty={props.uncapLevel != null ? i >= props.uncapLevel : false} key={`star_${i}`} index={i} onClick={toggleStar} diff --git a/components/UncapStar/index.tsx b/components/UncapStar/index.tsx index 9b0969f7..78510fad 100644 --- a/components/UncapStar/index.tsx +++ b/components/UncapStar/index.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useEffect } from 'react' import classnames from 'classnames' import './index.scss' diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 33d9d32e..511709aa 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -252,6 +252,7 @@ const WeaponGrid = (props: Props) => { ) const updateUncapLevel = (position: number, uncapLevel: number) => { + console.log(`Updating uncap level at position ${position} to ${uncapLevel}`) if (appState.grid.weapons.mainWeapon && position == -1) appState.grid.weapons.mainWeapon.uncap_level = uncapLevel else { diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx index 2baba499..5a59c138 100644 --- a/components/WeaponUnit/index.tsx +++ b/components/WeaponUnit/index.tsx @@ -11,7 +11,6 @@ import Button from '~components/Button' import type { SearchableObject } from '~types' -import { appState } from '~utils/appState' import { axData } from '~utils/axData' import { weaponAwakening } from '~utils/awakening' @@ -341,9 +340,9 @@ const WeaponUnit = (props: Props) => { } else return } - function passUncapData(uncap: number) { + function passUncapData(index: number) { if (props.gridWeapon) - props.updateUncap(props.gridWeapon.id, props.position, uncap) + props.updateUncap(props.gridWeapon.id, props.position, index) } function canBeModified(gridWeapon: GridWeapon) {