feat: eslint 적용 및 관련 코드 일괄 수정
This commit is contained in:
@@ -2,10 +2,7 @@ import { JosaUtil } from '@sammo-ts/common';
|
||||
|
||||
import type { General, GeneralTriggerState } from '@sammo-ts/logic/domain/entities.js';
|
||||
import { TriggerPriority } from '@sammo-ts/logic/triggers/core.js';
|
||||
import {
|
||||
BaseGeneralTrigger,
|
||||
type GeneralTriggerContext,
|
||||
} from '@sammo-ts/logic/triggers/general.js';
|
||||
import { BaseGeneralTrigger, type GeneralTriggerContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
|
||||
const HEAL_PROBABILITY = 0.5;
|
||||
const MIN_HEAL_INJURY = 10;
|
||||
@@ -20,15 +17,13 @@ const resolveCityGenerals = <TriggerState extends GeneralTriggerState>(
|
||||
}
|
||||
const list = worldView.listGeneralsByCity
|
||||
? worldView.listGeneralsByCity(general.cityId)
|
||||
: worldView.listGenerals().filter(
|
||||
(candidate) => candidate.cityId === general.cityId
|
||||
);
|
||||
: worldView.listGenerals().filter((candidate) => candidate.cityId === general.cityId);
|
||||
return list.filter((candidate) => candidate.id !== general.id);
|
||||
};
|
||||
|
||||
// 의술 특기의 도시 치료 트리거.
|
||||
export class CheUisulCityHealTrigger<
|
||||
TriggerState extends GeneralTriggerState = GeneralTriggerState
|
||||
TriggerState extends GeneralTriggerState = GeneralTriggerState,
|
||||
> extends BaseGeneralTrigger<TriggerState> {
|
||||
public readonly priority = TriggerPriority.Begin + 10;
|
||||
|
||||
@@ -36,10 +31,7 @@ export class CheUisulCityHealTrigger<
|
||||
super(general);
|
||||
}
|
||||
|
||||
action(
|
||||
context: GeneralTriggerContext<TriggerState>,
|
||||
env: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
action(context: GeneralTriggerContext<TriggerState>, env: Record<string, unknown>): Record<string, unknown> {
|
||||
const general = context.general;
|
||||
const rng = context.rng;
|
||||
const logger = context.log;
|
||||
@@ -50,17 +42,15 @@ export class CheUisulCityHealTrigger<
|
||||
logger?.push('<C>의술</>을 펼쳐 스스로 치료합니다!');
|
||||
}
|
||||
|
||||
const candidates = resolveCityGenerals(general, context).filter(
|
||||
(candidate) => {
|
||||
if (candidate.injury <= MIN_HEAL_INJURY) {
|
||||
return false;
|
||||
}
|
||||
if (general.nationId === 0) {
|
||||
return candidate.nationId === 0;
|
||||
}
|
||||
return true;
|
||||
const candidates = resolveCityGenerals(general, context).filter((candidate) => {
|
||||
if (candidate.injury <= MIN_HEAL_INJURY) {
|
||||
return false;
|
||||
}
|
||||
);
|
||||
if (general.nationId === 0) {
|
||||
return candidate.nationId === 0;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const healed = candidates.filter(() => rng.nextBool(HEAL_PROBABILITY));
|
||||
|
||||
@@ -75,14 +65,10 @@ export class CheUisulCityHealTrigger<
|
||||
const firstName = healed[0]?.name ?? '장수';
|
||||
if (healed.length === 1) {
|
||||
const josa = JosaUtil.pick(firstName, '을');
|
||||
logger?.push(
|
||||
`<C>의술</>을 펼쳐 도시의 장수 <Y>${firstName}</>${josa} 치료합니다!`
|
||||
);
|
||||
logger?.push(`<C>의술</>을 펼쳐 도시의 장수 <Y>${firstName}</>${josa} 치료합니다!`);
|
||||
} else {
|
||||
const otherCount = healed.length - 1;
|
||||
logger?.push(
|
||||
`<C>의술</>을 펼쳐 도시의 장수들 <Y>${firstName}</> 외 <C>${otherCount}</>명을 치료합니다!`
|
||||
);
|
||||
logger?.push(`<C>의술</>을 펼쳐 도시의 장수들 <Y>${firstName}</> 외 <C>${otherCount}</>명을 치료합니다!`);
|
||||
}
|
||||
|
||||
return env;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { JosaUtil } from '@sammo-ts/common';
|
||||
import { TriggerPriority } from '@sammo-ts/logic/triggers/core.js';
|
||||
import {
|
||||
BaseGeneralTrigger,
|
||||
type GeneralTriggerContext,
|
||||
} from '@sammo-ts/logic/triggers/general.js';
|
||||
import { BaseGeneralTrigger, type GeneralTriggerContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { General } from '@sammo-ts/logic/domain/entities.js';
|
||||
|
||||
interface ItemHealOptions {
|
||||
@@ -24,10 +21,7 @@ export class CheItemHealTrigger extends BaseGeneralTrigger {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
action(
|
||||
context: GeneralTriggerContext,
|
||||
env: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
action(context: GeneralTriggerContext, env: Record<string, unknown>): Record<string, unknown> {
|
||||
const { general } = context;
|
||||
if (general.role.items.item !== this.options.itemKey) {
|
||||
return env;
|
||||
@@ -40,9 +34,7 @@ export class CheItemHealTrigger extends BaseGeneralTrigger {
|
||||
context.skill.activate('pre.부상경감', 'pre.치료');
|
||||
|
||||
const josa = JosaUtil.pick(this.options.itemRawName, '을');
|
||||
context.log?.push(
|
||||
`<C>${this.options.itemName}</>${josa} 사용하여 치료합니다!`
|
||||
);
|
||||
context.log?.push(`<C>${this.options.itemName}</>${josa} 사용하여 치료합니다!`);
|
||||
|
||||
if (this.options.consume()) {
|
||||
general.role.items.item = null;
|
||||
|
||||
Reference in New Issue
Block a user