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,77 @@
|
||||
import type { GeneralActionContext } from '@sammo-ts/logic/triggers/general.js';
|
||||
import type { WarActionContext } from '@sammo-ts/logic/war/actions.js';
|
||||
import type { ItemModule, ItemSlot } from './types.js';
|
||||
|
||||
const resolveStatLabel = (statName: string): string => {
|
||||
switch (statName) {
|
||||
case 'leadership':
|
||||
return '통솔';
|
||||
case 'strength':
|
||||
return '무력';
|
||||
case 'intelligence':
|
||||
return '지력';
|
||||
default:
|
||||
return statName;
|
||||
}
|
||||
};
|
||||
|
||||
export interface StatItemOptions {
|
||||
key: string;
|
||||
rawName: string;
|
||||
slot: ItemSlot;
|
||||
statName: 'leadership' | 'strength' | 'intelligence';
|
||||
statValue: number;
|
||||
cost: number | null;
|
||||
buyable: boolean;
|
||||
reqSecu: number;
|
||||
unique?: boolean;
|
||||
extraInfo?: string;
|
||||
}
|
||||
|
||||
export const createStatItemModule = (
|
||||
options: StatItemOptions
|
||||
): ItemModule => {
|
||||
const statLabel = resolveStatLabel(options.statName);
|
||||
const name = `${options.rawName}(+${options.statValue})`;
|
||||
const baseInfo = `${statLabel} +${options.statValue}`;
|
||||
const info = options.extraInfo ? `${baseInfo}<br>${options.extraInfo}` : baseInfo;
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext,
|
||||
statName: string,
|
||||
value: number,
|
||||
_aux?: unknown
|
||||
): number;
|
||||
function onCalcStat(
|
||||
_context: WarActionContext,
|
||||
statName: string,
|
||||
value: number | [number, number],
|
||||
_aux?: unknown
|
||||
): number | [number, number];
|
||||
function onCalcStat(
|
||||
_context: GeneralActionContext | WarActionContext,
|
||||
statName: string,
|
||||
value: number | [number, number]
|
||||
): number | [number, number] {
|
||||
if (statName !== options.statName) {
|
||||
return value;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value;
|
||||
}
|
||||
return value + options.statValue;
|
||||
}
|
||||
|
||||
return {
|
||||
key: options.key,
|
||||
rawName: options.rawName,
|
||||
name,
|
||||
info,
|
||||
slot: options.slot,
|
||||
cost: options.cost,
|
||||
buyable: options.buyable,
|
||||
consumable: false,
|
||||
reqSecu: options.reqSecu,
|
||||
unique: options.unique ?? false,
|
||||
onCalcStat,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user