package objective

Package objective is the list of things the player is asked to do in a mission: each has a title, a text, a state (active, done, failed) and, if you want, a progress such as "3 of 5".

objective.Add("gate", "Open the gate", "Find the key in the tower.", true)
objective.Add("chest", "Find the chest", "Optional.", false)
objective.WinWhenPrimariesDone(true)
...
objective.Complete("gate")

A primary objective decides the mission when WinWhenPrimariesDone is on: all of the primaries done ends it with the outcome "victory", and any one of them failed with "defeat". A secondary objective (primary false) is only shown. The panel in the game shows the list, new and finished objectives are announced with a sound, and the list is part of the game state: it is saved, replayed and the same on every computer.

Like every call that changes the game, a call takes effect at the end of the script's current call. Titles may be 80 bytes and texts 400; a mission holds 32 objectives; an id that already exists, or an empty one, is ignored, and so is a call that names an unknown id.

import "aqua4/objective"

Functions

Add

func Add(id, title, text string, primary bool)

Add gives the player a new objective, active. primary says whether it decides the mission.

Complete

func Complete(id string)

Complete marks an active objective done. A finished objective does not change again.

Fail

func Fail(id string)

Fail marks an active objective failed.

Progress

func Progress(id string, n, total int)

Progress shows "n of total" on an active objective ("3 of 5 villagers rescued"). When n reaches total the objective is completed.

Update

func Update(id, text string)

Update changes the text of an active objective, for a new clue.

WinWhenPrimariesDone

func WinWhenPrimariesDone(on bool)

WinWhenPrimariesDone turns on (or off) ending the mission by its primary objectives: victory when every primary one is done, defeat when any failed. Off by default.