Planeshift
RecipeManager Class Reference

Class that represents the Recipe Manager of the game. More...

#include <recipe.h>

Classes

struct  Correspondence
 Keeps details about the matches between script actions and NPC Operations. More...
 
struct  TribeData
 Keeps details of all tribes enrolled in the manager. More...
 

Public Member Functions

bool AddTribe (Tribe *tribe)
 Add a tribe. More...
 
int ApplyRecipe (RecipeTreeNode *bestRecipe, Tribe *tribe, int step)
 Apply Recipe. More...
 
void CreateGlobalNPCType (Tribe *tribe)
 Compute global npctype. More...
 
RecipeGetRecipe (int recipeID)
 Get pointer to recipe based on ID. More...
 
RecipeGetRecipe (csString recipesName)
 Get pointer to recipe based on Recipe's Name. More...
 
TribeDataGetTribeData (Tribe *tribe)
 Get computed tribeData for a tribe. More...
 
bool LoadRecipes ()
 Loads all recipes from the database. More...
 
bool ParseFunction (csString function, Tribe *tribe, csArray< NPC * > &npcs, Recipe *recipe)
 Parse function. More...
 
bool ParseRequirement (const Recipe::Requirement &requirement, Tribe *tribe, Recipe *recipe)
 Check Requirement. More...
 
csString Preparse (csString function, Tribe *tribe)
 Preparser. More...
 
 RecipeManager (psNPCClient *NPCClient, EventManager *eventManager)
 Construct the Recipe Manager. More...
 
virtual ~RecipeManager ()
 Destruct the Recipe Manager. More...
 

Detailed Description

Class that represents the Recipe Manager of the game.

This object loads and stores all the recipes in-game. It also keeps track of the progress the tribes have in their recipes and triggers changes in tribes once recipes are completed.

Definition at line 148 of file recipe.h.

Constructor & Destructor Documentation

RecipeManager::RecipeManager ( psNPCClient NPCClient,
EventManager eventManager 
)

Construct the Recipe Manager.

virtual RecipeManager::~RecipeManager ( )
virtual

Destruct the Recipe Manager.

Member Function Documentation

bool RecipeManager::AddTribe ( Tribe tribe)

Add a tribe.

Method to load a tribe pointer into the tribes list held by the manager. Required for all tribes we want the manager to hold.

Parameters
tribeThe tribe to be added.
Returns
True if the tribe where added successfully
int RecipeManager::ApplyRecipe ( RecipeTreeNode bestRecipe,
Tribe tribe,
int  step 
)

Apply Recipe.

Applies a recipe to a tribe.

Parameters
bestRecipeThe recipeTreeNode to apply
tribeThe tribe on which to apply
stepThe step on which to start
Returns
The step on which the algorithm stopped, or -1 if completed.
void RecipeManager::CreateGlobalNPCType ( Tribe tribe)

Compute global npctype.

Computes a global part of an npctype for each tribe. The global npctype contains general/common data concerning tribe members. E.g. : Behavior when attacked, behavior during day/night

  • reactions that change to above-mentioned behaviors After assembling the NPCType it sends the string to the npcclient who creates a new object and pushes into npctypes hash.
Parameters
tribePointer to the tribe on which to create NPCType
Recipe* RecipeManager::GetRecipe ( int  recipeID)

Get pointer to recipe based on ID.

Recipe* RecipeManager::GetRecipe ( csString  recipesName)

Get pointer to recipe based on Recipe's Name.

TribeData* RecipeManager::GetTribeData ( Tribe tribe)

Get computed tribeData for a tribe.

bool RecipeManager::LoadRecipes ( )

Loads all recipes from the database.

bool RecipeManager::ParseFunction ( csString  function,
Tribe tribe,
csArray< NPC * > &  npcs,
Recipe recipe 
)

Parse function.

Applies changes to the tribe based on the function received as an argument.

Parameters
functionString containing a function and it's arguments
tribeThe tribe on which to apply the changes
npcsThe list of npcs to send perceptions to
recipeThe recipe this function belongs to
Returns
True if function is done, false if it needs wait time.
bool RecipeManager::ParseRequirement ( const Recipe::Requirement requirement,
Tribe tribe,
Recipe recipe 
)

Check Requirement.

Checks a requirement. For unmet requirements this function enrolls needed recipes in order to meet the requirements.

Parameters
requirementData structure containing requirement
tribeTribe to check requirements on
recipeThe recipe this requirement belongs to
Returns
True if all requirements are met, false otherwise.
csString RecipeManager::Preparse ( csString  function,
Tribe tribe 
)

Preparser.

Method to preparse the scripts in recipes in order to replace variables used while scripting. E.g. GROW_RESOURCE, HOME

Parameters
functionThe function to preparse
tribeThe tribe from which values are needed
Returns
The preparsed text with actual values

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