Skip to content

Commit

Permalink
more superimposition handling
Browse files Browse the repository at this point in the history
  • Loading branch information
frzyc committed Nov 27, 2024
1 parent 024d8be commit 1bc85ce
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libs/sr/formula-ui/src/lightCone/sheets/PastSelfInMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const sheet: UISheetElement = {
{
title: 'Duration',
fieldValue: (
<SuperImposeWrapper>
<SuperImposeWrapper lcKey={key}>
{(superimpose) => dm.duration[superimpose]}
</SuperImposeWrapper>
),
Expand All @@ -61,7 +61,7 @@ const sheet: UISheetElement = {
{
title: 'Energy regen at start of each wave',
fieldValue: (
<SuperImposeWrapper>
<SuperImposeWrapper lcKey={key}>
{(superimpose) => dm.enerRegn[superimpose]}
</SuperImposeWrapper>
),
Expand Down
11 changes: 10 additions & 1 deletion libs/sr/formula-ui/src/lightCone/util.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import type { LightConeKey } from '@genshin-optimizer/sr/consts'
import { own } from '@genshin-optimizer/sr/formula'
import { useSrCalcContext } from '@genshin-optimizer/sr/ui'
import type { ReactNode } from 'react'

export function SuperImposeWrapper({
lcKey,
children,
}: {
lcKey: LightConeKey
children: (superimpose: number) => ReactNode
}) {
const calc = useSrCalcContext()
const superimpose = calc?.compute(own.lightCone.superimpose).val ?? 1
let superimpose = 1
if (calc) {
const hasLightCone = !!calc.compute(own.common.count.sheet(lcKey)).val
if (hasLightCone)
superimpose = calc.compute(own.lightCone.superimpose).val ?? 1
}

return children(superimpose)
}
3 changes: 0 additions & 3 deletions libs/sr/formula/src/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,5 @@ const data: TagMapNodeEntries = [

// Default conditionals to 0
reader.with('qt', 'cond').add(0),

// Default superimposition to 1
reader.withTag(own.lightCone.superimpose.tag).add(1),
]
export default data
2 changes: 1 addition & 1 deletion libs/sr/formula/src/data/util/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const ownTag = {
...objKeyMap(bonusAbilities, () => isoSum),
...objKeyMap(statBoosts, () => isoSum),
},
lightCone: { lvl: iso, ascension: iso, superimpose: iso },
lightCone: { lvl: iso, ascension: iso, superimpose: isoSum },
common: {
count: isoSum,
path: iso,
Expand Down

0 comments on commit 1bc85ce

Please sign in to comment.