Banner Image

Module Core.Goal

Core - Models the process to achieve goal(s).


Features:

  • Define the goal.
  • Monitor the goal achievement.
  • Manage goal contribution by players.

Classes that implement a goal achievement, will derive from GOAL to implement the ways how the achievements can be realized.


Author: FlightControl

Contributions: funkyfranky


Global(s)

Global GOAL

Models processes that have an objective with a defined achievement.

#GOAL GOAL

Models processes that have an objective with a defined achievement.

Derived classes implement the ways how the achievements can be realized.

1. GOAL constructor

  • GOAL.New(): Creates a new GOAL object.

2. GOAL is a finite state machine (FSM).

2.1. GOAL States

  • Pending: The goal object is in progress.
  • Achieved: The goal objective is Achieved.

2.2. GOAL Events

  • Achieved: Set the goal objective to Achieved.

3. Player contributions.

Goals are most of the time achieved by players. These player achievements can be registered as part of the goal achievement. Use GOAL.AddPlayerContribution() to add a player contribution to the goal. The player contributions are based on a points system, an internal counter per player. So once the goal has been achieved, the player contributions can be queried using GOAL.GetPlayerContributions(), that retrieves all contributions done by the players. For one player, the contribution can be queried using GOAL.GetPlayerContribution(). The total amount of player contributions can be queried using GOAL.GetTotalContributions().

4. Goal achievement.

Once the goal is achieved, the mission designer will need to trigger the goal achievement using the Achieved event. The underlying 2 examples will achieve the goals for the Goal object:

  Goal:Achieved() -- Achieve the goal immediately.
  Goal:__Achieved( 30 ) -- Achieve the goal within 30 seconds.

5. Check goal achievement.

The method GOAL.IsAchieved() will return true if the goal is achieved (the trigger Achieved was executed). You can use this method to check asynchronously if a goal has been achieved, for example using a scheduler.

Type(s)

Fields and Methods inherited from GOAL Description

GOAL:Achieved()

Achieved Trigger for GOAL

GOAL:AddPlayerContribution(PlayerName)

Add a new contribution by a player.

GOAL:GetPlayerContribution(PlayerName)

GOAL:GetPlayerContributions()

Get the players who contributed to achieve the goal.

GOAL:GetTotalContributions()

Gets the total contributions that happened to achieve the goal.

GOAL:IsAchieved()

Validates if the goal is achieved.

GOAL:New()

GOAL Constructor.

GOAL:OnAfterAchieved(From, Event, To)

Achieved Handler OnAfter for GOAL

GOAL:OnBeforeAchieved(From, Event, To)

Achieved Handler OnBefore for GOAL

GOAL:OnEnterAchieved(From, Event, To)

Achieved State Handler OnEnter for GOAL

GOAL:OnLeaveAchieved(From, Event, To)

Achieved State Handler OnLeave for GOAL

GOAL.Players

GOAL.TotalContributions

GOAL:__Achieved(Delay)

Achieved Asynchronous Trigger for GOAL

Field(s)

#table GOAL.Players

@field #table GOAL.Players

Function(s)

Achieved Trigger for GOAL

Defined in:

GOAL

Add a new contribution by a player.

Defined in:

GOAL

Parameter:

#string PlayerName

The name of the player.

@param #GOAL self @param #number Player contribution.

Defined in:

GOAL

Parameter:

PlayerName

Get the players who contributed to achieve the goal.

The result is a list of players, sorted by the name of the players.

Defined in:

GOAL

Return value:

list The list of players, indexed by the player name.

Gets the total contributions that happened to achieve the goal.

The result is a number.

Defined in:

GOAL

Return value:

#number:

The total number of contributions. 0 is returned if there were no contributions (yet).

Validates if the goal is achieved.

Defined in:

GOAL

Return value:

#boolean:

true if the goal is achieved.

GOAL Constructor.

Defined in:

GOAL

Return value:

Achieved Handler OnAfter for GOAL

Defined in:

GOAL

Parameters:

#string From

#string Event

#string To

Achieved Handler OnBefore for GOAL

Defined in:

GOAL

Parameters:

#string From

#string Event

#string To

Return value:

#boolean:

Achieved State Handler OnEnter for GOAL

Defined in:

GOAL

Parameters:

#string From

#string Event

#string To

Achieved State Handler OnLeave for GOAL

Defined in:

GOAL

Parameters:

#string From

#string Event

#string To

Return value:

#boolean:

Achieved Asynchronous Trigger for GOAL

Defined in:

GOAL

Parameter:

#number Delay