Hi there first of all let me wish you all a happy new year!!!
So, i tried to make a Text based adventure game, and I realized I had to learn OOP, and I tried to do things the best way, so i ended up getting a little confused with OOP. i came up with 5files (main.cpp / game.cpp/ inventory.cpp/ player.cpp and map.cpp). but i can´t get where do i need to create objects and i came up a little confused, the game is running, the only thing is when it needs to return to menu i need to reset all variables, in best case destroy objects and re create as soon as player press play, but can´t figure how to do that.
main.cpp
#include<iostream>
#include<string>
#include<fstream>
#include"map.h"
#include"player.h"
#include"inventory.h"
#include"game.h"
void loadMap();
void getPlayerName();
void updateGame();
void displayGame();
std::string inventory();
std::string iventoryDeleteItem();
void handleHallEvents();
void handleKitchenEvents();
void handleLivingRoomEvents();
void handleLibraryEvents();
void handleHallWayEvents();
void handleBathroomEvents();
void handleHall1Events();
void handleBedroom1Events();
void handleBedroom2Events();
void handleBathroom1Events();
void handleCongratsEvents();
void handleHallFirstChoice();
void handleKitchenFirstChoice();
void handleLivingRoomFirstChoice();
void handleBathroomFirstChoice();
void handleBedroom2FirstChoice();
void handleBedroomFirstChoice();
std::string addInventoryItem(std::string);
enum gameStates{Menu,Running,Exit};
std::string iventoryItems[5] = { "empty", "empty", "empty", "empty", "empty" };
gameStates gameState;
Map isMap("Hall","0");
Player isPlayer;
Inventory isInventory;
Game isGame;
int main(){
gameState = Menu;
while (gameState != Exit)
{
switch (gameState)
{
case Menu:
{
int getMenuChoice = isGame.menuLogic();
if (getMenuChoice == 1)
{
isGame.clearScreen();
getPlayerName();
gameState = Running;
}else{
gameState = Exit;
}
break;
}
case Running:
updateGame();
loadMap();
displayGame();
break;
case Exit:
break;
}
}
return 0;
}
void getPlayerName(){
std::string playerInput;
std::cout << "Enter your name: ";
std::cin >> playerInput;
isPlayer.setName(playerInput);
}
void loadMap(){
std::ifstream map;
//std::cout << isMap.currentRoom;
map.open(isMap.getCurrentRoom() + ".txt");
if (map.fail()){
std::cout << "Erro\n";
system("pause");
exit(1);
}
std::string mapData;
while (getline(map, mapData)){
std::cout << mapData <<"\n";
}
map.close();
}
void updateGame(){
isGame.clearScreen();
}
void displayGame(){
if (isMap.getCurrentRoom() == "Hall"){
handleHallEvents();
}
else if (isMap.getCurrentRoom() == "Kitchen"){
handleKitchenEvents();
}
else if (isMap.getCurrentRoom() == "LivingRoom"){
handleLivingRoomEvents();
}
else if (isMap.getCurrentRoom() == "Library"){
handleLibraryEvents();
}
else if (isMap.getCurrentRoom() == "HallWay"){
handleHallWayEvents();
}
else if (isMap.getCurrentRoom() == "Bathroom"){
handleBathroomEvents();
}
else if (isMap.getCurrentRoom() == "Hall1"){
handleHall1Events();
}
else if (isMap.getCurrentRoom() == "Bedroom1"){
handleBedroom1Events();
}
else if (isMap.getCurrentRoom() == "Bedroom2"){
handleBedroom2Events();
}
else if (isMap.getCurrentRoom() == "Bathroom1"){
handleBathroom1Events();
}
else if (isMap.getCurrentRoom() == "Congrats"){
handleCongratsEvents();
}
}
//Hall handle events
void handleHallEvents(){
std::string playerInput;
//Check if is first visit to Hall so we can change text to fit
if (isMap.getHallFirstVisit()){
handleHallFirstChoice();
}else{
std::cout << "keep looking for your dog\n";
std::cout << "[1] -> go to Kitchen\n";
std::cout << "[2] -> go to Hallway\n";
std::cout << "[3] -> go to Livingroom\n";
std::cout << "[4] -> go Outside\n";
std::cout << "[i] -> Open Invetory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("Kitchen");
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "3"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("LivingRoom");
}
else if (isPlayer.getPlayerDecision() == "4"){
if (isInventory.getItemAsBeenUsed() == "mainKey"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("Congrats");
}
else{
std::cout << "This door is locked , you need the mainKey to open it ...\n";
goto retry;
}
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
isInventory.setItemAsBeenUsed(inventory());
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleHallFirstChoice(){
std::string playerInput;
std::cout << "Hi " << isPlayer.getName() << " you come up in this house in order to look for your dog, as you enter the door locked...Find your dog and get out of this place!\n";
std::cout << "[1] -> go to Kitchen\n";
std::cout << "[2] -> go to Hallway\n";
std::cout << "[3] -> go to Livingroom\n";
std::cout << "[4] -> go Outside\n";
std::cout << "[i] -> Open Invetory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("Kitchen");
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "3"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("LivingRoom");
}
else if (isPlayer.getPlayerDecision() == "4"){
if (isInventory.getItemAsBeenUsed() == "mainKey"){
isMap.setLastRoom("Hall");
isMap.setCurrentRoom("Congrats");
}
else{
std::cout << "This door is locked , you need the mainKey to open it ...\n";
goto retry;
}
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
isMap.setHallFirstVisit(false);
}
//End Hall handle events
//Kitchen handle events
void handleKitchenEvents(){
std::string playerInput;
//Check if is first visit to kitchen so we can change text to fit
if (isMap.getkitchenFirstVisit()){
handleKitchenFirstChoice();
}else{
std::cout << "you already were here , i don´t think you will find anything here...\n";
std::cout << "[1] -> go to Hall\n";
std::cout << "[i] -> open Iventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Kitchen");
isMap.setCurrentRoom("Hall");
}else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleKitchenFirstChoice(){
std::string playerInput;
std::cout << "You are in the kitchen and your dog is not here... the cabinets are a bit destroyed , seems to have something in it ...\n";
std::cout << "[1] -> examine Cabinets\n";
std::cout << "[2] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry0:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isGame.clearScreen();
loadMap();
isPlayer.setplayerDecision("");
addInventoryItem("Ligth");
std::cout << "You find yourself a flashlight ! check your inventory.\n";
std::cout << "[1] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Kitchen");
isMap.setCurrentRoom("Hall");
}else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}else{
std::cout << "That is not an option!\n";
goto retry;
}
isMap.setkitchenFirstVisit(false);
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("Kitchen");
isMap.setCurrentRoom("Hall");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}else{
std::cout << "That is not an option!\n";
goto retry0;
}
}
//End Kitchen handle events
//LivingRoom handel events
void handleLivingRoomEvents(){
std::string playerInput;
//Check if is first visit to LivingRoom so we can change text to fit
if (isMap.getLivingRoomFirstVisit()){
handleLivingRoomFirstChoice();
}else{
std::cout << "Besides the Dog Collar, i think there is not anything in this division... \n";
std::cout << "[1] -> go to Library\n";
std::cout << "[2] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Library");
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Hall");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleLivingRoomFirstChoice(){
std::string playerInput;
std::cout << "You are in the Livingroom and your dog is not here, it seems that this room has an Library, wait ... what is this noise? Seems to come from the couch ...\n";
std::cout << "[1] -> examine Couch\n";
std::cout << "[2] -> go to Library\n";
std::cout << "[3] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry0:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isGame.clearScreen();
loadMap();
isPlayer.setplayerDecision("");
addInventoryItem("Dog Collar");
std::cout << "You find yourself a rat gnawing on the collar of your dog !\n check your inventory.";
std::cout << "[1] -> go to Library\n";
std::cout << "[2] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Library");
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Hall");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
isMap.setLivingRoomFirstVisit(false);
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Library");
}
else if (isPlayer.getPlayerDecision() == "3"){
isMap.setLastRoom("LivingRoom");
isMap.setCurrentRoom("Hall");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry0;
}
}
//End LivingRoom handle events
//Library handle events
void handleLibraryEvents(){
std::string playerInput;
std::cout << "This division appears to be haunted , perhaps it is best to get out of here...\n";
std::cout << "[1] -> go to Livingroom\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Library");
isMap.setCurrentRoom("LivingRoom");
}else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End Library handle events
//HallWay handle events
void handleHallWayEvents(){
std::string playerInput;
std::cout << "you're in the hallway \n";
std::cout << "[1] -> go to 1st floor\n";
std::cout << "[2] -> go to Bathroom\n";
std::cout << "[3] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("HallWay");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("HallWay");
isMap.setCurrentRoom("Bathroom");
}
else if (isPlayer.getPlayerDecision() == "3"){
isMap.setLastRoom("HallWay");
isMap.setCurrentRoom("Hall");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End HallWay handle events
//Bathroom handle events
void handleBathroomEvents(){
std::string playerInput;
if (isMap.getBathroomFirstVisit()){
handleBathroomFirstChoice();
}else{
std::cout << "It seems this division doesn´t have anything else that interests us...\n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bathroom");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleBathroomFirstChoice(){
std::string playerInput;
if (isInventory.getItemAsBeenUsed() == "Ligth"){
std::cout << "You are using the flashlight, now you can see better... Look ! a key on the floor!\n";
std::cout << "[1] -> grab Key\n";
std::cout << "[2] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry0:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isGame.clearScreen();
loadMap();
isPlayer.setplayerDecision("");
addInventoryItem("Silver Key");
std::cout << "You found a key!\ncheck your Inventory.\n";
std::cout << "[1] -> go to HallWay\n";
std::cout << "[i] -> open Inventory\n";
retry1:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bathroom");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry1;
}
isMap.setBathroomFirstVisit(false);
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("Bathroom");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
isInventory.setItemAsBeenUsed(inventory());
}
else{
std::cout << "That is not an option!\n";
goto retry0;
}
}
else{
std::cout << "You are in Bathroom, it´s a little dark in here...\n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bathroom");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
isInventory.setItemAsBeenUsed(inventory());
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
//End Bathroom handle events
//Hall1 handle events
void handleHall1Events(){
std::string playerInput;
std::cout << "You are in 1st floor Hallway\n";
std::cout << "[1] -> go to Bedroom 1\n";
std::cout << "[2] -> go to Bedroom 2\n";
std::cout << "[3] -> go to Bathroom\n";
std::cout << "[4] -> go to Ground floor\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Hall1");
isMap.setCurrentRoom("Bedroom1");
}
else if (isPlayer.getPlayerDecision() == "2"){
if (isInventory.getItemAsBeenUsed() == "Silver Key"){
isMap.setLastRoom("Hall1");
isMap.setCurrentRoom("Bedroom2");
}
else{
std::cout << "This door is locked , you need the Silver Key to open...\n";
goto retry;
}
}
else if (isPlayer.getPlayerDecision() == "3"){
isMap.setLastRoom("Hall1");
isMap.setCurrentRoom("Bathroom1");
}
else if (isPlayer.getPlayerDecision() == "4"){
isMap.setLastRoom("Hall1");
isMap.setCurrentRoom("HallWay");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
isInventory.setItemAsBeenUsed(inventory());
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End Hall1 handle events
//Bedroom1 handle events
void handleBedroom1Events(){
std::string playerInput;
if (isMap.getBedroom1FirstVisit()){
handleBedroomFirstChoice();
}
else{
std::cout << "You´ve been here before, it seems this division as nothing to us...\n";
std::cout << "[1] -> go to Hall\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bedroom1");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleBedroomFirstChoice(){
std::string playerInput;
std::cout << "it's cold in here, you have a chest in front of you with abandoned aspect...\n";
std::cout << "[1] -> examine Chest\n";
std::cout << "[2] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry0:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isGame.clearScreen();
loadMap();
isPlayer.setplayerDecision("");
addInventoryItem("mainKey");
std::cout << "You´ve found the mainKey!\ncheck your Inventory.\n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
//std::cout << playerDecision;
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bedroom1");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
isMap.setBedroom1FirstVisit(false);
}
else if (isPlayer.getPlayerDecision() == "2"){
isMap.setLastRoom("Bedroom1");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry0;
}
}
//End Bedroom1 handle events
//Bedroom2 handle events
void handleBedroom2Events(){
std::string playerInput;
if (isMap.getBedroom2FirstVisit()){
handleBedroom2FirstChoice();
}
else{
std::cout << "you've been here before, look for a way out and leave this house!\n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Invetory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bedroom2");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
}
void handleBedroom2FirstChoice(){
std::string playerInput;
std::cout << "Hey you´ve found your Dog! he is ok, look for a way out and leave this house!\n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry:
playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bedroom2");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End Bedroom2 handle events
//Bathroom1 handle events
void handleBathroom1Events(){
std::string playerInput;
std::cout << "You 're in the bathroom on the 1st floor \n";
std::cout << "[1] -> go to Hallway\n";
std::cout << "[i] -> open Inventory\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
isMap.setLastRoom("Bathroom1");
isMap.setCurrentRoom("Hall1");
}
else if (isPlayer.getPlayerDecision() == "i"){
isPlayer.setplayerDecision("");
inventory();
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End Bathroom1 handle events
//Congrats handle events
void handleCongratsEvents(){
std::string playerInput;
std::cout << "Congratulations!!\n";
std::cout << "[1] -> go to Menu\n";
std::cout << "[2] -> Exit\n";
retry:
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "1"){
gameState = Menu;
}
else if (isPlayer.getPlayerDecision() == "2"){
gameState = Exit;
}
else{
std::cout << "That is not an option!\n";
goto retry;
}
}
//End Congrats handle events
std::string inventory(){
std::string item = "";
std::string playerInput;
while (isPlayer.getPlayerDecision() != "i"){
isGame.clearScreen();
loadMap();
isPlayer.setplayerDecision("");
for (int a = 0; a < 5; a++){
if (iventoryItems[a] == "Ligth" && isMap.getCurrentRoom() == "Bathroom"){
std::cout << "Item " << a + 1 << " -> " << iventoryItems[a] << " [u]-> Use this item\n";
item = iventoryItems[a];
}
else if (iventoryItems[a] == "Silver Key" && isMap.getCurrentRoom() == "Hall1"){
std::cout << "Item " << a + 1 << " -> " << iventoryItems[a] << " [u]-> Use this item\n";
item = iventoryItems[a];
}
else if (iventoryItems[a] == "mainKey" && isMap.getCurrentRoom() == "Hall"){
std::cout << "Item " << a + 1 << " -> " << iventoryItems[a] << " [u]-> Use this item\n";
item = iventoryItems[a];
}
else{
std::cout << "Item " << a + 1 << " -> " << iventoryItems[a] << "\n";
}
}
std::cout << "[i] -> close iventory\n";
std::cin >> playerInput;
isPlayer.setplayerDecision(playerInput);
if (isPlayer.getPlayerDecision() == "u"){
std::cout << "You used your item!\n";
//item = iventoryDeleteItem();
return item;
//system("pause");
}
}
return item;
}
std::string iventoryDeleteItem(){
std::string itemDeleted = "";
for (int a = 0; a < 5; a++){
if (iventoryItems[a] == "Ligth" && isMap.getCurrentRoom() == "Bathroom"){
//std::cout << "You have deleted Item " << a + 1 << " -> " << iventoryItems[a] << " [u]-> Use this item\n";
itemDeleted = iventoryItems[a];
iventoryItems[a] = "empty";
return itemDeleted;
}
}
return itemDeleted;
}
std::string addInventoryItem(std::string item){
for (int a = 0; a < 5; a++){
if (iventoryItems[a] == "empty")
{
iventoryItems[a] = item;
break;
}
}
return item;
}
Thank you.