Tightly couple ATK and HP values
This commit is contained in:
parent
9041683a6c
commit
dd8f1906e8
2 changed files with 30 additions and 5 deletions
|
|
@ -66,11 +66,34 @@ const RingSelect = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function receiveRingValues(index: number, left: number, right: number) {
|
function receiveRingValues(index: number, left: number, right: number) {
|
||||||
|
if (index == 1 || index == 2) {
|
||||||
|
setSyncedRingValues(index, right)
|
||||||
|
} else {
|
||||||
|
setRings({
|
||||||
|
...rings,
|
||||||
|
[index]: {
|
||||||
|
modifier: left,
|
||||||
|
strength: right,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSyncedRingValues(index: 1 | 2, value: number) {
|
||||||
|
const atkValues = (dataSet(1)[0] as ItemSkill).values ?? []
|
||||||
|
const hpValues = (dataSet(2)[0] as ItemSkill).values ?? []
|
||||||
|
|
||||||
|
let found = index === 1 ? atkValues.indexOf(value) : hpValues.indexOf(value)
|
||||||
|
|
||||||
setRings({
|
setRings({
|
||||||
...rings,
|
...rings,
|
||||||
[index]: {
|
1: {
|
||||||
modifier: left,
|
modifier: rings[1].modifier,
|
||||||
strength: right,
|
strength: atkValues[found],
|
||||||
|
},
|
||||||
|
2: {
|
||||||
|
modifier: rings[2].modifier,
|
||||||
|
strength: hpValues[found],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,10 @@ const SelectWithInput = ({
|
||||||
setCurrentItemValue(rightSelectValue)
|
setCurrentItemValue(rightSelectValue)
|
||||||
}, [leftSelectValue, rightSelectValue])
|
}, [leftSelectValue, rightSelectValue])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentItemSkill) sendValues(currentItemSkill.id, currentItemValue)
|
||||||
|
}, [currentItemSkill, currentItemValue])
|
||||||
|
|
||||||
// Methods: UI state management
|
// Methods: UI state management
|
||||||
function changeOpen(side: 'left' | 'right') {
|
function changeOpen(side: 'left' | 'right') {
|
||||||
if (side === 'left' && !leftSelectDisabled) {
|
if (side === 'left' && !leftSelectDisabled) {
|
||||||
|
|
@ -111,13 +115,11 @@ const SelectWithInput = ({
|
||||||
const skill = dataSet.find((sk) => sk.id === value)
|
const skill = dataSet.find((sk) => sk.id === value)
|
||||||
setCurrentItemSkill(skill)
|
setCurrentItemSkill(skill)
|
||||||
setCurrentItemValue(0)
|
setCurrentItemValue(0)
|
||||||
sendValues(leftSelectValue, rightSelectValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRightSelectChange(rawValue: string) {
|
function handleRightSelectChange(rawValue: string) {
|
||||||
const value = parseFloat(rawValue)
|
const value = parseFloat(rawValue)
|
||||||
setCurrentItemValue(value)
|
setCurrentItemValue(value)
|
||||||
sendValues(leftSelectValue, rightSelectValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue