Skip to content

Commit

Permalink
Merge e3edd76 into 350a791
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentvan7 authored Dec 13, 2023
2 parents 350a791 + e3edd76 commit d39a77e
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 19 deletions.
16 changes: 8 additions & 8 deletions libs/sr-assets/src/gen/chars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import Serval from './Serval'
import SilverWolf from './SilverWolf'
import Sushang from './Sushang'
import Tingyun from './Tingyun'
import TrailBlazerFireF from './TrailBlazerFireF'
import TrailBlazerFireM from './TrailBlazerFireM'
import TrailBlazerPhysicalF from './TrailBlazerPhysicalF'
import TrailBlazerPhysicalM from './TrailBlazerPhysicalM'
import TrailblazerFireF from './TrailblazerFireF'
import TrailblazerFireM from './TrailblazerFireM'
import TrailblazerPhysicalF from './TrailblazerPhysicalF'
import TrailblazerPhysicalM from './TrailblazerPhysicalM'
import Welt from './Welt'
import Yanqing from './Yanqing'

Expand Down Expand Up @@ -53,10 +53,10 @@ const data = {
SilverWolf,
Sushang,
Tingyun,
TrailBlazerFireF,
TrailBlazerFireM,
TrailBlazerPhysicalF,
TrailBlazerPhysicalM,
TrailblazerFireF,
TrailblazerFireM,
TrailblazerPhysicalF,
TrailblazerPhysicalM,
Welt,
Yanqing,
} as const
Expand Down
25 changes: 20 additions & 5 deletions libs/sr-consts/src/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,30 @@ export const path = [
export type PathKey = (typeof path)[number]

export const allTrailblazerGeneredKeys = [
'TrailBlazerPhysicalM',
'TrailBlazerPhysicalF',
'TrailBlazerFireM',
'TrailBlazerFireF',
'TrailblazerPhysicalM',
'TrailblazerPhysicalF',
'TrailblazerFireM',
'TrailblazerFireF',
] as const
export type TrailBlazerGeneredKey = (typeof allTrailblazerGeneredKeys)[number]
export type TrailblazerGeneredKey = (typeof allTrailblazerGeneredKeys)[number]

export const allCharacterKeys = [
...nonTrailblazerCharacterKeys,
...allTrailblazerGeneredKeys,
] as const
export type CharacterKey = (typeof allCharacterKeys)[number]

export const allCharacterLocationKeys = [
...nonTrailblazerCharacterKeys,
'Trailblazer',
] as const
export type CharacterLocationKey = (typeof allCharacterLocationKeys)[number]

export const allLocationKeys = [...allCharacterLocationKeys, ''] as const
export type LocationKey = (typeof allLocationKeys)[number]

export const allBonusAbilityKeys = [1, 2, 3] as const
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]
3 changes: 3 additions & 0 deletions libs/sr-consts/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ export const allStatKeys = [
'imaginary_dmg_',
] as const
export type StatKey = (typeof allStatKeys)[number]

export const allAscensionKeys = [0, 1, 2, 3, 4, 5, 6] as const
export type AscensionKey = (typeof allAscensionKeys)[number]
3 changes: 3 additions & 0 deletions libs/sr-consts/src/lightcone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ export const allLightConeKeys = [
] as const

export type LightConeKey = (typeof allLightConeKeys)[number]

