Skip to content

Commit

Permalink
Add formula-ui generators; add trailblazer generators (#2584)
Browse files Browse the repository at this point in the history
* Add generators for sr-formula-ui

* Add support for Trailblazer in generators; simplify some gender stuff

* Generate new trailblazer files

* Generate formula-ui sheets

* Fix format/types
  • Loading branch information
nguyentvan7 authored Dec 20, 2024
1 parent 805d84d commit 381469e
Show file tree
Hide file tree
Showing 239 changed files with 15,698 additions and 2,161 deletions.
9 changes: 9 additions & 0 deletions libs/sr/consts/src/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ export const allCharacterGenderedKeys = [
] as const
export type CharacterGenderedKey = (typeof allCharacterGenderedKeys)[number]

export function characterGenderedKeyToCharacterKey(
cgKey: CharacterGenderedKey
): CharacterKey {
if (cgKey.includes('Trailblazer')) {
return cgKey.slice(0, -1) as TrailblazerKey
}
return cgKey as NonTrailblazerCharacterKey
}

export const maxEidolonCount = 6 as const

export const allLocationKeys = [...allCharacterKeys, ''] as const
Expand Down
6 changes: 6 additions & 0 deletions libs/sr/formula-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ This library was generated with [Nx](https://nx.dev).
## Running unit tests

Run `nx test sr-formula-ui` to execute the unit tests via [Jest](https://jestjs.io).

## Generating template sheets

Run `nx generate @genshin-optimizer/sr/formula-ui:gen-sheet <char|lightCone|relic> <name>` to generate a single template.

Run `nx generate @genshin-optimizer/sr/formula-ui:gen-all-sheets` to generate all missing templates.
14 changes: 14 additions & 0 deletions libs/sr/formula-ui/generators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"generators": {
"gen-sheet": {
"factory": "./src/generators/gen-sheet/single-generator",
"schema": "./src/generators/gen-sheet/single-schema.json",
"description": "Generate a single sheet"
},
"gen-all-sheets": {
"factory": "./src/generators/gen-sheet/all-generator",
"schema": "./src/generators/gen-sheet/all-schema.json",
"description": "Generate all sheets"
}
}
}
6 changes: 6 additions & 0 deletions libs/sr/formula-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@genshin-optimizer/sr/formula-ui",
"version": "0.0.1",
"generators": "./generators.json",
"type": "commonjs"
}
File renamed without changes.
27 changes: 20 additions & 7 deletions libs/sr/formula-ui/src/char/sheetUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import type {
UISheetElement,
} from '@genshin-optimizer/pando/ui-sheet'
import { characterAsset } from '@genshin-optimizer/sr/assets'
import type {
CharacterGenderedKey,
StatKey,
import {
characterGenderedKeyToCharacterKey,
type CharacterGenderedKey,
type StatKey,
} from '@genshin-optimizer/sr/consts'
import { Translate } from '@genshin-optimizer/sr/i18n'
import {
Expand Down Expand Up @@ -50,7 +51,11 @@ export function talentSheet(
text: () =>
chg(
`abilities.${talentKey}.0.fullDesc`,
getCharInterpolateObject(ckey, talentKey, 0)
getCharInterpolateObject(
characterGenderedKeyToCharacterKey(ckey),
talentKey,
0
)
),
},
...docs,
Expand All @@ -73,7 +78,11 @@ export function bonusAbilitySheet(
text: () =>
chg(
`abilities.${talentKey}.0.fullDesc`,
getCharInterpolateObject(ckey, talentKey, 0) // TODO: FIXME: does not seem to work for bonus Stats (wrong array format)
getCharInterpolateObject(
characterGenderedKeyToCharacterKey(ckey),
talentKey,
0
) // TODO: FIXME: does not seem to work for bonus Stats (wrong array format)
),
},
...docs,
Expand All @@ -84,7 +93,7 @@ export function bonusStatsSheets(
ckey: CharacterGenderedKey
): Record<TalentSheetElementStatBoostKey, UISheetElement> {
return objKeyMap(allTalentSheetElementStatBoostKey, (key) => {
const stats = getCharStat(ckey)
const stats = getCharStat(characterGenderedKeyToCharacterKey(ckey))
const [statKey, value] = Object.entries(
stats.skillTree[key]?.levels?.[0].stats ?? {}
)[0]
Expand Down Expand Up @@ -124,7 +133,11 @@ export function eidolonSheet(
type: 'text',
text: chg(
`ranks.${eidolonNum}.desc`,
getCharInterpolateObject(ckey, 'eidolon', eidolonNum)
getCharInterpolateObject(
characterGenderedKeyToCharacterKey(ckey),
'eidolon',
eidolonNum
)
),
},
...docs,
Expand Down
93 changes: 93 additions & 0 deletions libs/sr/formula-ui/src/char/sheets/Acheron.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { UISheet } from '@genshin-optimizer/pando/ui-sheet'
import type { CharacterKey } from '@genshin-optimizer/sr/consts'
import { buffs, conditionals, formulas } from '@genshin-optimizer/sr/formula'
import { mappedStats } from '@genshin-optimizer/sr/stats'
import { trans } from '../../util'
import { type TalentSheetElementKey } from '../consts'
import {
bonusAbilitySheet,
bonusStatsSheets,
eidolonSheet,
talentSheet,
} from '../sheetUtil'

const key: CharacterKey = 'Acheron'
const [chg, _ch] = trans('char', key)
const formula = formulas[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const cond = conditionals[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const buff = buffs[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dm = mappedStats.char[key]

const sheet: UISheet<TalentSheetElementKey> = {
basic: talentSheet(key, 'basic', [
{
type: 'fields',
fields: [
{
title: chg('abilities.basic.0.name'),
fieldRef: formula.basicDmg_0.tag,
},
],
},
]),
skill: talentSheet(key, 'skill', []),
ult: talentSheet(key, 'ult', []),
talent: talentSheet(key, 'talent', []),
technique: talentSheet(key, 'technique'),
bonusAbility1: bonusAbilitySheet(key, 'bonusAbility1'),
bonusAbility2: bonusAbilitySheet(key, 'bonusAbility2'),
bonusAbility3: bonusAbilitySheet(key, 'bonusAbility3', []),

...bonusStatsSheets(key),
eidolon1: eidolonSheet(key, 'eidolon1', []),
eidolon2: eidolonSheet(key, 'eidolon2', []),
eidolon3: eidolonSheet(key, 'eidolon3', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'talent',
// fieldRef: buff.eidolon3_talent.tag,
// },
// {
// //TODO: Translate
// title: 'ult',
// fieldRef: buff.eidolon3_ult.tag,
// },
// ],
// },
]),
eidolon4: eidolonSheet(key, 'eidolon4', []),
eidolon5: eidolonSheet(key, 'eidolon5', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'basic',
// fieldRef: buff.eidolon5_basic.tag,
// },
// {
// //TODO: Translate
// title: 'skill',
// fieldRef: buff.eidolon5_skill.tag,
// },
// ],
// },
]),
eidolon6: eidolonSheet(key, 'eidolon6'),
}
export default sheet
93 changes: 93 additions & 0 deletions libs/sr/formula-ui/src/char/sheets/Argenti.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { UISheet } from '@genshin-optimizer/pando/ui-sheet'
import type { CharacterKey } from '@genshin-optimizer/sr/consts'
import { buffs, conditionals, formulas } from '@genshin-optimizer/sr/formula'
import { mappedStats } from '@genshin-optimizer/sr/stats'
import { trans } from '../../util'
import { type TalentSheetElementKey } from '../consts'
import {
bonusAbilitySheet,
bonusStatsSheets,
eidolonSheet,
talentSheet,
} from '../sheetUtil'

const key: CharacterKey = 'Argenti'
const [chg, _ch] = trans('char', key)
const formula = formulas[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const cond = conditionals[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const buff = buffs[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dm = mappedStats.char[key]

const sheet: UISheet<TalentSheetElementKey> = {
basic: talentSheet(key, 'basic', [
{
type: 'fields',
fields: [
{
title: chg('abilities.basic.0.name'),
fieldRef: formula.basicDmg_0.tag,
},
],
},
]),
skill: talentSheet(key, 'skill', []),
ult: talentSheet(key, 'ult', []),
talent: talentSheet(key, 'talent', []),
technique: talentSheet(key, 'technique'),
bonusAbility1: bonusAbilitySheet(key, 'bonusAbility1'),
bonusAbility2: bonusAbilitySheet(key, 'bonusAbility2'),
bonusAbility3: bonusAbilitySheet(key, 'bonusAbility3', []),

...bonusStatsSheets(key),
eidolon1: eidolonSheet(key, 'eidolon1', []),
eidolon2: eidolonSheet(key, 'eidolon2', []),
eidolon3: eidolonSheet(key, 'eidolon3', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'talent',
// fieldRef: buff.eidolon3_talent.tag,
// },
// {
// //TODO: Translate
// title: 'ult',
// fieldRef: buff.eidolon3_ult.tag,
// },
// ],
// },
]),
eidolon4: eidolonSheet(key, 'eidolon4', []),
eidolon5: eidolonSheet(key, 'eidolon5', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'basic',
// fieldRef: buff.eidolon5_basic.tag,
// },
// {
// //TODO: Translate
// title: 'skill',
// fieldRef: buff.eidolon5_skill.tag,
// },
// ],
// },
]),
eidolon6: eidolonSheet(key, 'eidolon6'),
}
export default sheet
93 changes: 93 additions & 0 deletions libs/sr/formula-ui/src/char/sheets/Asta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { UISheet } from '@genshin-optimizer/pando/ui-sheet'
import type { CharacterKey } from '@genshin-optimizer/sr/consts'
import { buffs, conditionals, formulas } from '@genshin-optimizer/sr/formula'
import { mappedStats } from '@genshin-optimizer/sr/stats'
import { trans } from '../../util'
import { type TalentSheetElementKey } from '../consts'
import {
bonusAbilitySheet,
bonusStatsSheets,
eidolonSheet,
talentSheet,
} from '../sheetUtil'

const key: CharacterKey = 'Asta'
const [chg, _ch] = trans('char', key)
const formula = formulas[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const cond = conditionals[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const buff = buffs[key]
// TODO: Cleanup
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dm = mappedStats.char[key]

const sheet: UISheet<TalentSheetElementKey> = {
basic: talentSheet(key, 'basic', [
{
type: 'fields',
fields: [
{
title: chg('abilities.basic.0.name'),
fieldRef: formula.basicDmg_0.tag,
},
],
},
]),
skill: talentSheet(key, 'skill', []),
ult: talentSheet(key, 'ult', []),
talent: talentSheet(key, 'talent', []),
technique: talentSheet(key, 'technique'),
bonusAbility1: bonusAbilitySheet(key, 'bonusAbility1'),
bonusAbility2: bonusAbilitySheet(key, 'bonusAbility2'),
bonusAbility3: bonusAbilitySheet(key, 'bonusAbility3', []),

...bonusStatsSheets(key),
eidolon1: eidolonSheet(key, 'eidolon1', []),
eidolon2: eidolonSheet(key, 'eidolon2', []),
eidolon3: eidolonSheet(key, 'eidolon3', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'talent',
// fieldRef: buff.eidolon3_talent.tag,
// },
// {
// //TODO: Translate
// title: 'ult',
// fieldRef: buff.eidolon3_ult.tag,
// },
// ],
// },
]),
eidolon4: eidolonSheet(key, 'eidolon4', []),
eidolon5: eidolonSheet(key, 'eidolon5', [
// {
// type: 'fields',
// fields: [
// {
// //TODO: Translate
// title: 'basic',
// fieldRef: buff.eidolon5_basic.tag,
// },
// {
// //TODO: Translate
// title: 'skill',
// fieldRef: buff.eidolon5_skill.tag,
// },
// ],
// },
]),
eidolon6: eidolonSheet(key, 'eidolon6'),
}
export default sheet
Loading

0 comments on commit 381469e

Please sign in to comment.