Intrinsic(name, opts)

A class to represent internal states that are relative to Significance

new Intrinsic(name, opts)

Creates a new intrinsic value

Parameters:
Name Type Description
name string

Name of the intrisic (e.g. hunger, pain, etc.)

opts

Extends

Members

max

maximum valume allowed for the intrinsic

min

minimim valume allowed for the intrinsic

normalizedValue

the value normalized to be a number between zero and one

positive

whether the intrisic is positive ('true') or negative ('false')

range

the number of values between min and max

Methods

static defaultConverter(val) → {number}

The default method for converting values to numbers. Mostly a wrapper for parseFloat.

Parameters:
Name Type Description
val *

The value to be converted to a number

Returns:
number -

The numeric form of val

getValue() → {*}

Returns the value of the intrinsic

Returns:
* -

The value of the intrinsic

sendEvent(type, data)

Emits an event using the specified eventClass

Parameters:
Name Type Description
type string

The event type to emit

data *

The data to emit

Overrides:

async setValue(val) → {Promise}

Set the value of the intrinsic and emit a change event if the value changed.

Parameters:
Name Type Description
val *

The value to set for the intrinsic, which is specific to the implementation of the intrinsic.

Returns:
Promise -

Returns a promise that resolves to the value of sendEvent if an event was emitted, or null if no change occurred.