Skip to content

Commit

Permalink
Fix typings
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentvan7 committed Jan 1, 2024
1 parent 17629ee commit 2e507b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libs/sr-formula/src/data/char/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
import { objKeyMap } from '@genshin-optimizer/util'
import type { AttackType, FormulaArg, Stat, Type } from '../util'
import {
TypeKeyToListingType,
customDmg,
customHeal,
customShield,
Expand Down Expand Up @@ -190,7 +191,7 @@ export function entriesForChar(data_gen: CharacterDataGen): TagMapNodeEntries {
selfBuff.listing.formulas.add(listingItem(self.final.crit_dmg_)),
selfBuff.listing.formulas.add(listingItem(self.final.heal_)),
selfBuff.listing.formulas.add(
listingItem(self.final.dmg_[data_gen.damageType.toLowerCase() as Type])
listingItem(self.final.dmg_[TypeKeyToListingType[data_gen.damageType]])
),
selfBuff.listing.formulas.add(listingItem(self.final.dmg_.physical)),
]
Expand Down
11 changes: 11 additions & 0 deletions libs/sr-formula/src/data/util/listing.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TypeKey } from '@genshin-optimizer/sr-consts'
import {
allCharacterKeys,
allLightConeKeys,
Expand Down Expand Up @@ -99,3 +100,13 @@ export type EntryType = (typeof entryTypes)[number]
export type Source = (typeof srcs)[number]
export type Member = (typeof members)[number]
export type Preset = (typeof presets)[number]

export const TypeKeyToListingType: Record<TypeKey, Type> = {
Physical: 'physical',
Quantum: 'quantum',
Lightning: 'lightning',
Ice: 'ice',
Wind: 'wind',
Fire: 'fire',
Imaginary: 'imaginary',
}
5 changes: 3 additions & 2 deletions libs/sr-formula/src/data/util/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { prod, type NumNode, type StrNode } from '@genshin-optimizer/pando'
import type { TypeKey } from '@genshin-optimizer/sr-consts'
import type { Read } from '.'
import {
TypeKeyToListingType,
percent,
reader,
selfBuff,
Expand All @@ -10,7 +11,7 @@ import {
type TagMapNodeEntries,
type TagMapNodeEntry,
} from '.'
import type { AttackType, Source, Type } from './listing'
import type { AttackType, Source } from './listing'

export type FormulaArg = {
team?: boolean // true if applies to every member, and false (default) if applies only to self
Expand Down Expand Up @@ -69,7 +70,7 @@ export function customDmg(
...extra: TagMapNodeEntries
): TagMapNodeEntries[] {
const buff = team ? teamBuff : selfBuff
const type = typeKey.toLowerCase() as Type
const type = TypeKeyToListingType[typeKey]
return splits.map((split, index) =>
registerFormula(
`${name}_${index}`,
Expand Down

0 comments on commit 2e507b5

Please sign in to comment.