For Text, Animations, Sound and Menu see CliKit
All of the below classes, methods and structs are under the
Enginenamespace
Represents an achievement with a name, description, and unlock status.
Achievement(): Default constructor.Achievement(string name, string description): Constructor that initializes the achievement with a name and description.~Achievement(): Destructor.void setName(string name): Sets the name of the achievement.string getName(): Retrieves the name of the achievement.void setDescription(string description): Sets the description of the achievement.string getDescription(): Retrieves the description of the achievement.void setUnlocked(bool unlocked): Sets the unlock status of the achievement.bool isUnlocked(): Checks if the achievement is unlocked.void unlock(): Unlocks the achievement.
bool unlocked: Indicates whether the achievement is unlocked or not.string name: The name of the achievement.string description: The description of the achievement.
Default constructor.
Constructor that initializes the achievement with a name and description.
name: The name of the achievement.description: The description of the achievement.
Destructor.
Sets the name of the achievement.
name: The name of the achievement.
Retrieves the name of the achievement.
Sets the description of the achievement.
description: The description of the achievement.
Retrieves the description of the achievement.
Sets the unlock status of the achievement.
unlocked: The unlock status of the achievement.
Checks if the achievement is unlocked.
Unlocks the achievement by setting its unlock status to true.
bool unlocked: Indicates whether the achievement is unlocked or not.string name: The name of the achievement.string description: The description of the achievement.
Executes a command by running the specified response, prompt, and player.
response: The response object containing the command logic.p: The prompt object representing the current prompt state.player: A pointer to the player object on which the command will be executed.
string name: The name of the item.string item_id: The ID of the item.string description: The description of the item.
virtual ~Item(): Destructor.Item(): Default constructor.Item(string name): Constructor that initializes the item with a given name.Item(string name, string description): Constructor that initializes the item with a given name and description.Item(string item_id, string name, string description): Constructor that initializes the item with a given ID, name, and description.
void setName(string name): Sets the name of the item.string getName(): Retrieves the name of the item.void setItemId(string item_id): Sets the ID of the item.string getItemId(): Retrieves the ID of the item.void setDescription(string description): Sets the description of the item.string getDescription(): Retrieves the description of the item.
vector<Node*> nodes: A vector that holds pointers to the nodes in the map.
Map(Node *default_node): Constructs a map with a default node and initializes the map.Map(int day, Node *default_node): Constructs a map with a default node and initializes the map with a specific day.
~Map(): Destructor.
void initMap(int day): Initializes the map with a specific day.void initMap(): Initializes the map.Node* getNode(int id): Retrieves a node with the specified ID.void addNode(Node *node, vector<int> connectedTo = {}): Adds a new node to the map with optional connections to other nodes.
The Mission class represents a mission with a name, description, and objectives. It also tracks the completion status of the mission.
Creates an empty Mission object.
Creates a Mission object with the specified name, description, and objectives.
name: A string representing the name of the mission.description: A string describing the mission.objectives: A vector of pointers toObjectiveobjects representing the objectives of the mission.
Destroys the Mission object and releases any allocated resources.
private string name: A string that stores the name of the mission.private string description: A string that stores the description of the mission.private bool completed: A boolean variable that indicates whether the mission is completed. By default, it is set tofalse.public vector<Objective *> objectives: A vector of pointers toObjectiveobjects representing the objectives of the mission.public static const bool COMPLETED: A constant boolean value set totrue, representing the completed status of the mission.
Sets the name of the mission to the specified name.
name: A string representing the name of the mission.
Returns the name of the mission.
Sets the description of the mission to the specified description.
description: A string describing the mission.
Returns the description of the mission.
Sets the completion status of the mission.
completed: A boolean value indicating the completion status. Set it totrueif the mission is completed, andfalseotherwise.
Checks whether the mission is completed.
- Returns: A boolean value indicating whether the mission is completed (
true) or not (false).
The Objective class represents an objective with a description and completion status.
Creates an empty Objective object.
Creates an Objective object with the specified description.
description: A string describing the objective.
Destroys the Objective object and releases any allocated resources.
private string description: A string that stores the description of the objective.private bool completed: A boolean variable that indicates whether the objective is completed. By default, it is set tofalse.
Sets the description of the objective to the specified description.
description: A string describing the objective.
Returns the description of the objective.
Sets the completion status of the objective.
completed: A boolean value indicating the completion status. Set it totrueif the objective is completed, andfalseotherwise.
Checks whether the objective is completed.
- Returns: A boolean value indicating whether the objective is completed (
true) or not (false).
Prints the descriptions of the objectives in the specified objectives vector.
objectives: A vector of pointers toObjectiveobjects representing the objectives to be printed.
Sets the completion status of the objective at the specified index in the objectives vector based on the check value.
check: A boolean value indicating whether the objective is completed (true) or not (false).objectives: A vector of pointers toObjectiveobjects representing the objectives.index: An integer representing the index of the objective to be completed.
The Node class represents a room or a place in general. It contains information about the node's ID, description, items, accessible nodes, and accessibility.
bool accessible: A flag indicating whether the node is accessible or not.
int id: The ID of the node.string description: The description of the node.vector<Item*> items: A vector that holds pointers to the items inside the node.vector<Node*> accessible_nodes: A vector that holds pointers to the nodes the player can move to from the current node.
~Node(): Destructor.Node(): Default constructor.Node(int id, string description, vector<Item*> items, vector<Node*> accessible_nodes, bool accessible): Constructs a node with the specified ID, description, items, accessible nodes, and accessibility.Node(int id, string description, vector<Item*> items): Constructs a node with the specified ID, description, and items.Node(string description): Constructs a node with the specified description, representing an inaccessible room.Node(int id, string description): Constructs a node with the specified ID and description, representing an inaccessible room.Node(int id, string description, bool accessible): Constructs a node with the specified ID, description, and accessibility.
void setId(int id): Sets the ID of the node.void setDescription(string description): Sets the description of the node.void addItem(Item *item): Adds an item to the node.void addRoute(Node *n): Adds a node as an accessible route from the current node.void lock(): Locks the node, making it inaccessible.void unlock(): Unlocks the node, making it accessible.bool isAccessible(): Checks if the node is accessible.
The Inventory class represents a collection of items that a player can possess.
vector<Item *> items: A vector that holds pointers to the items in the inventory.
Inventory(): Default constructor.~Inventory(): Destructor.Inventory(vector<Item *> items): Constructs an inventory with the specified items.
vector<Item *> getItems(): Retrieves the items in the inventory.
void addItem(Item *item): Adds an item to the inventory.Item getItem(string id): Retrieves an item from the inventory based on its ID.int getQuantity(Item *item): Retrieves the quantity of a specific item in the inventory.int getQuantity(string id): Retrieves the quantity of an item in the inventory based on its ID.string exportContents(): Exports the contents of the inventory as a string representation.void importContents(): Imports the contents of the inventory from a string representation.void printInventory(): Prints the inventory.
The Player class represents a player with an inventory, name, stats, and a current mission.
Creates an empty Player object.
Creates a Player object with the specified inventory, name, and stats.
inventory: AnInventoryobject representing the player's inventory.name: A string representing the name of the player.stats: A vector of integers representing the player's stats.
Destroys the Player object and releases any allocated resources.
private Inventory inventory: AnInventoryobject representing the player's inventory.private string name: A string that stores the name of the player.private vector<int> stats: A vector of integers representing the player's stats.private Mission *mission: A pointer to aMissionobject representing the player's current mission.public Node *currentNode: A pointer to aNodeobject representing the player's current location.
Sets the player's inventory to the specified inventory.
inventory: AnInventoryobject representing the player's inventory.
Returns the player's inventory.
Sets the player's name to the specified name.
name: A string representing the name of the player.
Returns the player's name.
Sets the player's current mission to the specified mission.
mission: A pointer to aMissionobject representing the player's current mission.
Returns the player's current mission.
Returns the player's stats.
Sets the player's current location to the specified newNode.
newNode: A pointer to aNodeobject representing the player's new location.
Moves the player to a new node if it is accessible.
newNode: A pointer to aNodeobject representing the node the player tries to move to.
Collects the specified item and adds it to the player's inventory.
item: A pointer to anItemobject representing the item to be collected.
The Progress class represents the progress of a player, including the player's details, nodes, and achievements.
Creates a Progress object with the specified player, nodes, and achievements.
player: APlayerobject representing the player's details.nodes: A vector ofNodeobjects representing the nodes.achievements: A vector ofAchievementobjects representing the achievements.
Creates an empty Progress object.
Destroys the Progress object and releases any allocated resources.
public Player player: APlayerobject representing the player's details.vector<Node> nodes: A vector ofNodeobjects representing the nodes.vector<Achievement> achievements: A vector ofAchievementobjects representing the achievements.int day: An integer representing the current day.
Serializes the object's fields in order to save and load the progress.
ar: A reference to theArchiveobject.version: An unsigned integer representing the version of the serialization format.
Please note that the serialize function is necessary to have access to the serialization library.
The Response struct represents a response object that contains a command and its arguments.
string command: The command string.vector<string> args: A vector of strings representing the arguments for the command.
The Prompt struct represents a prompt object that contains information about a prompt message, accepted commands, and a prompt character.
char prompt_char: The prompt character to be displayed.string message: The message displayed as the prompt.vector<string> accepted_commands: A vector of strings representing the accepted commands for the prompt.
The prompt method is used to display a prompt message and accept user input.
Response prompt(char prompt_char, string message, vector<string> accepted_commands, vector<string> game_commands = {});Response prompt(Prompt p, vector<string> game_commands = {}, bool displayPromptMsg = true);
-
For the first method signature:
prompt_char: The prompt character to be displayed.message: The message displayed as the prompt.accepted_commands: A vector of strings representing the accepted commands for the prompt.game_commands(optional): A vector of strings representing additional game-specific commands.
-
For the second method signature:
p: APromptobject containing the prompt character, message, and accepted commands.game_commands(optional): A vector of strings representing additional game-specific commands.displayPromptMsg(optional): A boolean value indicating whether to display the prompt message (default istrue).
A Response object representing the user's input command and arguments.
The print method is used to print a message to the console without appending a newline character.
void print(string message);
message: The message to be printed.
None.
The println method is used to print a message to the console and append a newline character.
void println(string message, int delay = 2);
message: The message to be printed.delay(optional): The delay in seconds before printing the newline character (default is2).
None.
The saveToFile method is used to save text data to a file.
void saveToFile(string file_name, string text_data);
file_name: The name of the file to save the text data to.text_data: The text data to be saved to the file.
None.
The loadFromFile method is used to load text data from a file.
string loadFromFile(string file_name);
file_name: The name of the file to load the text data from.
A string containing the loaded text data from the file.
The saveObject method is used to save an object of type T to a file.
template <typename T> void saveObject(string filename, T object_to_save);
filename: The name of the file to save the object to.object_to_save: The object of typeTto be saved to the file.
None.
The loadObject method is used to load an object of type T from a file.
template <typename T> T loadObject(string filename, T object_to_load);
filename: The name of the file to load the object from.object_to_load: An empty object of typeTto be populated with the loaded data.
An object of type T containing the loaded data from the file.
The engine.h file serves as a single point of inclusion for all the necessary header files required for the game engine. By including this file in your source code, you gain access to all the classes and utilities needed to build and run a game.