Bitsmist Frameworks
Docs » Perk

Perk

Overview

This is the base class of the Perk. All perks inherit this Perk.

Properties

info

Type:Object get

Returns an object with information about this perk. It has the following keys:

KeyTypeDescription
dependsString
Array of String
The name of the perk on which this perk depends. It is possible to specify more than one in an array.
sectionStringThe 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.
orderNumberThe 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.

The base class returns an empty object.

Methods

globalInit()

Type:Undefined static

Initializes the perk. It is called automatically once when a perk is registered using PerkPerk.register(). Normally, the perk is registered before all processing begins.

The base class does nothing.

Parameters

None.

Return Value

Undefined.


init(unit, options)

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.

The base class does nothing.

Parameters

ParameterTypeDescription
unit
Required
UnitA unit to be attached.
optionsObjectInitialization options.

Return Value

Undefined.


upgrade(unit, type, name, content)

Type:Undefined static

Upgrades the unit. The type of upgrade varies depending on the type argument.

typeDescription
“asset”Adds the asset to the unit. Specify the asset name for the “name” and content holder for the “content” parameter.
“method”Adds the method to the unit. Specify the method name for the “name” and the Function object for “the content” parameter.
“property”Adds the property to the unit. Specify the property name for the “name” and the getter/setter for the “content” parameter.
“event”Adds the event handler to the unit. Specify the event name for the “name” and the event handler Function object for the “content” parameter.
othersAdds content to the asset specified by the “name” parameter with the “content” parameter.

Paramters

ParameterTypeDescription
unit
Required
UnitThe unit to be upgraded.
type
Required
StringThe upgrade type. Valid types are “asset”, “method”, “property”, “event” and the asset names.
name
Required
StringThe name of the item to be upgraded.
content
Required
*The content of upgrade.

Return Value

Undefined.

Previous Next

© 2019-2023 Masaki Yasutake

Bitsmist Frameworks

Table of Contents

Table of Contents

  • Perk
    • Overview
    • Properties
      • info
    • Methods
      • globalInit()
      • init(unit, options)
      • upgrade(unit, type, name, content)

Introduction

  • Overview
  • Installation
  • Create a Sample Unit

Unit Explained

  • Overview
  • Properties and Methods
  • Settings
  • Loading
  • Events
  • HTML
  • CSS
  • Extending with Perks

Reference - Unit

  • Unit

Reference - Perk

  • Perk (Base Class)
  • BasicPerk
  • EventPerk
  • PerkPerk
  • SettingPerk
  • SkinPerk
  • StatusPerk
  • StylePerk
  • UnitPerk

Reference - Store

  • Store
  • ChainableStore

Reference - Utility

  • AjaxUtil
  • ClassUtil
  • URLUtil
  • Util