Skip to content

Commit

Permalink
preliminary text display for formula using UI sheets (frzyc#2470)
Browse files Browse the repository at this point in the history
* preliminary text display for formula using UI sheets

* add base stats uisheet

* fix heal

* add more base stats, update sheet

* createTagMap util
  • Loading branch information
frzyc authored and macerator-yaro committed Oct 29, 2024
1 parent 3a57092 commit 0b7b11a
Show file tree
Hide file tree
Showing 37 changed files with 298 additions and 94 deletions.
2 changes: 1 addition & 1 deletion libs/pando/engine/src/tag/dedup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class DedupTags<V = never> {
}

/** Object associated with `tag` */
at(tag: Tag): DedupTag<V> {
at(tag: Tag): Leaf<V> {
const id = this.keys.get(tag)
const cur = id.reduce((cur, id) => cur.child(id), this.root)
if (!cur.leaf) cur.leaf = new Leaf(tag, id, this.keys, cur)
Expand Down
4 changes: 4 additions & 0 deletions libs/pando/ui-sheet/src/types/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ export type TextField = {
}

export type Field = TagField | TextField

export function isTagField(field: Field): field is TagField {
return 'fieldRef' in field
}
29 changes: 6 additions & 23 deletions libs/sr/consts/src/common.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
import type { AbilityKey } from './character'
import { allRelicMainStatKeys, allRelicSubStatKeys } from './relic'

export const allRarityKeys = [5, 4, 3, 2, 1] as const
export type RarityKey = (typeof allRarityKeys)[number]

export const allStatKeys = [
'spd',
'hp',
'hp_',
'atk',
'atk_',
'def',
'def_',
'crit_',
'crit_dmg_',
'brEffect_',
'eff_',
'eff_res_',
'enerRegen_',
'heal_',
'physical_dmg_',
'fire_dmg_',
'ice_dmg_',
'wind_dmg_',
'lightning_dmg_',
'quantum_dmg_',
'imaginary_dmg_',
] as const
export const otherStatKeys = ['spd_', 'dmg_', 'weakness_', 'resPen_'] as const

export const allStatKeys = Array.from(
new Set([...allRelicMainStatKeys, ...allRelicSubStatKeys, ...otherStatKeys])
)
export type StatKey = (typeof allStatKeys)[number]

export const allElementalDamageKeys = [
Expand Down
24 changes: 16 additions & 8 deletions libs/sr/consts/src/relic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ export const allRelicSubStatKeys = [
'brEffect_',
] as const
export type RelicSubStatKey = (typeof allRelicSubStatKeys)[number]

export const allElementalDmgMainStatKeys = [
'physical_dmg_',
'fire_dmg_',
'ice_dmg_',
'lightning_dmg_',
'wind_dmg_',
'quantum_dmg_',
'imaginary_dmg_',
] as const
export const allRelicMainStatKeys = [
'hp',
'atk',
Expand All @@ -87,16 +95,11 @@ export const allRelicMainStatKeys = [
'heal_',
'eff_',
'spd',
'physical_dmg_',
'fire_dmg_',
'ice_dmg_',
'lightning_dmg_',
'wind_dmg_',
'quantum_dmg_',
'imaginary_dmg_',
...allElementalDmgMainStatKeys,
'brEffect_',
'enerRegen_',
] as const

export type RelicMainStatKey = (typeof allRelicMainStatKeys)[number]

export const allRelicRarityKeys = [2, 3, 4, 5] as const
Expand Down Expand Up @@ -142,3 +145,8 @@ export const relicSlotToMainStatKeys: Record<RelicSlotKey, RelicMainStatKey[]> =
],
rope: ['hp_', 'atk_', 'def_', 'brEffect_', 'enerRegen_'],
}

export const allRelicMainSubStatKeys = Array.from(
new Set([...allRelicSubStatKeys, ...allRelicMainStatKeys] as const)
)
export type RelicMainSubStatKey = (typeof allRelicMainSubStatKeys)[number]
6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/chs/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/cht/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/de/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/en/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/es/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/fr/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/id/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/ja/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/ko/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/pt/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/ru/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/th/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion libs/sr/dm-localization/assets/locales/vi/statKey_gen.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const HashData = {
},
statKey: {
spd: '461357812',
spd_: '461357812',
hp: '-1544419067',
hp_: '-1544419067',
atk: '-1126979077',
Expand All @@ -67,5 +68,8 @@ export const HashData = {
lightning_dmg_: '235195444',
quantum_dmg_: '1819458027',
imaginary_dmg_: '1031064451',
dmg_: '-907763317',
weakness_: '-1297647890',
resPen_: '-538204877',
},
}
2 changes: 2 additions & 0 deletions libs/sr/formula-ui/src/char/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './consts'
export * from './sheets'
export * from './tagFieldMap'
export * from './util'
34 changes: 34 additions & 0 deletions libs/sr/formula-ui/src/char/sheets/CharBase.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { TagField } from '@genshin-optimizer/pando/ui-sheet'
import type { ElementalTypeKey } from '@genshin-optimizer/sr/consts'
import {
allElementalDmgMainStatKeys,
allStatKeys,
} from '@genshin-optimizer/sr/consts'
import type { Tag } from '@genshin-optimizer/sr/formula'
import { own } from '@genshin-optimizer/sr/formula'
import { StatDisplay } from '@genshin-optimizer/sr/ui'
export const charBaseUiSheet: TagField[] = allStatKeys.map((statKey) => {
if (
allElementalDmgMainStatKeys.includes(
statKey as (typeof allElementalDmgMainStatKeys)[number]
)
) {
const tag = {
...own.final.dmg_.tag,
elementalType: statKey.slice(0, -5) as ElementalTypeKey,
} as Tag
return {
title: <StatDisplay statKey={statKey} />,
fieldRef: tag,
} as TagField
}
if (statKey === 'crit_')
return {
fieldRef: own.common.cappedCrit_.tag,
title: <StatDisplay statKey={statKey} />,
}
return {
fieldRef: own.final[statKey as keyof typeof own.final].tag as Tag,
title: <StatDisplay statKey={statKey} />,
}
})
Loading

0 comments on commit 0b7b11a

Please sign in to comment.