import { PlayerCtor, RpgWritableSignal } from '@rpgjs/common'; import { RpgPlayer } from './Player'; export interface StateData { id?: string; name?: string; addStates?: StateApplication[]; removeStates?: StateApplication[]; [key: string]: unknown; } export type StateClass = { new (): StateData; }; export type StateInput = StateClass | StateData | string; export interface StateApplication { state: StateClass | string; rate: number; } export interface StateEfficiency { state: StateInput; rate: number; } /** * State Manager Mixin * * Provides state management capabilities to any class. This mixin handles * player states (buffs/debuffs), state defense from equipment, and state * efficiency modifiers. It manages the complete state system including * application, removal, and resistance mechanics. * * @param Base - The base class to extend with state management * @returns Extended class with state management methods * * @example * ```ts * class MyPlayer extends WithStateManager(BasePlayer) { * constructor() { * super(); * // State system is automatically initialized * } * } * * const player = new MyPlayer(); * player.addState(Paralyze); * console.log(player.getState(Paralyze)); * ``` */ export declare function WithStateManager(Base: TBase): TBase; /** * Interface for State Manager functionality * * Provides state management capabilities including state defense, efficiency modifiers, * and state application/removal. This interface defines the public API of the StateManager mixin. */ export interface IStateManager { /** * Gets the defensive capabilities against various states from equipped items * * @returns Array of state defense objects with rate and state properties */ statesDefense: StateEfficiency[]; /** * Manages the player's state efficiency modifiers * * @returns Signal containing array of state efficiency objects */ statesEfficiency: RpgWritableSignal; /** * Apply states to a player from skill or item effects * * @param player - The target player to apply states to * @param states - Object containing arrays of states to add or remove */ applyStates(player: RpgPlayer, states: { addStates?: StateApplication[]; removeStates?: StateApplication[]; }): void; /** * Get a state to the player. Returns null if the state is not present * * @param stateClass - The state class constructor or state ID to search for * @returns The state instance if found, null otherwise */ getState(stateClass: StateClass | string): StateData | undefined; /** * Adds a state to the player * * @param stateClass - The state class constructor or state ID to apply * @param chance - Probability of successful application (0-1, default 1) * @returns The state instance if successfully applied, null if already present * @throws StateLog.addFailed if the chance roll fails */ addState(stateClass: StateClass | string, chance?: number): object | null; /** * Remove a state to the player * * @param stateClass - The state class constructor or state ID to remove * @param chance - Probability of successful removal (0-1, default 1) * @throws StateLog.removeFailed if the chance roll fails * @throws StateLog.notApplied if the state is not currently active */ removeState(stateClass: StateClass | string, chance?: number): void; /** * Find state efficiency modifier for a specific state class * * @param stateClass - The state class to find efficiency for * @returns The efficiency object if found, undefined otherwise */ findStateEfficiency(stateClass: StateClass): StateEfficiency | undefined; }