diff --git a/packages/logic/src/items/che_명마_07_백상.ts b/packages/logic/src/items/che_명마_07_백상.ts index 6d81155..5b6e877 100644 --- a/packages/logic/src/items/che_명마_07_백상.ts +++ b/packages/logic/src/items/che_명마_07_백상.ts @@ -4,12 +4,14 @@ import type { WarActionContext } from '@sammo-ts/logic/war/actions.js'; import { createStatItemModule } from './base.js'; import type { ItemModule } from './types.js'; +const STAT_VALUE = 7; + const baseModule = createStatItemModule({ key: 'che_명마_07_백상', rawName: '백상', slot: 'horse', statName: 'leadership', - statValue: 7, + statValue: STAT_VALUE, cost: 200, buyable: false, reqSecu: 0, @@ -20,22 +22,20 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'killRice') { - return (newValue as number) * 1.1; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'leadership' && typeof value === 'number') { + newValue = value + STAT_VALUE; } - if (statName === 'initWarPhase') { - return (newValue as number) - 1; + if (statName === 'killRice' && typeof newValue === 'number') { + return newValue * 1.1; + } + if (statName === 'initWarPhase' && typeof newValue === 'number') { + return newValue - 1; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_명마_12_옥란백용구.ts b/packages/logic/src/items/che_명마_12_옥란백용구.ts index d290655..0bbb548 100644 --- a/packages/logic/src/items/che_명마_12_옥란백용구.ts +++ b/packages/logic/src/items/che_명마_12_옥란백용구.ts @@ -4,12 +4,14 @@ import type { WarActionContext } from '@sammo-ts/logic/war/actions.js'; import { createStatItemModule } from './base.js'; import type { ItemModule } from './types.js'; +const STAT_VALUE = 12; + const baseModule = createStatItemModule({ key: 'che_명마_12_옥란백용구', rawName: '옥란백용구', slot: 'horse', statName: 'leadership', - statValue: 12, + statValue: STAT_VALUE, cost: 200, buyable: false, reqSecu: 0, @@ -22,20 +24,18 @@ export const itemModule: ItemModule = { onCalcStat: function ( context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warAvoidRatio') { - const { leadership } = (context as unknown as GeneralActionContext).general.stats; - const crewL = (context as unknown as GeneralActionContext).general.crew / 100; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'leadership' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warAvoidRatio' && typeof newValue === 'number') { + const { leadership } = context.general.stats; + const crewL = context.general.crew / 100; const boost = (1 - crewL / leadership) * 0.5; - return (newValue as number) + Math.min(Math.max(boost, 0), 0.5); + return newValue + Math.min(Math.max(boost, 0), 0.5); } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_부적_태현청생부.ts b/packages/logic/src/items/che_부적_태현청생부.ts index 80261ab..6fda3c6 100644 --- a/packages/logic/src/items/che_부적_태현청생부.ts +++ b/packages/logic/src/items/che_부적_태현청생부.ts @@ -21,10 +21,10 @@ export const itemModule: ItemModule = { onCalcStat: function ( _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown - ): unknown { - if (statName === ('injuryProb' as unknown as WarStatName)) { - return (value as number) - 1; + value: number | [number, number] + ): number | [number, number] { + if (statName === 'injuryProb' && typeof value === 'number') { + return value - 1; } return value; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_01_효경전.ts b/packages/logic/src/items/che_서적_01_효경전.ts index 7bfefd7..630f4fa 100644 --- a/packages/logic/src/items/che_서적_01_효경전.ts +++ b/packages/logic/src/items/che_서적_01_효경전.ts @@ -21,19 +21,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.01; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.01; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_02_회남자.ts b/packages/logic/src/items/che_서적_02_회남자.ts index c69de67..897fa5d 100644 --- a/packages/logic/src/items/che_서적_02_회남자.ts +++ b/packages/logic/src/items/che_서적_02_회남자.ts @@ -21,19 +21,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.01; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.01; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_04_건상역주.ts b/packages/logic/src/items/che_서적_04_건상역주.ts index 1663ebf..85b519c 100644 --- a/packages/logic/src/items/che_서적_04_건상역주.ts +++ b/packages/logic/src/items/che_서적_04_건상역주.ts @@ -21,19 +21,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.02; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.02; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_05_여씨춘추.ts b/packages/logic/src/items/che_서적_05_여씨춘추.ts index 12d9809..1cc8f21 100644 --- a/packages/logic/src/items/che_서적_05_여씨춘추.ts +++ b/packages/logic/src/items/che_서적_05_여씨춘추.ts @@ -21,19 +21,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.03; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.03; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_06_사민월령.ts b/packages/logic/src/items/che_서적_06_사민월령.ts index e91ce1f..59d9362 100644 --- a/packages/logic/src/items/che_서적_06_사민월령.ts +++ b/packages/logic/src/items/che_서적_06_사민월령.ts @@ -21,19 +21,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.03; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.03; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_서적_07_위료자.ts b/packages/logic/src/items/che_서적_07_위료자.ts index a0e1dd5..5c00e5a 100644 --- a/packages/logic/src/items/che_서적_07_위료자.ts +++ b/packages/logic/src/items/che_서적_07_위료자.ts @@ -4,12 +4,14 @@ import type { WarActionContext } from '@sammo-ts/logic/war/actions.js'; import { createStatItemModule } from './base.js'; import type { ItemModule } from './types.js'; +const STAT_VALUE = 7; + const baseModule = createStatItemModule({ key: 'che_서적_07_위료자', rawName: '위료자', slot: 'book', statName: 'intelligence', - statValue: 7, + statValue: STAT_VALUE, cost: 200, buyable: false, reqSecu: 0, @@ -20,19 +22,17 @@ const baseModule = createStatItemModule({ export const itemModule: ItemModule = { ...baseModule, onCalcStat: function ( - context: GeneralActionContext | WarActionContext, + _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown, - aux?: unknown - ): unknown { - const newValue = baseModule.onCalcStat!( - context as unknown as GeneralActionContext, - statName as unknown as GeneralStatName, - value as unknown as number, - aux - ); - if (statName === 'warMagicTrialProb') { - return (newValue as number) + 0.2; + value: number | [number, number], + _aux?: unknown + ): number | [number, number] { + let newValue: number | [number, number] = value; + if (statName === 'intelligence' && typeof value === 'number') { + newValue = value + STAT_VALUE; + } + if (statName === 'warMagicTrialProb' && typeof newValue === 'number') { + return newValue + 0.2; } return newValue; } as NonNullable, diff --git a/packages/logic/src/items/che_숙련_동작.ts b/packages/logic/src/items/che_숙련_동작.ts index fd30c86..f0c22a9 100644 --- a/packages/logic/src/items/che_숙련_동작.ts +++ b/packages/logic/src/items/che_숙련_동작.ts @@ -19,10 +19,10 @@ export const itemModule: ItemModule = { onCalcStat: function ( _context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown - ): unknown { - if (statName === ('addDex' as unknown as GeneralStatName)) { - return (value as number) * 1.2; + value: number | [number, number] + ): number | [number, number] { + if (statName === 'addDex' && typeof value === 'number') { + return value * 1.2; } return value; } as NonNullable, diff --git a/packages/logic/src/items/che_징병_낙주.ts b/packages/logic/src/items/che_징병_낙주.ts index a06688b..006f5c6 100644 --- a/packages/logic/src/items/che_징병_낙주.ts +++ b/packages/logic/src/items/che_징병_낙주.ts @@ -28,10 +28,10 @@ export const itemModule: ItemModule = { onCalcStat: function ( context: GeneralActionContext | WarActionContext, statName: GeneralStatName | WarStatName, - value: unknown - ): unknown { - if (statName === 'leadership') { - return (value as number) + (context as unknown as GeneralActionContext).general.stats.leadership * 0.15; + value: number | [number, number] + ): number | [number, number] { + if (statName === 'leadership' && typeof value === 'number') { + return value + context.general.stats.leadership * 0.15; } return value; } as NonNullable, diff --git a/packages/logic/src/triggers/types.ts b/packages/logic/src/triggers/types.ts index e472c94..82529d4 100644 --- a/packages/logic/src/triggers/types.ts +++ b/packages/logic/src/triggers/types.ts @@ -44,9 +44,11 @@ export type WarStatName = | 'bonusAtmos' | 'warCriticalRatio' | 'warAvoidRatio' + | 'injuryProb' | 'killRice' | 'criticalDamageRange' | 'warMagicSuccessDamage' | 'warMagicTrialProb' | 'warMagicSuccessProb' + | 'addDex' | `dex${number}`;