Ok, im making a Text Based RPG and well just look at my problem.

#include "Library.h"

using namespace std;

//Constant Integers
//Functions
void StartGame();
void LoadGame();
void Berkshire();
void Game_Menu();
//Integers
int Gold = 0;
int Health = 20;
int Energy = 20;
int Mana = 10;
int numItems = 0;
int Salary = 2;
//Arrays
char Game[4];
//Strings
string Name;
string Menuopt;
string Inventory[5];
string Body[6];
                                         

int main()
{
    
    //Welcome Screen
    cout << "\t\tWelcome to the world or Hilvale!\n\n";
    cout << "\t\t    Created by Kile Exley\n\n";
    system("PAUSE");
    system("CLS");
    Game_Menu();
    cout << "\n";
    system("PAUSE");
    return 0;
}
    
void Game_Menu()
{
    //Game Menu
    cout << "\t\t|-----------|\n";
    cout << "\t\t| Game Menu |\n";
    cout << "\t\t|-----------|\n\n\n";
    cout << "New (Game)\n";
    cout << "Load (Game)\n\n";
    cin >> Menuopt;
    
    if (Menuopt == "New")
    {
                StartGame();
    }
    if (Menuopt == "Load")
    {
                LoadGame();
    }
    else
    {
        system("CLS");
        Game_Menu();
    }
}

void StartGame()
{
     system("CLS");
     cout << "You have started a New Game\n\n";
     cout << "What is your name?\n";
     cin >> Name;
     system("PAUSE");
     Berkshire();
}

void LoadGame()
{
     cout << "\nWhat game should be loaded?\n\n";
}

void Berkshire()
{
     
     system("CLS");
     cout << "Welcome " << Name << ", to Berkshire!\n\n";
     cout << "Where would you like to go?\n";
     cout << "Work (Gain " << Salary << " Gold)\n";
     cout << "Inn (Heal)\n";
     cout << "Potion (Shop)\n";
     cout << "Armor (Shop)\n";
     cin >> Menuopt;
     
     if (Menuopt == "Work")
     {
                 system("CLS");
                 
                 if (Energy >= 5, Energy -= 5)
                 {
                     cout << "You earned " << Salary << " Gold, you now have " << Energy << " Energy\n";
                     system("PAUSE");
                     return Berkshire();   
                 } 
                 if (Energy < 5)
                 {
                     cout << "You only have " << Energy << ", you need 5 to be able to work\n";
                 }
     }
     else
     {
         Berkshire();
     }
                 
}

Heres what happens after i use up all my Energy (20) from working 3 times after i try to do it a fourth instead of saying that you dont have enough energy it just goes to the Game Menu. Please help me.

So what is the problem? Out of energy? What is that supposed to mean? And the program just goes to the Game Menu because that's exactly what you told it to do (line 35).

People don't generally like "help me" or other generalized titles. A better title for your post would be "Problem in text-based RPG". That sounds much more intriguing!

I haven't seen this kind of thing before: if (Energy >= 5, Energy -= 5) Do you realize that the Energy -= 5 part will be executed whether or not the Energy >= 5 part is true? Put Energy -= 5 in the body of the if.

Use a loop in Berkshire, not a recursive call, and you will probably be able to sort out why it goes right back to the menu.

This article has been dead for over six months. Start a new discussion instead.