UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

165 lines 4.18 kB
export default Stat; /** * Modifiable statistic. * Allows non-destructive linear arithmetic. * Useful when we wish to be able to reverse part or the whole of the computation * * Main purpose of the class is to facilitate implementation of RPG-like stats, such as maximum health, or armor. * These stats can then be modified by various skills, equipment and effects. Each such modification will be added as a separate {@link LinearModifier} and can be reversed by removing the modifier. */ declare class Stat extends Number { /** * * @param {number} input * @param {List<LinearModifier>}modifiers * @returns {number} */ static applyModifiers(input: number, modifiers: List<LinearModifier>): number; /** * @param {number} [value] * @constructor */ constructor(value?: number); /** * Unique identifier of a stat, such a health, armor etc. * @type {number} */ id: number; /** * List of modifiers. * Order has no influence on final computed value * @private * @readonly * @type {List<LinearModifier>} */ private readonly __modifiers; /** * Computed value will be pass through this function before being exposed. * Useful for rounding and clamping. * see {@link Stat.Process} for some options. * @type {function(number): number} */ postprocess: (arg0: number) => number; /** * Base value that modifiers will affect * @type {Vector1} */ base: Vector1; /** * Final computed value. Do not modify this directly * @type {Vector1} */ value: Vector1; /** * * @returns {Signal<LinearModifier>} */ get onModifierAdded(): Signal<LinearModifier>; /** * * @returns {Signal<LinearModifier>} */ get onModifierRemoved(): Signal<LinearModifier>; /** * Remove all modifiers from the stat */ resetModifiers(): void; /** * * @returns {string} */ toString(): string; /** * * @returns {number} */ getValue(): number; updateValue(): void; /** * * @returns {number} */ getBaseValue(): number; /** * * @param {number} v */ setBaseValue(v: number): void; /** * NOTE: do not modify result * @return {LinearModifier[]} */ getModifiers(): LinearModifier[]; /** * * @param {LinearModifier} mod */ addModifier(mod: LinearModifier): void; /** * * @param {LinearModifier} mod * @return {boolean} */ hasModifier(mod: LinearModifier): boolean; /** * * @param {LinearModifier} mod * @returns {boolean} */ removeModifier(mod: LinearModifier): boolean; /** * * @param {Stat} other * @returns {boolean} */ equals(other: Stat): boolean; /** * * @param {Stat} other */ copy(other: Stat): void; /** * Copy base value from another stat * @param {Stat} other */ copyBase(other: Stat): void; /** * * @param {function(number):number} f * @param {number} v */ setBaseFromParametricFunction(f: (arg0: number) => number, v: number): void; /** * @param {Stat} other */ addNonTransientModifiersFromStat(other: Stat): void; toJSON(): { base: number; modifiers: any; }; fromJSON(json: any): void; /** * * @returns {Signal} */ get onChanged(): Signal; /** * @readonly * @type {boolean} */ readonly isStat: boolean; } declare namespace Stat { namespace Process { export function ROUND_DOWN(v: number): number; export function NONE(v: any): any; export function clampMin(value: number): (arg0: number) => number; export function clampMax(value: number): (arg0: number) => number; export { chain }; } } import Vector1 from "../../geom/Vector1.js"; import LinearModifier from "./LinearModifier.js"; import List from "../../collection/list/List.js"; import { chain } from "../../function/chain.js"; //# sourceMappingURL=Stat.d.ts.map