Constructor
#
new WildMagicAPI()
Namespaces
- templates
Methods
#
(async) generateChatData() → {Object}
Helper function for creating the chat message data for a given surge result
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
info.surgeRoll |
Roll
|
|
|
Roll object representing the test roll for surging |
info.targetRoll |
Roll
|
|
|
Roll object representing the upper bound for a successful surge |
info.surgeOccured |
boolean
|
<optional>
|
false
|
whether a surge occured or not |
info.spellLevel |
number
|
<optional>
|
0
|
spell level that triggered this surge |
info.extraText |
string
|
<optional>
|
''
|
Additional string placed between spell level and "spell" in output. Ex. 'as a level 9 spell is cast' |
Returns:
- ChatMessage data needed to construct the surge results.
-
Type
-
Object
#
isTidesCharged(actor) → {boolean}
Determines if the actor has a charged use of Tides remaining. In the event of both
a resource and feature item being used to track charges, this will indicate true (charged)
if either the resource or item has uses left.
Parameters:
| Name |
Type |
Description |
actor |
Actor5e
|
actor to query for charged tides |
Returns:
indicates if tides is charged (true) or not (false)
-
Type
-
boolean
#
registerHandler(label, handler, preCheckopt) → {boolean}
Registers the provided handler with the wild magic system. If done during the
'wmsRegister' hook, will additionally add this to the actor special traits
list. If done afterwords, can be invoked by directly calling 'surge'.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
label |
string
|
|
|
Unique identifier for this handler. Also used as the
displayed handler name in the special traits menu |
handler |
function
|
|
|
signature: async function handler(actor, surgeData).
Given surgeData produced by the preCheck function, determines if a surge occurs
(typically by rolling under a target number). |
preCheck |
function
|
<optional>
|
WildMagic.slotExpended
|
signature
function preCheck(actor, update). Given an actor pre-update and the update to
be applied, returns an object containing information for its paired handler OR
false if a surge cannot occur (ex. the update was not expending a spell slot). |
Returns:
indicates successful addition
-
Type
-
boolean
#
surge(actor, surgeOptionsopt) → {Promise}
Force a surge to occur for the desired actor
Parameters:
| Name |
Type |
Attributes |
Description |
actor |
Actor5e
|
|
which character will surge |
surgeOptions |
Object
|
<optional>
|
optional information to customize this actor's surge process and results
Properties
| Name |
Type |
Description |
data |
Object
|
information needed by this actor's surge handler. Often {spellLevel: N}. |
handler |
string
|
function
|
Either the handler's key (string) or a custom handler function. |
|
- See:
-
DnDWildMagic.registerHandler for details on the handler function signature.
Returns:
Resulting information returned by the handler function used to carry out any needed operations resulting from this type of surge.
-
Type
-
Promise
#
tidesRechargeUpdate(actor) → {Object|Object|Array.<Object>}
Generates the needed actor and item updates for recharging the configured Tides feature/resource
Parameters:
| Name |
Type |
Description |
actor |
Actor5e
|
actor for which to generate the recharge update information. |
Returns:
-
updates - resulting update information
-
Type
-
Object
-
updates.actor - actor update data
-
Type
-
Object
-
updates.item - array of item update data
-
Type
-
Array.<Object>
#
unregisterHandler(label) → {boolean}
Unregisters a given handler and preCheck pair based on the handler's key (label)
Parameters:
| Name |
Type |
Description |
label |
string
|
name of handler and preCheck pair to remove |
Returns:
indicates successful removal of handler
-
Type
-
boolean