This is the base class of the Perks. All perks inherit this Perk.
Unit-specific settings are written in the “perk” section.
{ "perk": { "options": { "apply": [String, ...], } } }
Type:Object
get
Returns an object with information about this perk. It has the following keys:
Key | Type | Description |
---|---|---|
depends | String/ Array of String | The name of the perk on which this perk depends. It is possible to specify more than one in an array. |
sectionName | String | The section name of the settings this perk will use. If this section name is present in the settings, the corresponding perk will be attached to the unit. |
order | Number | The priority level of the perk. The lower the number, the higher the priority. Perk initialization and event handlers are executed according to this priority order. |
Each perk needs to override this property and return proper information.
Type:Promise
get
The promise that is resolved when a perk is ready.
Type:Function
Create a handler. The handler must have been previously registered with registerHandler().
Parameter | Type | Description |
---|---|---|
handlerName Required | String | The name of a handler to create. |
…args | Array of Arguments | The arguments passed to a handler's constructor. |
A created handler instance.
Type:Perk
static
Returns a perk specified with the perkName argument. The perk must have been previously registered with registerPerk().
Parameter | Type | Description |
---|---|---|
perkName Required | String | The name of a perk to retrieve. |
Perk.
Type:Undefined
static
Initializes the perk. It is called automatically once when a perk is registered using registerPerk(). Normally, the perk is registered before any other processing begins.
Each perk needs to override this method and do its processing if necessary.
None.
Undefined.
Type:Undefined
Asynchronous
static
Initializes the unit. It is called when attaching a perk to a unit. Normally, it is called automatically when the settings are loaded. The unit to be attached is passed as an argument.
Each perk needs to override this method and do its processing if necessary.
Parameter | Type | Description |
---|---|---|
unit Required | Unit | A unit to be attached. |
options | Object | Initialization options. |
Undefined.
Type:Undefined
Registers a handler with the perk. The handler is a class that is used by a perk to handle actual processing.
Parameter | Type | Description |
---|---|---|
handler Required | Function | The handler to register. |
perkName | String | The perk with which a handler registers. |
None.
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.
Parameter | Type | Description |
---|---|---|
perk Required | Perk | The perk to register. |
Undefined.
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 unit's perk asset. When attaching, each park's init() method is called and the unit is upgraded. If the specified perk is already attached, nothing is done.
Parameter | Type | Description |
---|---|---|
perk Required | Perk | The perk to attach. |
options | Object | Options. Passed to the init() method of the attaching perk. |
Undefined.
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.
Parameter | Type | Description |
---|---|---|
options Required | Object | Options. Has the following keys: |
“settings” | Object | The unit settings. |
Undefined.