Public Types | Static Public Member Functions

ScriptGoal Class Reference

Class that handles some goal related functions. More...

#include <script_goal.hpp>

Inheritance diagram for ScriptGoal:
ScriptObject SimpleCountedObject

Public Types

enum  GoalID { GOAL_INVALID = ::INVALID_GOALTYPE }
 

The goal IDs.

More...
enum  GoalType {
  GT_NONE = ::GT_NONE, GT_TILE = ::GT_TILE, GT_INDUSTRY = ::GT_INDUSTRY, GT_TOWN = ::GT_TOWN,
  GT_COMPANY = ::GT_COMPANY
}
 

Goal types that can be given to a goal.

More...

Static Public Member Functions

static bool IsValidGoal (GoalID goal_id)
 Check whether this is a valid goalID.
static GoalID New (ScriptCompany::CompanyID company, Text *goal, GoalType type, uint32 destination)
 Create a new goal.
static bool Remove (GoalID goal_id)
 Remove a goal from the list.

Detailed Description

Class that handles some goal related functions.

game

Definition at line 23 of file script_goal.hpp.


Member Enumeration Documentation

The goal IDs.

Enumerator:
GOAL_INVALID 

An invalid goal id.

Definition at line 28 of file script_goal.hpp.

Goal types that can be given to a goal.

Enumerator:
GT_NONE 

Destination is not linked.

GT_TILE 

Destination is a tile.

GT_INDUSTRY 

Destination is an industry.

GT_TOWN 

Destination is a town.

GT_COMPANY 

Destination is a company.

Definition at line 36 of file script_goal.hpp.


Member Function Documentation

bool ScriptGoal::IsValidGoal ( GoalID  goal_id  )  [static]

Check whether this is a valid goalID.

Parameters:
goal_id The GoalID to check.
Returns:
True if and only if this goal is valid.

Definition at line 26 of file script_goal.cpp.

Referenced by Remove().

ScriptGoal::GoalID ScriptGoal::New ( ScriptCompany::CompanyID  company,
Text goal,
GoalType  type,
uint32  destination 
) [static]

Create a new goal.

Parameters:
company The company to create the goal for, or ScriptCompany::COMPANY_INVALID for all.
goal The goal to add to the GUI (can be either a raw string, or a ScriptText object).
type The type of the goal.
destination The destination of the type type.
Returns:
The new GoalID, or GOAL_INVALID if it failed.
Precondition:
goal != NULL && len(goal) != 0.
company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.

Definition at line 31 of file script_goal.cpp.

References CMD_CREATE_GOAL, ScriptCompany::COMPANY_INVALID, ScriptObject::DoCommand(), EnforcePrecondition, Text::GetEncodedText(), GOAL_INVALID, GT_COMPANY, GT_INDUSTRY, GT_NONE, GT_TILE, GT_TOWN, ScriptIndustry::IsValidIndustry(), ScriptMap::IsValidTile(), ScriptTown::IsValidTown(), ScriptCompany::ResolveCompanyID(), and StrEmpty().

bool ScriptGoal::Remove ( GoalID  goal_id  )  [static]

Remove a goal from the list.

Parameters:
goal_id The goal to remove.
Returns:
True if the action succeeded.
Precondition:
IsValidGoal(goal_id).

Definition at line 49 of file script_goal.cpp.

References CMD_REMOVE_GOAL, ScriptObject::DoCommand(), EnforcePrecondition, and IsValidGoal().


The documentation for this class was generated from the following files: