-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInventory.h
More file actions
62 lines (49 loc) · 1.65 KB
/
Inventory.h
File metadata and controls
62 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <string>
#include <iostream>
#include <vector>
#include "TextAdventure.h"
using namespace std;
// This struct holds all the details for an inventory item
struct Item
{
public:
// This is the name that will be displayed when the item is described
string Name;
// This is the room index that the item can be found in
int Location;
// This is a check to see if the player has collected the item yet
bool bCollected;
// This is a check to see if the item has been used and can't be used again
bool bConsumed;
// And this string is the replacement for the room description once the item is collected
string LatterDescription;
// This constructor function populates the struct with the input variables
Item(string InName, int InLocation, bool bInCollected, bool bInConsumed, string InLatterDescription)
{
Name = InName;
Location = InLocation;
bCollected = bInCollected;
bConsumed = bInConsumed;
LatterDescription = InLatterDescription;
}
};
// This class holds all the functions and details of items in the player's inventory
class Inventory
{
public:
Inventory(Game* InGame);
~Inventory() {};
// This is the parent Game class
Game* TextAdv = nullptr;
// This is the list of items possble for the player to have in their inventory
vector<Item> InventoryList;
// This function collects the item from the room if possible
bool CollectItem(string ItemName, int RoomIndex);
// This function consumes an item if possible
void ConsumeItem(string ItemName);
// This function checks if the player has an item
bool HasItem(string ItemName);
// This function returns all the items the player has collected
string PrintInventory();
};