feat: update stat handling by introducing specific types for GeneralStatName and WarStatName across various modules

This commit is contained in:
2026-01-03 09:49:46 +00:00
parent d1522ff450
commit 395d937fd5
11 changed files with 170 additions and 71 deletions
+5 -4
View File
@@ -1,8 +1,9 @@
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
import type { GeneralStatName, WarStatName } from '@sammo-ts/logic/triggers/types.js';
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
import type { ItemModule, ItemSlot } from './types.js';
const resolveStatLabel = (statName: string): string => {
const resolveStatLabel = (statName: GeneralStatName): string => {
switch (statName) {
case 'leadership':
return '통솔';
@@ -37,19 +38,19 @@ export const createStatItemModule = (
const info = options.extraInfo ? `${baseInfo}<br>${options.extraInfo}` : baseInfo;
function onCalcStat(
_context: GeneralActionContext,
statName: string,
statName: GeneralStatName,
value: number,
_aux?: unknown
): number;
function onCalcStat(
_context: WarActionContext,
statName: string,
statName: WarStatName,
value: number | [number, number],
_aux?: unknown
): number | [number, number];
function onCalcStat(
_context: GeneralActionContext | WarActionContext,
statName: string,
statName: GeneralStatName | WarStatName,
value: number | [number, number]
): number | [number, number] {
if (statName !== options.statName) {