Skip to content

Commit

Permalink
relic set/substat editors
Browse files Browse the repository at this point in the history
  • Loading branch information
frzyc committed Nov 11, 2024
1 parent 7a4f55e commit 7984d7e
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 33 deletions.
7 changes: 5 additions & 2 deletions libs/sr/db/src/Database/DataManagers/BuildTcDataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function initCharTC(characterKey: CharacterKey): IBuildTc {
substats: {
type: 'max',
stats: objKeyMap(allRelicSubStatKeys, () => 0),
rarity: 5,
},
sets: {},
},
Expand Down Expand Up @@ -143,7 +144,7 @@ function validateCharTCRelic(relic: unknown): IBuildTc['relic'] | undefined {
if (typeof relic !== 'object') return undefined
let {
slots,
substats: { type, stats },
substats: { type, stats, rarity },
sets,
} = relic as IBuildTc['relic']
const _slots = validateCharTCRelicSlots(slots)
Expand All @@ -154,11 +155,13 @@ function validateCharTCRelic(relic: unknown): IBuildTc['relic'] | undefined {
stats = objKeyMap(allRelicSubStatKeys, (k) =>
typeof stats[k] === 'number' ? stats[k] : 0
)
if (typeof rarity !== 'number' || !allRelicRarityKeys.includes(rarity))
rarity = 5

if (typeof sets !== 'object') sets = {}
// TODO: validate sets

return { slots, substats: { type, stats }, sets }
return { slots, substats: { type, stats, rarity }, sets }
}
function validateCharTCRelicSlots(
slots: unknown
Expand Down
3 changes: 2 additions & 1 deletion libs/sr/db/src/Interfaces/IBuildTc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { ILightCone } from '@genshin-optimizer/sr/srod'
export type BuildTcRelicSlot = {
level: number
statKey: RelicMainStatKey
rarity:RelicRarityKey
rarity: RelicRarityKey
}
export type BuildTCLightCone = Omit<ILightCone, 'location' | 'lock'>
export interface IBuildTc {
Expand All @@ -26,6 +26,7 @@ export interface IBuildTc {
substats: {
type: RelicSubstatTypeKey
stats: Record<RelicSubStatKey, number>
rarity: RelicRarityKey
}
sets: Partial<Record<RelicSetKey, 2 | 4>>
}
Expand Down
Loading

0 comments on commit 7984d7e

Please sign in to comment.