feat: eslint 적용 및 관련 코드 일괄 수정

This commit is contained in:
2026-01-05 15:46:47 +00:00
parent cb312f02b3
commit c965b1120f
387 changed files with 39808 additions and 38800 deletions
+1 -3
View File
@@ -29,9 +29,7 @@ export interface StatItemOptions {
extraInfo?: string;
}
export const createStatItemModule = (
options: StatItemOptions
): ItemModule => {
export const createStatItemModule = (options: StatItemOptions): ItemModule => {
const statLabel = resolveStatLabel(options.statName);
const name = `${options.rawName}(+${options.statValue})`;
const baseInfo = `${statLabel} +${options.statValue}`;
@@ -1,14 +1,9 @@
import { BaseWarUnitTrigger, WarTriggerCaller } from '@sammo-ts/logic/war/triggers.js';
import {
CheSnipingActivateTrigger,
CheSnipingAttemptTrigger,
} from '@sammo-ts/logic/war/triggers/che_저격.js';
import { CheSnipingActivateTrigger, CheSnipingAttemptTrigger } from '@sammo-ts/logic/war/triggers/che_저격.js';
import { createStatItemModule } from './base.js';
import type { ItemModule } from './types.js';
const raiseType =
BaseWarUnitTrigger.TYPE_ITEM +
BaseWarUnitTrigger.TYPE_DEDUP_TYPE_BASE * 102;
const raiseType = BaseWarUnitTrigger.TYPE_ITEM + BaseWarUnitTrigger.TYPE_DEDUP_TYPE_BASE * 102;
const baseModule = createStatItemModule({
key: 'che_무기_02_단궁',
@@ -29,13 +24,7 @@ export const itemModule: ItemModule = {
return null;
}
return new WarTriggerCaller(
new CheSnipingAttemptTrigger(
context.unit,
raiseType,
0.01,
10,
30
),
new CheSnipingAttemptTrigger(context.unit, raiseType, 0.01, 10, 30),
new CheSnipingActivateTrigger(context.unit, raiseType)
);
},
@@ -1,14 +1,9 @@
import { BaseWarUnitTrigger, WarTriggerCaller } from '@sammo-ts/logic/war/triggers.js';
import {
CheSnipingActivateTrigger,
CheSnipingAttemptTrigger,
} from '@sammo-ts/logic/war/triggers/che_저격.js';
import { CheSnipingActivateTrigger, CheSnipingAttemptTrigger } from '@sammo-ts/logic/war/triggers/che_저격.js';
import { createStatItemModule } from './base.js';
import type { ItemModule } from './types.js';
const raiseType =
BaseWarUnitTrigger.TYPE_ITEM +
BaseWarUnitTrigger.TYPE_DEDUP_TYPE_BASE * 109;
const raiseType = BaseWarUnitTrigger.TYPE_ITEM + BaseWarUnitTrigger.TYPE_DEDUP_TYPE_BASE * 109;
const baseModule = createStatItemModule({
key: 'che_무기_09_동호비궁',
@@ -30,14 +25,7 @@ export const itemModule: ItemModule = {
return null;
}
return new WarTriggerCaller(
new CheSnipingAttemptTrigger(
context.unit,
raiseType,
0.2,
20,
40,
20
),
new CheSnipingAttemptTrigger(context.unit, raiseType, 0.2, 20, 40, 20),
new CheSnipingActivateTrigger(context.unit, raiseType)
);
},
@@ -10,8 +10,7 @@ export const itemModule: ItemModule = {
key: ITEM_KEY,
rawName: '도기',
name: '도기(보물)',
info:
'[개인] 판매 시 장수 소지금과 국고에 금, 쌀 중 하나를 추가 (총 +10,000, 2년마다 +5,000)',
info: '[개인] 판매 시 장수 소지금과 국고에 금, 쌀 중 하나를 추가 (총 +10,000, 2년마다 +5,000)',
slot: 'item',
cost: 200,
buyable: false,
@@ -56,9 +55,7 @@ export const itemModule: ItemModule = {
const josa = JosaUtil.pick('도기', '을');
context.log?.push(
`<C>${itemModule.name}</>${josa} 판매하여 ${resName} <C>${score.toLocaleString(
'en-US'
)}</>을 보충합니다.`
`<C>${itemModule.name}</>${josa} 판매하여 ${resName} <C>${score.toLocaleString('en-US')}</>을 보충합니다.`
);
return aux;
},
@@ -18,8 +18,7 @@ export const itemModule: ItemModule = {
unique: false,
getPreTurnExecuteTriggerList: (context) => {
const target = context.general.triggerState.meta['use_treatment'];
const injuryTarget =
typeof target === 'number' && Number.isFinite(target) ? target : 10;
const injuryTarget = typeof target === 'number' && Number.isFinite(target) ? target : 10;
return new GeneralTriggerCaller(
new CheItemHealTrigger(context.general, {
injuryTarget,
+17 -40
View File
@@ -1,9 +1,6 @@
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
import type { GeneralActionModule } from '@sammo-ts/logic/triggers/general-action.js';
import {
GeneralTriggerCaller,
type GeneralActionContext,
} from '@sammo-ts/logic/triggers/general.js';
import { GeneralTriggerCaller, type GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
import type {
GeneralStatName,
TriggerActionPhase,
@@ -47,15 +44,12 @@ const defaultImporters: Record<ItemKey, ItemImporter> = {
che_보물_도기: async () => import('./che_보물_도기.js'),
};
export const isItemKey = (value: string): value is ItemKey =>
ITEM_KEYS.includes(value as ItemKey);
export const isItemKey = (value: string): value is ItemKey => ITEM_KEYS.includes(value as ItemKey);
export class ItemLoader {
private readonly cache = new Map<ItemKey, Promise<ItemModule>>();
constructor(
private readonly importers: Record<ItemKey, ItemImporter> = defaultImporters
) {}
constructor(private readonly importers: Record<ItemKey, ItemImporter> = defaultImporters) {}
async load(key: ItemKey): Promise<ItemModule> {
const cached = this.cache.get(key);
@@ -72,9 +66,7 @@ export class ItemLoader {
}
const resolved = module.itemModule;
if (resolved.key !== key) {
throw new Error(
`Item key mismatch: expected ${key}, got ${resolved.key}`
);
throw new Error(`Item key mismatch: expected ${key}, got ${resolved.key}`);
}
return resolved;
});
@@ -99,13 +91,12 @@ export const loadItemModules = async (
return modules;
};
export type ItemModuleRegistry<
TriggerState extends GeneralTriggerState = GeneralTriggerState
> = Map<string, ItemModule<TriggerState>>;
export type ItemModuleRegistry<TriggerState extends GeneralTriggerState = GeneralTriggerState> = Map<
string,
ItemModule<TriggerState>
>;
export const createItemModuleRegistry = <
TriggerState extends GeneralTriggerState = GeneralTriggerState
>(
export const createItemModuleRegistry = <TriggerState extends GeneralTriggerState = GeneralTriggerState>(
modules: ItemModule<TriggerState>[]
): ItemModuleRegistry<TriggerState> => {
const registry: ItemModuleRegistry<TriggerState> = new Map();
@@ -116,13 +107,11 @@ export const createItemModuleRegistry = <
};
class ItemGeneralActionRouter<
TriggerState extends GeneralTriggerState = GeneralTriggerState
TriggerState extends GeneralTriggerState = GeneralTriggerState,
> implements GeneralActionModule<TriggerState> {
constructor(private readonly registry: ItemModuleRegistry<TriggerState>) {}
private resolveModules(
context: GeneralActionContext<TriggerState>
): Array<ItemModule<TriggerState>> {
private resolveModules(context: GeneralActionContext<TriggerState>): Array<ItemModule<TriggerState>> {
const keys = listEquippedItemKeys(context.general);
const modules: Array<ItemModule<TriggerState>> = [];
for (const key of keys) {
@@ -248,13 +237,11 @@ class ItemGeneralActionRouter<
}
class ItemWarActionRouter<
TriggerState extends GeneralTriggerState = GeneralTriggerState
TriggerState extends GeneralTriggerState = GeneralTriggerState,
> implements WarActionModule<TriggerState> {
constructor(private readonly registry: ItemModuleRegistry<TriggerState>) {}
private resolveModules(
context: WarActionContext<TriggerState>
): Array<ItemModule<TriggerState>> {
private resolveModules(context: WarActionContext<TriggerState>): Array<ItemModule<TriggerState>> {
const keys = listEquippedItemKeys(context.general);
const modules: Array<ItemModule<TriggerState>> = [];
for (const key of keys) {
@@ -266,9 +253,7 @@ class ItemWarActionRouter<
return modules;
}
getBattleInitTriggerList(
context: WarActionContext<TriggerState>
): WarTriggerCaller | null {
getBattleInitTriggerList(context: WarActionContext<TriggerState>): WarTriggerCaller | null {
const caller = new WarTriggerCaller();
for (const module of this.resolveModules(context)) {
const triggers = module.getBattleInitTriggerList?.(context);
@@ -279,9 +264,7 @@ class ItemWarActionRouter<
return caller.isEmpty() ? null : caller;
}
getBattlePhaseTriggerList(
context: WarActionContext<TriggerState>
): WarTriggerCaller | null {
getBattlePhaseTriggerList(context: WarActionContext<TriggerState>): WarTriggerCaller | null {
const caller = new WarTriggerCaller();
for (const module of this.resolveModules(context)) {
const triggers = module.getBattlePhaseTriggerList?.(context);
@@ -335,11 +318,7 @@ class ItemWarActionRouter<
if (!module.getWarPowerMultiplier) {
continue;
}
const [attMul, defMul] = module.getWarPowerMultiplier(
context,
unit,
oppose
);
const [attMul, defMul] = module.getWarPowerMultiplier(context, unit, oppose);
attack *= attMul;
defence *= defMul;
}
@@ -347,9 +326,7 @@ class ItemWarActionRouter<
}
}
export const createItemActionModules = <
TriggerState extends GeneralTriggerState = GeneralTriggerState
>(
export const createItemActionModules = <TriggerState extends GeneralTriggerState = GeneralTriggerState>(
registry: ItemModuleRegistry<TriggerState>
): { general: GeneralActionModule<TriggerState>[]; war: WarActionModule<TriggerState>[] } => ({
general: [new ItemGeneralActionRouter(registry)],
+7 -28
View File
@@ -1,8 +1,5 @@
import type { GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
import type {
GeneralActionContext,
GeneralTriggerCaller,
} from '@sammo-ts/logic/triggers/general.js';
import type { GeneralActionContext, GeneralTriggerCaller } from '@sammo-ts/logic/triggers/general.js';
import type {
GeneralStatName,
TriggerActionPhase,
@@ -20,9 +17,7 @@ import type { WarUnit } from '@sammo-ts/logic/war/units.js';
export type ItemSlot = 'horse' | 'weapon' | 'book' | 'item';
export interface ItemModule<
TriggerState extends GeneralTriggerState = GeneralTriggerState
> {
export interface ItemModule<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
key: string;
name: string;
rawName: string;
@@ -47,12 +42,7 @@ export interface ItemModule<
): number;
onCalcStat?: {
(
context: GeneralActionContext<TriggerState>,
statName: GeneralStatName,
value: number,
aux?: unknown
): number;
(context: GeneralActionContext<TriggerState>, statName: GeneralStatName, value: number, aux?: unknown): number;
(
context: WarActionContext<TriggerState>,
statName: WarStatName,
@@ -62,12 +52,7 @@ export interface ItemModule<
};
onCalcOpposeStat?: {
(
context: GeneralActionContext<TriggerState>,
statName: GeneralStatName,
value: number,
aux?: unknown
): number;
(context: GeneralActionContext<TriggerState>, statName: GeneralStatName, value: number, aux?: unknown): number;
(
context: WarActionContext<TriggerState>,
statName: WarStatName,
@@ -96,13 +81,9 @@ export interface ItemModule<
aux?: Record<string, unknown> | null
): Record<string, unknown> | null;
getBattleInitTriggerList?(
context: WarActionContext<TriggerState>
): WarTriggerCaller | null;
getBattleInitTriggerList?(context: WarActionContext<TriggerState>): WarTriggerCaller | null;
getBattlePhaseTriggerList?(
context: WarActionContext<TriggerState>
): WarTriggerCaller | null;
getBattlePhaseTriggerList?(context: WarActionContext<TriggerState>): WarTriggerCaller | null;
getWarPowerMultiplier?(
context: WarActionContext<TriggerState>,
@@ -111,8 +92,6 @@ export interface ItemModule<
): [number, number];
}
export interface ItemModuleExport<
TriggerState extends GeneralTriggerState = GeneralTriggerState
> {
export interface ItemModuleExport<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
itemModule: ItemModule<TriggerState>;
}
+8 -25
View File
@@ -1,8 +1,5 @@
import type { ScenarioConfig } from '@sammo-ts/logic/scenario/types.js';
import type {
General,
GeneralTriggerState,
} from '@sammo-ts/logic/domain/entities.js';
import type { General, GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
import type { ItemModule } from './types.js';
const ITEM_REMAIN_PREFIX = 'itemRemain:';
@@ -24,15 +21,11 @@ const toBoolean = (value: unknown): boolean => {
export const isInventoryEnabled = (config: ScenarioConfig): boolean => {
const constConfig = config.const ?? {};
return toBoolean(
constConfig['allowInventory'] ??
constConfig['inventoryEnabled'] ??
constConfig['enableInventory']
constConfig['allowInventory'] ?? constConfig['inventoryEnabled'] ?? constConfig['enableInventory']
);
};
export const listEquippedItemKeys = <
TriggerState extends GeneralTriggerState
>(
export const listEquippedItemKeys = <TriggerState extends GeneralTriggerState>(
general: General<TriggerState>
): string[] => {
const items = [
@@ -53,21 +46,15 @@ export const listEquippedItemKeys = <
return result;
};
export const getItemRemain = <
TriggerState extends GeneralTriggerState
>(
export const getItemRemain = <TriggerState extends GeneralTriggerState>(
general: General<TriggerState>,
itemKey: string
): number | null => {
const value = general.triggerState.counters[
`${ITEM_REMAIN_PREFIX}${itemKey}`
];
const value = general.triggerState.counters[`${ITEM_REMAIN_PREFIX}${itemKey}`];
return typeof value === 'number' && value > 0 ? value : null;
};
export const setItemRemain = <
TriggerState extends GeneralTriggerState
>(
export const setItemRemain = <TriggerState extends GeneralTriggerState>(
general: General<TriggerState>,
itemKey: string,
remain: number | null
@@ -80,9 +67,7 @@ export const setItemRemain = <
general.triggerState.counters[key] = remain;
};
export const consumeItemRemain = <
TriggerState extends GeneralTriggerState
>(
export const consumeItemRemain = <TriggerState extends GeneralTriggerState>(
general: General<TriggerState>,
itemKey: string,
fallbackRemain = 1
@@ -96,9 +81,7 @@ export const consumeItemRemain = <
return true;
};
export const canAcquireItem = <
TriggerState extends GeneralTriggerState
>(options: {
export const canAcquireItem = <TriggerState extends GeneralTriggerState>(options: {
general: General<TriggerState>;
item: ItemModule;
config: ScenarioConfig;