User logic nodes state. UserCore subclass.

Constructor

Methods

inline checkTimers ():Void

Checks timers on all nodes for this user and fails the nodes if needed.

inline clearSkipFlags ():Void

inline cloneData ():Dynamic

inline diffData (prevData:Dynamic):Void

dump (noBadge:Bool):List<Dynamic>

Stores user logic data into a list of anonymous objects for client response.

Parameters:

noBadge

If set to true, will skip nodes that give out badge as a reward.

Returns:

List of anonymous objects.

enterTree (treeInfo:LogicTreeCore):UserLogicTreeCore

Enters first node in that tree if all checks succeed.

Parameters:

treeInfo

Tree info.

Returns:

User tree instance. Returns null, if tree is completed or cannot be entered.

inline getTree (id:Int):UserLogicTreeCore

Returns user logic tree state by its ID.

Parameters:

id

Tree ID.

Returns:

User logic tree instance.

inline hasCompleted (id:Int):Bool

Returns true if the user has completed this tree.

Returns:

True if the tree is completed. False otherwise.

trigger (type:String, params:_LogicTriggerParams):Void

Activates node trigger, checks for node completion and completes the node if all completion requirements are met. Also handles node failure.

Usage examples:

// increases a counter
c.user.logic.trigger('counter',
  { name: 'money.given' });

// increases a counter by an amount
c.user.logic.trigger('counter',
  { name: 'money.given', amount: 10 });

// sets a counter to an amount
c.user.logic.trigger('counter',
  { name: 'money.given', action: 'set', amount: 10 });

// increases a conditional counter if "val" condition is met
c.user.logic.trigger('condCounter',
  { name: 'level.finishTime', val: finishTime });

// increases a conditional counter by an amount if "val" condition is met
c.user.logic.trigger('condCounter',
  { name: 'level.finishTime', val: finishTime, amount: 10 });

// sets a conditional counter to an amount if "val" condition is met
c.user.logic.trigger('condCounter',
  { name: 'level.finishTime', val: finishTime, action: 'set', amount: 10 });

// notifies nodes that an attribute has changed
c.user.logic.trigger('attr', { name: 'reputation' });

Parameters:

type

Trigger type. One of the following: attr, counter, condCounter, client or one of project-specific trigger types (handled by core/logic.trigger method subscription).

params

Trigger parameters.

triggerSingle (treeID:Int, type:String, params:_LogicTriggerParams):Void

Activates trigger for a single given tree, checks for node completion and completes the node if all completion requirements are met. Also handles node failure.

Parameters:

treeID

Tree ID. Logic tree has to be active.

type

Trigger type. Check documentation for UserLogicCore.trigger().

params

Trigger parameters.