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

Update sr-formula and add March7th sheet #1403

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a672c30
Adjust usage of context
nguyentvan7 Dec 29, 2023
1278c17
Use CalcContext
nguyentvan7 Dec 30, 2023
54f300d
Add global override for object functions
nguyentvan7 Dec 31, 2023
798cb55
Fix key naming
nguyentvan7 Dec 31, 2023
b3b31c5
Export SkillTreeNodeBonusStat type
nguyentvan7 Dec 31, 2023
da02c8a
Fix tag shape
nguyentvan7 Dec 31, 2023
74fe689
Update stat calculation
nguyentvan7 Dec 31, 2023
dbe96bd
Export Calculator type
nguyentvan7 Dec 31, 2023
7c200c9
Export type dmg keys
nguyentvan7 Dec 31, 2023
eeb2dfa
Fix default char stats
nguyentvan7 Dec 31, 2023
326d014
Add small trace and eidolon utils
nguyentvan7 Jan 1, 2024
2766e3f
Add gen files and fix typing
nguyentvan7 Jan 1, 2024
0546d10
Add base stats to util
nguyentvan7 Jan 1, 2024
1c68d5b
Add dmg and shield utils
nguyentvan7 Jan 1, 2024
107f5a1
Add jsdoc and heal util
nguyentvan7 Jan 1, 2024
b7f1eb1
Add March7th sheet and fix bugs in formula impl
nguyentvan7 Jan 1, 2024
10cb091
Add formula printer
nguyentvan7 Jan 1, 2024
f011b75
Add simple copy-pasted listFormulas (broken)
nguyentvan7 Jan 1, 2024
209f9af
Fix more bugs
nguyentvan7 Jan 1, 2024
e2fea54
Rename march damage
nguyentvan7 Jan 1, 2024
0879e82
Fix stat display
nguyentvan7 Jan 1, 2024
f3b0ed5
Add damage calcs
nguyentvan7 Jan 1, 2024
e419d69
Attempt to compute nodes
nguyentvan7 Jan 1, 2024
86765ba
Delete bad UI
nguyentvan7 Jan 1, 2024
6f740bb
Fix damage calcs
nguyentvan7 Jan 1, 2024
17629ee
Fix ui display
nguyentvan7 Jan 1, 2024
2e507b5
Fix typings
nguyentvan7 Jan 1, 2024
ab1e70d
Fix some todos
nguyentvan7 Jan 1, 2024
7999a0e
Fix light cone calc
nguyentvan7 Jan 1, 2024
e9b877e
Fix def/res calcs
nguyentvan7 Jan 1, 2024
9d172f6
Fix typeRoots
nguyentvan7 Jan 1, 2024
b5257f5
Fix typings
nguyentvan7 Jan 1, 2024
174b00d
Fix unit tests
nguyentvan7 Jan 1, 2024
6b04f40
Fix typing again
nguyentvan7 Jan 1, 2024
06868dd
Fix src for char, lightCone and relic
nguyentvan7 Jan 1, 2024
c0d4a55
Fix errors
nguyentvan7 Jan 1, 2024
3badff1
Add comments for srsim splits
nguyentvan7 Jan 1, 2024
82c302f
Resolve comments
nguyentvan7 Jan 2, 2024
d6e72e8
Fix percent(1) for critmulti
nguyentvan7 Jan 2, 2024
2919a45
Fix circular read
nguyentvan7 Jan 2, 2024
201d5df
Add back char and lightCone src
nguyentvan7 Jan 2, 2024
8efc5da
Fix bug and add debug calculator
nguyentvan7 Jan 2, 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
20 changes: 13 additions & 7 deletions apps/sr-frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { CharacterProvider, DatabaseProvider } from '@genshin-optimizer/sr-ui'
import {
CalcProvider,
CharacterProvider,
DatabaseProvider,
} from '@genshin-optimizer/sr-ui'
import {
CssBaseline,
Stack,
Expand All @@ -17,12 +21,14 @@ export default function App() {
<ThemeProvider theme={theme}>
<DatabaseProvider>
<CharacterProvider>
<CssBaseline />
<Stack gap={1} pt={1}>
<CharacterSelector />
<Character />
<Database />
</Stack>
<CalcProvider>
<CssBaseline />
<Stack gap={1} pt={1}>
<CharacterSelector />
<Character />
<Database />
</Stack>
</CalcProvider>
</CharacterProvider>
</DatabaseProvider>
</ThemeProvider>
Expand Down
107 changes: 69 additions & 38 deletions apps/sr-frontend/src/app/Character.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
import { reread } from '@genshin-optimizer/pando'
import type { AscensionKey } from '@genshin-optimizer/sr-consts'
import { convert, selfTag } from '@genshin-optimizer/sr-formula'
import {
self,
selfBuff,
srCalculatorWithEntries,
} from '@genshin-optimizer/sr-formula'
import {
CharacterContext,
useCalcContext,
useCharacter,
useCharacterContext,
useCharacterReducer,
} from '@genshin-optimizer/sr-ui'
import { CardThemed } from '@genshin-optimizer/ui-common'
import { Box, CardContent, Stack, TextField, Typography } from '@mui/material'
import { Container } from '@mui/system'
import { useContext, useMemo } from 'react'
import { ExpandMore } from '@mui/icons-material'
import {
Accordion,
AccordionDetails,
AccordionSummary,
Box,
CardContent,
Container,
Stack,
TextField,
Typography,
} from '@mui/material'

export default function Character() {
const { characterKey } = useContext(CharacterContext)
const { characterKey } = useCharacterContext()
const character = useCharacter(characterKey)
const charReducer = useCharacterReducer(characterKey)

const calc = useMemo(
() =>
character &&
srCalculatorWithEntries([
selfBuff.char.lvl.add(character.level),
selfBuff.char.ascension.add(character?.ascension),
{
tag: { src: 'char' },
value: reread({ src: characterKey }),
},
]),
[character, characterKey]
)
const { calc } = useCalcContext()
const member0 = convert(selfTag, { member: 'member0', et: 'self' })

return (
<Container>
Expand All @@ -45,34 +39,71 @@ export default function Character() {
label="Level"
variant="outlined"
inputProps={{ min: 1, max: 90 }}
value={character?.level}
value={character?.level || 0}
onChange={(e) => charReducer({ level: parseInt(e.target.value) })}
/>
<TextField
type="number"
label="Ascension"
variant="outlined"
inputProps={{ min: 0, max: 6 }}
value={character?.ascension}
value={character?.ascension || 0}
onChange={(e) =>
charReducer({
ascension: parseInt(e.target.value) as AscensionKey,
})
}
/>
{(
[
['ATK', 'atk'],
['DEF', 'def'],
['HP', 'hp'],
['SPD', 'spd'],
] as const
).map(([txt, skey]) => (
<Typography key={skey}>
{txt}: {calc?.compute(self.stat[skey].src('char')).val}
</Typography>
))}
<Accordion>
<AccordionSummary expandIcon={<ExpandMore />}>
Basic stats for all chars
</AccordionSummary>
<AccordionDetails>
{(
[
['ATK', 'atk'],
['DEF', 'def'],
['HP', 'hp'],
['SPD', 'spd'],
] as const
).map(([txt, skey]) => (
<Typography key={skey}>
{txt}: {calc?.compute(member0.final[skey]).val}
</Typography>
))}
</AccordionDetails>
</Accordion>
</Stack>
<Accordion>
<AccordionSummary expandIcon={<ExpandMore />}>
All target values, if sheet is created
</AccordionSummary>
<AccordionDetails>
<Stack>
{calc?.listFormulas(member0.listing.formulas).map((read) => {
const computed = calc.compute(read)
const name = read.tag.name || read.tag.q
return (
<Box>
<Typography key={name}>
{name}: {computed.val}
</Typography>
<Accordion>
<AccordionSummary expandIcon={<ExpandMore />}>
meta for {name}
</AccordionSummary>
<AccordionDetails>
<Typography component="pre">
{JSON.stringify(computed.meta, undefined, 2)}
</Typography>{' '}
</AccordionDetails>
</Accordion>
</Box>
)
})}
</Stack>
</AccordionDetails>
</Accordion>
</CardContent>
</CardThemed>
</Container>
Expand Down
5 changes: 2 additions & 3 deletions apps/sr-frontend/src/app/CharacterSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
CharacterAutocomplete,
CharacterContext,
useCharacterContext,
} from '@genshin-optimizer/sr-ui'
import { CardThemed } from '@genshin-optimizer/ui-common'
import { CardContent, Container } from '@mui/material'
import { useContext } from 'react'

export default function CharacterSelector() {
const { characterKey, setCharacterKey } = useContext(CharacterContext)
const { characterKey, setCharacterKey } = useCharacterContext()

return (
<Container>
Expand Down
10 changes: 3 additions & 7 deletions apps/sr-frontend/src/app/Database.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SandboxStorage } from '@genshin-optimizer/database'
import { DatabaseContext } from '@genshin-optimizer/sr-ui'
import { SroDatabase } from '@genshin-optimizer/sr-db'
import { useDatabaseContext } from '@genshin-optimizer/sr-ui'
import { CardThemed, DropdownButton } from '@genshin-optimizer/ui-common'
import { range } from '@genshin-optimizer/util'
import {
Expand All @@ -12,14 +12,10 @@ import {
Typography,
} from '@mui/material'
import type { ChangeEvent } from 'react'
import { useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { useCallback, useEffect, useMemo, useState } from 'react'

export default function Database() {
const {
database: mainDB,
databases,
setDatabase,
} = useContext(DatabaseContext)
const { database: mainDB, databases, setDatabase } = useDatabaseContext()
const [index, setIndex] = useState(0)
const database = databases[index]
const current = database === mainDB
Expand Down
2 changes: 1 addition & 1 deletion apps/sr-frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node", "vite/client"]
"types": ["node", "vite/client", "object-overrides"]
},
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts", "src/**/*.tsx"]
Expand Down
2 changes: 1 addition & 1 deletion libs/pando/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": ["node", "vite/client"]
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.spec.ts", "vitest.config.ts"]
Expand Down
22 changes: 17 additions & 5 deletions libs/sr-consts/src/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ export const nonTrailblazerCharacterKeys = [
export type NonTrailblazerCharacterKey =
(typeof nonTrailblazerCharacterKeys)[number]

export const damageType = [
export const allTypeKeys = [
'Physical',
'Quantum',
'Thunder',
'Lightning',
'Ice',
'Wind',
'Fire',
'Imaginary',
] as const
export type DamageTypeKey = (typeof damageType)[number]
export type TypeKey = (typeof allTypeKeys)[number]

export const path = [
export const allPathKeys = [
'Erudition',
'Preservation',
'Abundance',
Expand All @@ -51,7 +51,7 @@ export const path = [
'Harmony',
'TheHunt',
] as const
export type PathKey = (typeof path)[number]
export type PathKey = (typeof allPathKeys)[number]

export const allTrailblazerGenderedKeys = [
'TrailblazerPhysicalM',
Expand Down Expand Up @@ -88,6 +88,18 @@ export type BonusAbilityKey = (typeof allBonusAbilityKeys)[number]
export const allStatBoostKeys = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as const
export type StatBoostKey = (typeof allStatBoostKeys)[number]

export const allEidolonKeys = [1, 2, 3, 4, 5, 6] as const
export type EidolonKey = (typeof allEidolonKeys)[number]

export const allAbilityKeys = [
'basic',
'skill',
'ult',
'talent',
'technique',
] as const
export type AbilityKey = (typeof allAbilityKeys)[number]

export function charKeyToCharLocKey(
charKey: CharacterKey
): CharacterLocationKey {
Expand Down
12 changes: 11 additions & 1 deletion libs/sr-consts/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const allStatKeys = [
'def_',
'crit_',
'crit_dmg_',
'taunt',
'brEff_',
'eff_',
'eff_res_',
Expand All @@ -27,5 +26,16 @@ export const allStatKeys = [
] as const
export type StatKey = (typeof allStatKeys)[number]

export const allTypeDmgKeys = [
'physical_dmg_',
'fire_dmg_',
'ice_dmg_',
'wind_dmg_',
'lightning_dmg_',
'quantum_dmg_',
'imaginary_dmg_',
] as const
export type TypeDmgKey = (typeof allTypeDmgKeys)[number]

export const allAscensionKeys = [0, 1, 2, 3, 4, 5, 6] as const
export type AscensionKey = (typeof allAscensionKeys)[number]
6 changes: 3 additions & 3 deletions libs/sr-dm/src/dm/character/AvatarConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { dumpFile, nameToKey } from '@genshin-optimizer/pipeline'
import type { DamageTypeKey } from '@genshin-optimizer/sr-consts'
import type { TypeKey } from '@genshin-optimizer/sr-consts'
import { objFilterKeys } from '@genshin-optimizer/util'
import { TextMapEN } from '../../TextMapUtil'
import { PROJROOT_PATH } from '../../consts'
import type { AvatarBaseTypeKey, AvatarId } from '../../mapping'
import { characterIdMap } from '../../mapping'
import { TextMapEN } from '../../TextMapUtil'
import { readDMJSON } from '../../util'
import type { HashId, MaterialValue, Value } from '../common'

Expand All @@ -16,7 +16,7 @@ export type AvatarConfig = {
AvatarVOTag: string
Rarity: AvatarRarity
JsonPath: string
DamageType: DamageTypeKey
DamageType: TypeKey
SPNeed: Value
ExpGroup: number
MaxPromotion: number
Expand Down
45 changes: 45 additions & 0 deletions libs/sr-dm/src/dm/character/AvatarRankConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { dumpFile } from '@genshin-optimizer/pipeline'
import { PROJROOT_PATH } from '../../consts'
import { readDMJSON } from '../../util'
import type { HashId, MaterialValue, Value } from '../common'
import { avatarConfig } from './AvatarConfig'

// Eidolon information
export type AvatarRankConfig = {
RankID: number // Internal Eidolon ID
Rank: number // Eidolon #1-6
Trigger: HashId
Name: string
Desc: string
IconPath: string
SkillAddLevelList: SkillAddLevelList // Info for Eidolon 3/5
RankAbility: string[] // I dunno
UnlockCost: MaterialValue
Param: Value[] // Scalings, if any
}
// { <skillId>: <# of levels increased> }
type SkillAddLevelList = Partial<Record<string, number>>

const avatarRankConfigSrc = JSON.parse(
readDMJSON('ExcelOutput/AvatarRankConfig.json')
) as Record<string, AvatarRankConfig>

// Convert to { charId: { eidolon#: config } } mapping
const avatarRankConfig = Object.fromEntries(
Object.entries(avatarConfig).map(([avatarId, avatarConfig]) => [
avatarId, // Map charId
// to { eidolon#: config }
Object.fromEntries(
avatarConfig.RankIDList.map((rankId) => [
avatarRankConfigSrc[rankId].Rank, // Map Eidolon #1-6
avatarRankConfigSrc[rankId], // to Config
])
),
])
)

dumpFile(
`${PROJROOT_PATH}/src/dm/character/AvatarRankConfig_charMapped_gen.json`,
avatarRankConfig
)
export { avatarRankConfig }
8 changes: 8 additions & 0 deletions libs/sr-dm/src/dm/character/AvatarSkillConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dumpFile } from '@genshin-optimizer/pipeline'
import type { AbilityKey } from '@genshin-optimizer/sr-consts'
import { objMap } from '@genshin-optimizer/util'
import { PROJROOT_PATH } from '../../consts'
import { readDMJSON } from '../../util'
Expand Down Expand Up @@ -42,6 +43,13 @@ export type AvatarSkillConfig = {
}

export type AttackType = 'Normal' | 'BPSkill' | 'Ultra' | 'MazeNormal' | 'Maze'
export const DmAttackTypeMap: Record<AttackType, AbilityKey> = {
Normal: 'basic',
BPSkill: 'skill',
Ultra: 'ult',
MazeNormal: 'talent',
Maze: 'technique',
}

export type SkillEffect =
| 'SingleAttack'
Expand Down
Loading