Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lantua committed Aug 20, 2024
1 parent 2b1a385 commit a0c8522
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
17 changes: 4 additions & 13 deletions libs/gi/formula/src/data/util/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,11 @@ export function convert<V extends Record<string, Record<string, Desc>>>(
}

// Default queries
const noName = { src: null, name: null }
export const self = convert(selfTag, { et: 'self', dst: 'all' })
export const team = convert(selfTag, {
et: 'team',
src: null,
dst: 'all',
name: null,
})
export const target = convert(selfTag, { et: 'target', src: null, name: null })
export const enemy = convert(enemyTag, {
et: 'enemy',
src: null,
dst: null,
name: null,
})
export const team = convert(selfTag, { et: 'team', dst: 'all', ...noName })
export const target = convert(selfTag, { et: 'target', ...noName })
export const enemy = convert(enemyTag, { et: 'enemy', dst: null, ...noName })

// Default tag DB keys
export const selfBuff = convert(selfTag, { et: 'self' })
Expand Down
21 changes: 6 additions & 15 deletions libs/sr/formula/src/data/util/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ export function convert<V extends Record<string, Record<string, Desc>>>(
v: V,
tag: Omit<Tag, 'qt' | 'q'>
): {
[j in 'withTag' | keyof V]: j extends 'withTag'
[j in 'withTag' | keyof V]: j extends 'withTag'
? (_: Tag) => Read
: { [k in keyof V[j]]: Read }
} {
} {
const r = reader.withTag(tag)
return r.withAll(
'qt',
Expand All @@ -172,20 +172,11 @@ export function convert<V extends Record<string, Record<string, Desc>>>(
}

// Default queries
const noName = { src: null, name: null }
export const self = convert(selfTag, { et: 'self', dst: 'all' })
export const team = convert(selfTag, {
et: 'team',
src: null,
dst: 'all',
name: null,
})
export const target = convert(selfTag, { et: 'target', src: null, name: null })
export const enemy = convert(enemyTag, {
et: 'enemy',
src: null,
dst: null,
name: null,
})
export const team = convert(selfTag, { et: 'team', dst: 'all', ...noName, })
export const target = convert(selfTag, { et: 'target', ...noName })
export const enemy = convert(enemyTag, { et: 'enemy', dst: null, ...noName, })

// Default tag DB keys
export const selfBuff = convert(selfTag, { et: 'self' })
Expand Down

0 comments on commit a0c8522

Please sign in to comment.