API for managing missions and their objectives.
properties
Mission(settings) – optionally use settings obj to set one or more top-level properties (causes objectives to be cleared)
.name – name of mission (string)
.date – date on which the mission starts (date object)
.id – mission id (string)
.labels – a list of labels that the mission relies on (each one must exist in labels.ini)
.status – true = mission successful, false = mission failed, undefined/null = in progress (default: undefined)
.timeLimit – get/set time limit, null 0 = timed out, any other falsey = no time limit
.countDown – object with numeric refs (times in seconds until 0) and string values (audio files to play)
.onTimeout() – triggered when mission timer runs out
.onSuccessstart() – triggered when start the mission successful
.onFailureonStart() – triggered when mission failedstarts
.setupsuccessful() – function to set-up game before finish the mission startssuccessfully
.teardownfailed() – function to clear-up the game after the mission endsfinish the mission as failed
.onFinish(success) – triggered when mission successful
.objective(obj) – add an objective
...
.<objectiveID> = objective object
.id – title – string
.type – see constants
.title – id – string
.status – true = objective achieved, false = objective failed, undefined/null = in progress (default)
.struct – array of structures required to complete objective (auto-sets .tasks to num structures)
.tasks – total number of tasks
...
.inc([data]) – increment progress, optionally pass in data for event handler
.optional – required – mandatory objective optional? true/false (default: falsetrue)
.hidden – objective hidden? true/false (default: false)
.enabled – objective enabled? true/false (default: true) – cannot progress objective while disbled
.requires – array of prerequisite objectives
...
.onDisabled() – triggered when the objective is disabled
Constants
Mission.PRIMARY_OBJECTIVE
Mission.SECONDARY_OBJECTIVE
Mission.TERTIARY_OBJECTIVE – defaults required:false
Mission.SECRET_OBJECTIVE – defaults required:false, hidden:true