feat: 여러 아이템의 onCalcStat 함수 개선 및 통일성 있는 statValue 상수화
This commit is contained in:
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -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<ItemModule['onCalcStat']>,
|
||||
|
||||
@@ -44,9 +44,11 @@ export type WarStatName =
|
||||
| 'bonusAtmos'
|
||||
| 'warCriticalRatio'
|
||||
| 'warAvoidRatio'
|
||||
| 'injuryProb'
|
||||
| 'killRice'
|
||||
| 'criticalDamageRange'
|
||||
| 'warMagicSuccessDamage'
|
||||
| 'warMagicTrialProb'
|
||||
| 'warMagicSuccessProb'
|
||||
| 'addDex'
|
||||
| `dex${number}`;
|
||||
|
||||
Reference in New Issue
Block a user