UNPKG

warscript

Version:

A typescript library for Warcraft III using Warpack.

42 lines (41 loc) 2.23 kB
/// <reference types="@typescript-to-lua/language-extensions" /> /** @noSelfInFile */ import { Unit } from "../unit"; import { AbilityTypeId } from "../../object-data/entry/ability-type"; export type UnitBonusId<Brand extends string = any> = number & { readonly __unitBonusId: unique symbol; readonly __unitBonusIdBrand: Brand; }; export type UnitArmorBonusId = UnitBonusId<"armor">; export type UnitAttackSpeedFactorBonusId = UnitBonusId<"attackSpeedFactor">; export type UnitMovementSpeedFactorBonusId = UnitBonusId<"movementSpeedFactor">; export type UnitDamageBonusId = UnitBonusId<"damage">; export type UnitReceivedDamageFactorBonusId = UnitBonusId<"receivedDamageFactor">; export type UnitBonusType<Id extends UnitBonusId = UnitBonusId> = ({ abilityTypeId: AbilityTypeId; field: jabilityintegerlevelfield; integer: true; } | { abilityTypeId: AbilityTypeId; field: jabilityreallevelfield; integer: false; } | { abilityTypeId?: undefined; valueByUnit: LuaMap<Unit, number>; }) & { reduce: (this: void, array: number[]) => number; initialValue: number; readonly __unitBonusTypeId?: Id; }; export declare namespace UnitBonusType { const ARMOR: UnitBonusType<UnitArmorBonusId>; const ATTACK_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>; const MOVEMENT_SPEED_FACTOR: UnitBonusType<UnitAttackSpeedFactorBonusId>; const DAMAGE: UnitBonusType<UnitDamageBonusId>; const RECEIVED_DAMAGE_FACTOR: UnitBonusType<UnitReceivedDamageFactorBonusId>; } export declare const addUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, value: number) => Id; export declare const removeUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => boolean; export declare const updateUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id, value: number) => boolean; export declare const addOrUpdateOrRemoveUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id | undefined, value: number) => Id | undefined; export declare const getUnitBonus: <Id extends UnitBonusId<any>>(unit: Unit, bonusType: UnitBonusType<Id>, id: Id) => number;