Table of Contents

PerkPerk

Inherits:Perk Section:perk Priority:0

Overview

PerkPerk grants units perk-related functions such as attaching perks.

Settings

Format - Unit

Unit-specific settings are written in the “perk” section.

{
    "perk": {
        "options": {
            "apply": [String, ...],
        }
    }
}

"apply"

Type:Array of String

The names of the perks to be applied to the unit. The perks must already exist in the system.

Methods

register(perk)

Type:Undefined

Registers the perk with the system. A perk cannot be attached unless it is registered. The perk's global initialization process is executed when registered.

Parameters

ParameterTypeDescription
perkPerkThe perk to register.

Return Value

Undefined.

Inventory

perks

Type:Object Target:Instance

This object holds the perks attached to this unit. Each item has the following keys:

ParameterTypeDescription
objectPerkThe perk attached.

Spells

attach

Type:Undefined Target:Unit

Attaches the perk passed in the argument to the unit. If the perk depends on other perks, dependent perks are attached first. The attached perk is added to the perks in unit's inventory. When attaching, each park's init() method is called and the unit is upgraded. If the specified perk is already attached, nothing is done.

Parameters

ParameterTypeDescription
perkPerkThe perk to attach.
optionsObjectOptions. Passed to the init() method of the attaching perk.

Return Value

Undefined.


attachPerks

Type:Undefined Target:Unit

Attaches all the perks depending on the settings using the attachl spell. The order of attaching is based on the priority number of each perk, the lower the number the earlier.

Parameters

ParameterTypeDescription
optionsObjectOptions. Has the following keys:
“settings”ObjectThe unit settings.

Return Value

Undefined.