Fix uncap levels
Shit was really broken Since 0 is a valid value, we needed to check if it was null, because Javascript
This commit is contained in:
parent
4dbbe01486
commit
e0eb0fdf21
4 changed files with 13 additions and 13 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useRef, useState } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import UncapStar from '~components/UncapStar'
|
import UncapStar from '~components/UncapStar'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
@ -10,12 +10,10 @@ interface Props {
|
||||||
flb: boolean
|
flb: boolean
|
||||||
ulb: boolean
|
ulb: boolean
|
||||||
special: boolean
|
special: boolean
|
||||||
updateUncap?: (uncap: number) => void
|
updateUncap?: (index: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const UncapIndicator = (props: Props) => {
|
const UncapIndicator = (props: Props) => {
|
||||||
const [uncap, setUncap] = useState(props.uncapLevel)
|
|
||||||
|
|
||||||
const numStars = setNumStars()
|
const numStars = setNumStars()
|
||||||
function setNumStars() {
|
function setNumStars() {
|
||||||
let numStars
|
let numStars
|
||||||
|
|
@ -53,7 +51,7 @@ const UncapIndicator = (props: Props) => {
|
||||||
|
|
||||||
function toggleStar(index: number, empty: boolean) {
|
function toggleStar(index: number, empty: boolean) {
|
||||||
if (props.updateUncap) {
|
if (props.updateUncap) {
|
||||||
if (empty) props.updateUncap(index + 1)
|
if (empty && index > 0) props.updateUncap(index + 1)
|
||||||
else props.updateUncap(index)
|
else props.updateUncap(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -71,10 +69,11 @@ const UncapIndicator = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ulb = (i: number) => {
|
const ulb = (i: number) => {
|
||||||
|
// console.log('ULB; Number of stars:', props.uncapLevel)
|
||||||
return (
|
return (
|
||||||
<UncapStar
|
<UncapStar
|
||||||
ulb={true}
|
ulb={true}
|
||||||
empty={props.uncapLevel ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onClick={toggleStar}
|
||||||
|
|
@ -83,10 +82,11 @@ const UncapIndicator = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const flb = (i: number) => {
|
const flb = (i: number) => {
|
||||||
|
// console.log('FLB; Number of stars:', props.uncapLevel)
|
||||||
return (
|
return (
|
||||||
<UncapStar
|
<UncapStar
|
||||||
flb={true}
|
flb={true}
|
||||||
empty={props.uncapLevel ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onClick={toggleStar}
|
||||||
|
|
@ -95,10 +95,10 @@ const UncapIndicator = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const mlb = (i: number) => {
|
const mlb = (i: number) => {
|
||||||
// console.log("MLB; Number of stars:", props.uncapLevel)
|
// console.log('MLB; Number of stars:', props.uncapLevel)
|
||||||
return (
|
return (
|
||||||
<UncapStar
|
<UncapStar
|
||||||
empty={props.uncapLevel ? i >= props.uncapLevel : false}
|
empty={props.uncapLevel != null ? i >= props.uncapLevel : false}
|
||||||
key={`star_${i}`}
|
key={`star_${i}`}
|
||||||
index={i}
|
index={i}
|
||||||
onClick={toggleStar}
|
onClick={toggleStar}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
||||||
|
console.log(`Updating uncap level at position ${position} to ${uncapLevel}`)
|
||||||
if (appState.grid.weapons.mainWeapon && position == -1)
|
if (appState.grid.weapons.mainWeapon && position == -1)
|
||||||
appState.grid.weapons.mainWeapon.uncap_level = uncapLevel
|
appState.grid.weapons.mainWeapon.uncap_level = uncapLevel
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import Button from '~components/Button'
|
||||||
|
|
||||||
import type { SearchableObject } from '~types'
|
import type { SearchableObject } from '~types'
|
||||||
|
|
||||||
import { appState } from '~utils/appState'
|
|
||||||
import { axData } from '~utils/axData'
|
import { axData } from '~utils/axData'
|
||||||
import { weaponAwakening } from '~utils/awakening'
|
import { weaponAwakening } from '~utils/awakening'
|
||||||
|
|
||||||
|
|
@ -341,9 +340,9 @@ const WeaponUnit = (props: Props) => {
|
||||||
} else return
|
} else return
|
||||||
}
|
}
|
||||||
|
|
||||||
function passUncapData(uncap: number) {
|
function passUncapData(index: number) {
|
||||||
if (props.gridWeapon)
|
if (props.gridWeapon)
|
||||||
props.updateUncap(props.gridWeapon.id, props.position, uncap)
|
props.updateUncap(props.gridWeapon.id, props.position, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
function canBeModified(gridWeapon: GridWeapon) {
|
function canBeModified(gridWeapon: GridWeapon) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue