Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substat optimization on TC page #1263

Merged
merged 75 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
cb0e5fd
wip: tc-opt
eeeqeee Nov 21, 2022
3ed54a9
fixes
eeeqeee Nov 23, 2022
3aed95f
add comments
eeeqeee Jan 9, 2023
3b827f5
Merge branch 'master' into tc-opt
eeeqeee Feb 19, 2023
2629306
fix hysteresis
eeeqeee Feb 20, 2023
44f1e38
eslint fixes + touchups
eeeqeee Feb 20, 2023
1737d69
remove max+offset from display
eeeqeee Mar 1, 2023
7434284
Fix apply not working & set max default to 30 subs
eeeqeee Mar 2, 2023
c2aebcf
wtf is teamData
Mar 3, 2023
a6c71c4
Merge remote-tracking branch 'origin/master' into pr/781
frzyc Mar 4, 2023
f6e5713
cleanup max+offset
frzyc Mar 4, 2023
40afe56
add UI to mass edit substat rolls/max
frzyc Mar 4, 2023
d35c15d
fix bugs
eeeqeee Mar 9, 2023
6ec5863
Merge remote-tracking branch 'origin/master' into tc-opt
eeeqeee Mar 11, 2023
70e8124
fix merge
eeeqeee Mar 11, 2023
edd363a
guard printing
eeeqeee Jun 18, 2023
09f38b5
Merge remote-tracking branch 'origin/master' into tc-opt
eeeqeee Jun 18, 2023
0f47810
fmt
eeeqeee Jun 18, 2023
d34cafe
extract to function
eeeqeee Jun 18, 2023
1674eda
hardcode answer if more distributedSubs than max
eeeqeee Jun 22, 2023
e0d2fb6
add comment and fold ignored subs
eeeqeee Jun 22, 2023
2e1a339
missed rename
eeeqeee Jun 22, 2023
5b02868
add comments
eeeqeee Jul 1, 2023
4d6472c
Merge remote-tracking branch 'origin/master' into tc-opt
frzyc Jul 14, 2023
699458b
Merge branch 'master' into tc-opt
nguyentvan7 Jul 20, 2023
fb955a9
Merge branch 'master' into tc-opt
frzyc Aug 9, 2023
607be09
minor fixes
frzyc Aug 9, 2023
2c93580
Merge branch 'master' into tc-opt
frzyc Dec 19, 2023
8aa3794
Merge branch 'master' into tc-opt
frzyc Dec 21, 2023
dd02eea
Merge branch 'master' into tc-opt
frzyc Dec 21, 2023
734cce6
minor updates & fixes
frzyc Dec 23, 2023
77de132
Merge branch 'master' into tc-opt
frzyc Dec 23, 2023
d7d2d2a
minor fixes
frzyc Dec 23, 2023
2e7c97c
forgot to assign the last substat
eeeqeee Dec 24, 2023
7689903
minor refactoring
frzyc Dec 24, 2023
282ae64
add rarity + better max
frzyc Dec 24, 2023
8ddc26b
update roll calc
frzyc Dec 24, 2023
ad7f27a
update input
frzyc Dec 24, 2023
2404a01
add kqms button
frzyc Dec 24, 2023
b590bf4
prevent all editors to trigger on 1st render
frzyc Dec 24, 2023
172c7de
avoid using `any` in upOpt.ts
eeeqeee Dec 25, 2023
c76e89e
format
eeeqeee Dec 25, 2023
764afdc
switch to `shouldShowDevComponents`
eeeqeee Dec 25, 2023
f46336d
update initializer function for charTC
frzyc Dec 25, 2023
72e2cc2
add 2 rolls to kqms
frzyc Dec 25, 2023
6e63ccf
update default/reset rolls for charTC
frzyc Dec 25, 2023
ef2b839
add dialogs
frzyc Dec 28, 2023
23b5887
Merge branch 'master' into tc-opt
frzyc Dec 31, 2023
46a571c
use KQMS
frzyc Dec 31, 2023
e943329
add gcsim snippet
frzyc Dec 31, 2023
22bc917
gcsim has no comma
frzyc Dec 31, 2023
dc46497
use raw value
frzyc Dec 31, 2023
d88db5f
refinement
frzyc Dec 31, 2023
b48b513
add `minSubstats` and `scalesWith`
eeeqeee Jan 3, 2024
269cd95
change from `minSubstats` to `minTotal`
eeeqeee Jan 5, 2024
9287d3b
cap
frzyc Jan 6, 2024
439f404
Merge branch 'master' into tc-opt
frzyc Jan 7, 2024
478550d
Revert "change from `minSubstats` to `minTotal`"
frzyc Jan 8, 2024
6e22acb
Revert "add `minSubstats` and `scalesWith`"
frzyc Jan 8, 2024
0fc097b
minor update
frzyc Jan 8, 2024
8fb9a98
util
frzyc Jan 8, 2024
6d8e434
Tc opt 2 (#1423)
frzyc Jan 18, 2024
ac09bdc
add unit test
frzyc Jan 19, 2024
3d40c32
add QoL
frzyc Jan 21, 2024
2399fbe
fix lint
frzyc Jan 21, 2024
781d141
translation + bugfix
frzyc Jan 21, 2024
8959ae3
update constraintCard
frzyc Jan 21, 2024
389bb8e
address comments
frzyc Jan 21, 2024
211ffbb
prevent canceling from breaking future opt runs (#1444)
eeeqeee Jan 21, 2024
e25dc0f
fix quotes
frzyc Jan 21, 2024
6eb998c
addresss comments
frzyc Jan 23, 2024
c781e4f
addresss comments
frzyc Jan 23, 2024
145b9a2
format
frzyc Jan 23, 2024
e2cb6fe
Merge branch 'master' into tc-opt
frzyc Jan 24, 2024
0f8d40a
fix merge issue
frzyc Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ type Data = {
setNumKey: SetNum
hideHeader?: boolean
conditionalsOnly?: boolean
disabled?: boolean
}

export default function SetEffectDisplay({
setKey,
setNumKey,
hideHeader = false,
conditionalsOnly = false,
disabled = false,
}: Data) {
const sheet = getArtSheet(setKey)

Expand All @@ -27,7 +29,11 @@ export default function SetEffectDisplay({
return (
<Box display="flex" flexDirection="column">
{document ? (
<DocumentDisplay sections={document} hideHeader={hideHeader} />
<DocumentDisplay
sections={document}
hideHeader={hideHeader}
disabled={disabled}
/>
) : null}
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ type ConditionalDisplayProps = {
conditional: DocumentConditional
hideHeader?: boolean | ((section: DocumentSection) => boolean)
hideDesc?: boolean
disabled?: boolean
}

export default function ConditionalDisplay({
conditional,
hideHeader = false,
hideDesc = false,
disabled = false,
}: ConditionalDisplayProps) {
const { data } = useContext(DataContext)
let fields
Expand All @@ -38,7 +40,7 @@ export default function ConditionalDisplay({
<HeaderDisplay header={conditional.header} hideDesc={hideDesc} />
)}
<CardContent sx={{ p: 0, '&:last-child': { pb: 0 } }}>
<ConditionalSelector conditional={conditional} />
<ConditionalSelector conditional={conditional} disabled={disabled} />
</CardContent>
{fields && <FieldsDisplay fields={fields} />}
</CardDark>
Expand Down
50 changes: 28 additions & 22 deletions apps/frontend/src/app/Components/CustomNumberInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ButtonProps, InputProps } from '@mui/material'
import { Button, InputBase, styled } from '@mui/material'
import type { ChangeEvent, KeyboardEvent } from 'react'
import { useCallback, useEffect, useState } from 'react'
export type CustomNumberInputProps = Omit<InputProps, 'onChange'> & {
value?: number | undefined
Expand Down Expand Up @@ -68,41 +69,46 @@ export default function CustomNumberInput({
...props
}: CustomNumberInputProps) {
const { inputProps = {}, ...restProps } = props
const { min, max } = inputProps
const [display, setDisplay] = useState(value.toString())

const onInputChange = useCallback(
(e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>
setDisplay(e.target.value),
[]
)

const [number, setNumber] = useState(value)
const [focused, setFocus] = useState(false)
const parseFunc = useCallback(
(val: string) => (float ? parseFloat(val) : parseInt(val)),
[float]
)
const onBlur = useCallback(() => {
onChange(number)
setFocus(false)
}, [onChange, number, setFocus])
const onFocus = useCallback(() => {
setFocus(true)
}, [setFocus])
useEffect(() => setNumber(value), [value, setNumber]) // update value on value change
const onInputChange = useCallback(
(e) => {
const newNum = parseFunc(e.target.value) || 0
if (inputProps.min !== undefined && newNum < inputProps.min) return
if (inputProps.max !== undefined && newNum > inputProps.max) return
setNumber(newNum)
},
[setNumber, parseFunc, inputProps.min, inputProps.max]
const onValidate = useCallback(() => {
const change = (v: number) => {
setDisplay(v.toString())
onChange(v)
}
const newNum = parseFunc(display) || 0
if (min !== undefined && newNum < min) return change(min)
if (max !== undefined && newNum > max) return change(max)
return change(newNum)
}, [min, max, parseFunc, onChange, display])

useEffect(() => setDisplay(value.toString()), [value, setDisplay]) // update value on value change

const onKeyDown = useCallback(
(e: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) =>
e.key === 'Enter' && onValidate(),
[onValidate]
)
const onKeyDown = useCallback((e) => e.key === 'Enter' && onBlur(), [onBlur])

return (
<StyledInputBase
value={focused && !number ? '' : number}
value={display}
aria-label="custom-input"
type="number"
inputProps={{ step: float ? 0.1 : 1, ...inputProps }}
onChange={onInputChange}
onBlur={onBlur}
onFocus={onFocus}
onBlur={onValidate}
disabled={disabled}
onKeyDown={onKeyDown}
{...restProps}
Expand Down
6 changes: 6 additions & 0 deletions apps/frontend/src/app/Components/DocumentDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ type DocumentDisplayProps = {
teamBuffOnly?: boolean
hideDesc?: boolean
hideHeader?: boolean | ((section: DocumentSection) => boolean)
disabled?: boolean
}

export default function DocumentDisplay({
sections,
teamBuffOnly,
hideDesc = false,
hideHeader = false,
disabled = false,
}: DocumentDisplayProps) {
const { data } = useContext(DataContext)
if (!sections.length) return null
Expand All @@ -41,6 +43,7 @@ export default function DocumentDisplay({
key={i}
hideDesc={hideDesc}
hideHeader={hideHeader}
disabled={disabled}
/>
)
})
Expand All @@ -57,10 +60,12 @@ function SectionDisplay({
section,
hideDesc = false,
hideHeader = false,
disabled = false,
}: {
section: DocumentSection
hideDesc?: boolean
hideHeader?: boolean | ((section: DocumentSection) => boolean)
disabled?: boolean
}) {
if ('fields' in section) {
return (
Expand All @@ -76,6 +81,7 @@ function SectionDisplay({
conditional={section}
hideDesc={hideDesc}
hideHeader={hideHeader}
disabled={disabled}
/>
)
} /* if ("text" in section) */ else {
Expand Down
13 changes: 11 additions & 2 deletions apps/frontend/src/app/Components/LevelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ export default function LevelSelect({
ascension,
setBoth,
useLow = false,
disabled = false,
}: {
level: number
ascension: AscensionKey
setBoth: (action: { level?: number; ascension?: AscensionKey }) => void
useLow?: boolean
disabled?: boolean
}) {
const { t } = useTranslation('ui')
const ascensionMaxLevels = useLow ? ascensionMaxLevelLow : ascensionMaxLevel
Expand Down Expand Up @@ -56,6 +58,7 @@ export default function LevelSelect({
onChange={setLevel}
value={level}
startAdornment="Lv. "
disabled={disabled}
inputProps={{
min: 1,
max: 90,
Expand All @@ -66,12 +69,18 @@ export default function LevelSelect({
</CustomNumberInputButtonGroupWrapper>
<Button
sx={{ pl: 1, whiteSpace: 'nowrap' }}
disabled={!(useLow ? ambiguousLevelLow : ambiguousLevel)(level)}
disabled={
!(useLow ? ambiguousLevelLow : ambiguousLevel)(level) || disabled
}
onClick={setAscension}
>
<strong>/ {ascensionMaxLevel[ascension]}</strong>
</Button>
<DropdownButton title={t('selectlevel')} sx={{ flexGrow: 1 }}>
<DropdownButton
title={t('selectlevel')}
sx={{ flexGrow: 1 }}
disabled={disabled}
>
{[...(useLow ? milestoneLevelsLow : milestoneLevels)].map(
([lv, as]) => {
const selected = lv === level && as === ascension
Expand Down
7 changes: 6 additions & 1 deletion apps/frontend/src/app/Components/RefinementDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ import DropdownButton from './DropdownMenu/DropdownButton'
export default function RefinementDropdown({
refinement,
setRefinement,
disabled = false,
}: {
refinement: RefinementKey
setRefinement: (r: RefinementKey) => void
disabled?: boolean
}) {
const { t } = useTranslation('ui')
return (
<DropdownButton title={t('refinement', { value: refinement })}>
<DropdownButton
title={t('refinement', { value: refinement })}
disabled={disabled}
>
{allRefinementKeys.map((r) => (
<MenuItem
key={r}
Expand Down
Loading