feat(items): add new item modules and enhance item functionality
- Introduced various item modules including '흑색마', '사륜거', '단궁', '동호비궁', '도기', '변도론', '전론', and '환약'. - Implemented stat item modules to enhance general and war action contexts. - Added triggers for item healing and sniping actions during battles. - Enhanced item management with new utility functions for inventory handling. - Updated the item registry and loader to support new items and their functionalities. - Improved the overall structure of item-related code for better maintainability and scalability.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
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 type { General } from '@sammo-ts/logic/domain/entities.js';
|
||||
|
||||
interface ItemHealOptions {
|
||||
itemKey: string;
|
||||
itemName: string;
|
||||
itemRawName: string;
|
||||
injuryTarget: number;
|
||||
consume: () => boolean;
|
||||
}
|
||||
|
||||
// 아이템(환약 등)으로 턴 실행 전 부상을 회복하는 트리거.
|
||||
export class CheItemHealTrigger extends BaseGeneralTrigger {
|
||||
public readonly priority = TriggerPriority.Begin - 10;
|
||||
private readonly options: ItemHealOptions;
|
||||
|
||||
constructor(general: General, options: ItemHealOptions) {
|
||||
super(general);
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
action(
|
||||
context: GeneralTriggerContext,
|
||||
env: Record<string, unknown>
|
||||
): Record<string, unknown> {
|
||||
const { general } = context;
|
||||
if (general.role.items.item !== this.options.itemKey) {
|
||||
return env;
|
||||
}
|
||||
if (general.injury < this.options.injuryTarget) {
|
||||
return env;
|
||||
}
|
||||
|
||||
general.injury = 0;
|
||||
context.skill.activate('pre.부상경감', 'pre.치료');
|
||||
|
||||
const josa = JosaUtil.pick(this.options.itemRawName, '을');
|
||||
context.log?.push(
|
||||
`<C>${this.options.itemName}</>${josa} 사용하여 치료합니다!`
|
||||
);
|
||||
|
||||
if (this.options.consume()) {
|
||||
general.role.items.item = null;
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user