Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ALL-Project-2-Text-Based-Game-Blackmail-/inventory.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
41 lines (39 sloc)
1.13 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///inventory.h | |
#ifndef INVENTORY_H | |
#define INVENTORY_H | |
#include "item.h" | |
#include "weapon.h" | |
#include "armor.h" | |
#include <exception> | |
#include <vector> | |
#include <memory> | |
///this class will hold items that I will later add to active slots | |
class Inventory | |
{ | |
private: | |
int max_inventory_space; | |
int number_of_items; | |
int player_input; | |
public: | |
///At first I have tried this using normal pointers, but figuring out that | |
/// I am propably creating a memory leak, I switched to unique pointer, because later I will also need to move an Item | |
///I am also using array instead of vector, because with vector i got Critical error detected c0000374 and was not able to fix it | |
///The lastitem slot will be for swaping armor and weapon | |
std::unique_ptr<Item> Inventory_array[11]; | |
Weapon weapon_slot; | |
Armor armor_slot; | |
Inventory(); | |
void add_item(Item &item,int mode_of_operation); | |
void remove_item(int item_number); | |
void swap_item(int item_number,std::string item_type); | |
void display_inventory(); | |
void inventory_menu(); | |
~Inventory(){ | |
for(int i = 0; i > number_of_items;i++) | |
{ | |
Inventory_array[i].release(); | |
Inventory_array[i] = 0; | |
} | |
}; | |
}; | |
#endif |