Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lantua committed Aug 19, 2024
1 parent c5f818a commit 9be16fb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
6 changes: 2 additions & 4 deletions libs/gi/formula/src/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const emptyInfo: Info = Object.freeze({ conds: Object.freeze({}) })
const { arithmetic } = calculation

type MemRec<V> = Partial<Record<Member, V>>
/// conds[dst][src][sheet][name]
type CondInfo = MemRec<MemRec<Partial<Record<Sheet, Record<string, number>>>>>

export type CalcMeta = PartialMeta & Info
Expand All @@ -20,10 +21,7 @@ export type PartialMeta = {
op: 'const' | 'sum' | 'prod' | 'min' | 'max' | 'sumfrac' | 'res'
ops: CalcResult<number, PartialMeta>[]
}
type Info = {
/// conds[dst][src][sheet][name]
conds: CondInfo
}
type Info = { conds: CondInfo }

export class Calculator extends Base<CalcMeta> {
override computeCustom(val: any[], op: string): any {
Expand Down
6 changes: 1 addition & 5 deletions libs/gi/formula/src/data/common/conds.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { allBoolConditionals } from '../util'

export const { enemyFrozen } = allBoolConditionals('static', 'both')
export const {
hasShield,
nearbyDendro1, // Burning, Quicken, Bloom
nearbyDendro2, // Aggravate, Spread, Hyperbloom, Burgeon
} = allBoolConditionals('static', 'dst')
export const { hasShield } = allBoolConditionals('static', 'dst')
10 changes: 8 additions & 2 deletions libs/gi/formula/src/data/common/resonance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { cmpGE } from '@genshin-optimizer/pando/engine'
import { register, team, teamBuff } from '../util'
import { enemyFrozen, hasShield, nearbyDendro1, nearbyDendro2 } from './conds'
import { allBoolConditionals, register, team, teamBuff } from '../util'
import { enemyFrozen, hasShield } from './conds'

const count = team.common.count

// CAUTION: the names cannot collide with other 'static' conditionals on other sheets
export const {
nearbyDendro1, // Burning, Quicken, Bloom
nearbyDendro2, // Aggravate, Spread, Hyperbloom, Burgeon
} = allBoolConditionals('static', 'dst')

export default register(
'reso',
teamBuff.premod.atk_.add(cmpGE(count.pyro, 2, 0.25)),
Expand Down
6 changes: 2 additions & 4 deletions libs/sr/formula/src/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const emptyInfo: Info = Object.freeze({ conds: Object.freeze({}) })
const { arithmetic } = calculation

type MemRec<V> = Partial<Record<Member, V>>
/// conds[dst][src][sheet][name]
type CondInfo = MemRec<MemRec<Partial<Record<Sheet, Record<string, number>>>>>

export type CalcMeta = PartialMeta & Info
Expand All @@ -20,10 +21,7 @@ export type PartialMeta = {
op: 'const' | 'sum' | 'prod' | 'min' | 'max' | 'sumfrac' | 'res'
ops: CalcResult<number, PartialMeta>[]
}
type Info = {
/// conds[dst][src][sheet][name]
conds: CondInfo
}
type Info = { conds: CondInfo }

export class Calculator extends Base<CalcMeta> {
override computeMeta(
Expand Down

0 comments on commit 9be16fb

Please sign in to comment.