export const allSuperimposeKeys = [0, 1, 2, 3, 4, 5] as const
export type SuperimposeKey = (typeof allSuperimposeKeys)[number]
18 changes: 18 additions & 0 deletions libs/sr-db/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/sr-db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# sr-db

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test sr-db` to execute the unit tests via [Jest](https://jestjs.io).
24 changes: 24 additions & 0 deletions libs/sr-db/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "sr-db",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/sr-db/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/sr-db/**/*.ts"]
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../coverage/libs/sr-db"
}
}
},
"tags": []
}
21 changes: 21 additions & 0 deletions libs/sr-db/src/ICharacter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type {
AscensionKey,
BonusAbilityKey,
CharacterKey,
StatBoostKey,
} from '@genshin-optimizer/sr-consts'

export interface ICharacter {
key: CharacterKey
level: number
eidolon: number
ascension: AscensionKey
traces: {
basic: number
skill: number
ult: number
talent: number
bonusAbilities: Partial<Record<BonusAbilityKey, boolean>>
statBoosts: Partial<Record<StatBoostKey, boolean>>
}
}
15 changes: 15 additions & 0 deletions libs/sr-db/src/ILightCone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type {
AscensionKey,
LightConeKey,
SuperimposeKey,
LocationKey,
} from '@genshin-optimizer/sr-consts'

export interface ILightCone {
key: LightConeKey
level: number
ascension: AscensionKey
superimpose: SuperimposeKey
location: LocationKey // where '' means not equipped
lock: boolean
}
24 changes: 24 additions & 0 deletions libs/sr-db/src/IRelic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type {
LocationKey,
RarityKey,
RelicMainStatKey,
RelicSetKey,
RelicSlotKey,
RelicSubStatKey,
} from '@genshin-optimizer/sr-consts'

export interface IRelic {
setKey: RelicSetKey
slotKey: RelicSlotKey
level: number
rarity: RarityKey
mainStatKey: RelicMainStatKey
location: LocationKey
lock: boolean
substats: ISubstat[]
}

export interface ISubstat {
key: RelicSubStatKey | ''
value: number
}
12 changes: 12 additions & 0 deletions libs/sr-db/src/ISRODatabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { ICharacter } from './ICharacter'
import type { ILightCone } from './ILightCone'
import type { IRelic } from './IRelic'

export type ISRODatabase = {
format: 'SRO'
source: string
version: 1
characters?: ICharacter[]
relics?: IRelic[]
lightcones?: ILightCone[]
}
1 change: 1 addition & 0 deletions libs/sr-db/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/sr-db'
22 changes: 22 additions & 0 deletions libs/sr-db/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions libs/sr-db/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
25 changes: 25 additions & 0 deletions libs/sr-db/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
]
},
"include": [
"vite.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
24 changes: 24 additions & 0 deletions libs/sr-db/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite'

import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'

export default defineConfig({
cacheDir: '../../node_modules/.vite/sr-db',

plugins: [nxViteTsPaths()],

// Uncomment this if you are using workers.
// worker: {
// plugins: [ nxViteTsPaths() ],
// },

test: {
globals: true,
cache: {
dir: '../../node_modules/.vitest',
},
environment: 'node',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
},
})
12 changes: 6 additions & 6 deletions libs/sr-dm/src/mapping/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type {
NonTrailblazerCharacterKey,
PathKey,
RarityKey,
TrailBlazerGeneredKey,
TrailblazerGeneredKey,
} from '@genshin-optimizer/sr-consts'
import type { AvatarRarity } from '../dm'

export const characterIdMap: Record<
string,
NonTrailblazerCharacterKey | TrailBlazerGeneredKey
NonTrailblazerCharacterKey | TrailblazerGeneredKey
> = {
'1001': 'March7th',
'1002': 'DanHeng',
Expand All @@ -35,10 +35,10 @@ export const characterIdMap: Record<
'1206': 'Sushang',
'1209': 'Yanqing',
'1211': 'Bailu',
'8001': 'TrailBlazerPhysicalM',
'8002': 'TrailBlazerPhysicalF',
'8003': 'TrailBlazerFireM',
'8004': 'TrailBlazerFireF',
'8001': 'TrailblazerPhysicalM',
'8002': 'TrailblazerPhysicalF',
'8003': 'TrailblazerFireM',
'8004': 'TrailblazerFireF',
} as const
export type AvatarId = keyof typeof characterIdMap

Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
],
"@genshin-optimizer/sr-assets": ["libs/sr-assets/src/index.ts"],
"@genshin-optimizer/sr-consts": ["libs/sr-consts/src/index.ts"],
"@genshin-optimizer/sr-db": ["libs/sr-db/src/index.ts"],
"@genshin-optimizer/sr-dm": ["libs/sr-dm/src/index.ts"],
"@genshin-optimizer/sr-formula": ["libs/sr-formula/src/index.ts"],
"@genshin-optimizer/sr-stats": ["libs/sr-stats/src/index.ts"],
Expand Down

0 comments on commit d39a77e

Please sign in to comment.