User quests. UserCore subclass.

Constructor

Fields

read only block:Block

User data block link.

Methods

check (uq:UserQuestCore):String

Checks if this quest is ready to be completed or timed out.

Parameters:

uq

User quest instance.

Returns:

Operation error code: ok - all conditions are met, quest can be completed. notCompleted - some conditions are not met. failure - timed quest failure due to completion timer.

dynamic checkHook (uq:UserQuestCore, r:Dynamic):Int

This method is used to handle additional quest completion requirements. As an alternative you can use core/quest.check method subscription.

Parameters:

uq

User quest instance.

r

Full completion requirement object record.

Returns:

1 if this quest meets this completion requirement. 0 if this quest does not meet this completion requirement. -1 if this hook does not handle this completion requirement.

inline checkTimers ():Void

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

inline complete (uq:UserQuestCore):Void

Forces quest completion without any checks. Gives out rewards and executes UserQuestsCore.completePost() hook.

Parameters:

uq

User quest instance.

dynamic completePost (uq:UserQuestCore, isSuccess:Bool):Void

This method is executed after quest completion.

Parameters:

uq

User quest instance.

isSuccess

If set to true, the quest was completed successfully.

dump (noBadge:Bool):List<Dynamic>

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

Parameters:

noBadge

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

Returns:

List of anonymous objects.

dynamic dumpCheckHook (r:Dynamic):Dynamic

This method is used to add additional quest completion requirements to client response in UserQuestsCore.dump().

Parameters:

r

Full completion requirement object record.

Returns:

Anonymous object to add to user quest completion requirements. Returns null, if this hook does not handle this requirement type.

dynamic dumpRequiresHook (r:Dynamic):Dynamic

This method is used to add additional quest requirements to client response in UserQuestsCore.dump().

Parameters:

r

Full requirement object record.

Returns:

Anonymous object to add to quest requirements. Returns null, if this hook does not handle this requirement type.

dynamic dumpResultHook (r:Dynamic):Dynamic

This method is used to add additional quest results to client response in UserQuestsCore.dump().

Parameters:

r

Full result object record.

Returns:

Anonymous object to add to quest results. Returns null, if this hook does not handle this result type.

get (id:Int):UserQuestCore

Returns user quest by quest ID.

Parameters:

id

Quest ID.

Returns:

User quest instance.

inline getAmount ():Int

Returns amount of active quests the user has.

Returns:

Amount of active quests.

getDaily ():UserQuestCore

Returns current daily quest.

Returns:

User quest instance.

dynamic getDailyChainID ():Int

This method is used to get chain ID that contains daily quests for this user.

Returns:

Chain ID. If -1 is returned, this user will not receive a daily quest.

receive (id:Int, ?markAsUpdated:Bool):UserQuestCore

Receives a given quest. This is a low-level function that does not do any checks for quest requirements. In most cases UserChainsCore.receiveNext() is preferable.

Parameters:

id

Quest ID.

markAsUpdated

If null or true, will mark user block as updated.

Returns:

New user quest instance.

remove (uq:UserQuestCore):Void

Removes a quest from user quests. Mainly used for resetting daily quests at the start of new day. If used on a normal quest, something should be done about the user chain that contains it.

Parameters:

uq

User quest instance.

dynamic requiresHook (r:Dynamic):Int

This method is used to handle additional project-specific quest requirements. Will be given full requirement record as an argument. As an alternative you can use core/quest.requires method subscription.

Parameters:

r

Full requirement object record.

Returns:

1 if the user meets this requirement. 0 if the user does not meet this requirement. -1 if this hook does not handle this requirement.

dynamic resultHook (r:Dynamic):Int

This method is used to handle additional quest completion results. As an alternative you can use core/quest.result method subscription.

Parameters:

r

Full completion result object record.

Returns:

Return value is currently unused.

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

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

Usage examples:

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

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

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

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

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

Parameters:

type

Trigger type. One of the following: attr, counter, condCounter, cvar or one of project-specific trigger types (handled by UserQuestsCore.triggerHook() and core/quest.trigger method subscription).

params

Trigger parameters.

dynamic triggerHook (uq:UserQuestCore, type:String, params:_QuestTriggerParams):Int

This method is used to handle additional project-specific quest triggers. Should set any necessary quest variables if this quest accepted this trigger. As an alternative you can use core/quest.trigger method subscription.

Parameters:

uq

User quest instance.

type

Trigger type.

params

Trigger parameters.

Returns:

1 if the trigger was accepted by this quest and completed by the handler. 0 if the trigger was accepted by this quest but the trigger parameters were not met. -1 if this hook does not handle this trigger.