I dont know what the deal is, but I always seem to have trouble with them...I cant seem to find anything wrong with the code...I have commented where things seem to go wrong.
CreepyManQuest.cpp
Code:
bool CreepyMansQuest(PLAYER* player)
{
Clr_Scrn();
std::cout << "You find yourself standing just outside an entrance to what appears\n"
<< "to be a ruined castle. A relic that was probably left over from the\n"
<< "middle war days.\n" << std::endl;
Pause();
int CastleEntrance = -1;
// this while loop works...
while(CastleEntrance != 0)
{
Clr_Scrn();
std::cout << "Location: Castle Entrance\n\n" << std::endl;
std::cout << "What would you like to do?\n"
<< "<1> Enter the ruins.\n"
<< "<2> View Stats\n"
<< "<3> View Inventory\n"
<< "<0> Leave Immediately\n"
<< ">";
std::cin >> CastleEntrance;;
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
if (CastleEntrance == 1)
{
if (!Battle(player, CMQGen()))
{
return false;
} // player loses battle
else
{
Clr_Scrn();
std::cout << "You are now inside the ancient castle. All around you there are signs\n"
<< "of war. One that was fought centuries ago. Just a head of you, you see\n"
<< "what once was a door.\n" << std::endl;
Pause();
int ChamberOne = -1;
// this while loop works for obvious reasons
while(ChamberOne !=0)
{
Clr_Scrn();
std::cout << "Location: Chamber One\n\n" << std::endl;
std::cout << "What would you like to do?\n"
<< "<1> Explore further\n"
<< "<2> Check Stats\n"
<< "<3> Check Inventory\n"
<< "<0> Leave Imediately\n"
<< ">";
std::cin >> ChamberOne;
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
if (ChamberOne == 1)
{
if (!Battle(player, CMQGen()))
{
return false;
} // player loses
else
{
int DiningHall = -1;
/* this one does not...it wont exit when player enters 4...Its exits the function like it
should when player enters 0...but take out the return statement and it wont exit at all*/
while (DiningHall !=0 || DiningHall !=4)
{
Clr_Scrn();
std::cout << "Location: Dining Hall\n\n" << std::endl;
std::cout << "You now stand in what seems to be the dining hall.\n"
<< "The walls on three sides of the chamber have caved in\n"
<< "Leaving you three differnt exits.\n"
<< "<1> Go Left\n"
<< "<2> Go Right\n"
<< "<3> Go Forward\n"
<< "<4> Go Back\n"
<< "<5> Check Stats\n"
<< "<6> Check Inventory\n"
<< "<0> Run Away\n"
<< ">";
std::cin >> DiningHall;
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
switch (DiningHall)
{
case 1:
{
int ChamberFour = -1;
// this loop wont exit at all no matter what you enter
while (ChamberFour != 2 || ChamberFour != 0)
{
Clr_Scrn();
std::cout << "Location: Chamber Four\n\n\n\n\n" << std::endl;
std::cout << "<1> Go Right\n"
<< "<2> Go Back\n"
<< "<3> Check Stats\n"
<< "<4> Check Inventory\n"
<< ">";
std::cin >> ChamberFour;
std::cin.clear();
std::cin.ignore(INT_MAX,'\n');
if (ChamberFour == 1)
{
if (!Battle(player, CMQGen()))
{
return false;
} // player loses exit quest
else
{
int ChamberSeven = -1;
} // player wins and moves on
} // player enter battle
} // end chamber four loop, player goes back to the dining hall
break;
} // player enter chamber four
case 2:
{
int ChamberThree = -1;
while (ChamberThree != 1)
{
} // end chamber four loop, player goes back to dining hall
break;
} // player enters chamber three
case 3:
{
int ChamberSix = -1;
while (ChamberSix != 2)
{
} // end chamber six loop, players goes back to dining hall
break;
} // player enters chamber six
case 4:
{
std::cout << "You turn around and head back to the first chamber.\n" << std::endl;
Pause();
break;
} // player goes back to chamber one
case 5:
{
player->GetStats();
Pause();
break;
} // show player stats
case 6:
{
player->PlayerInventory();
Pause();
break;
} // show player inventory
case 0:
{
std::cout << "You run away!\n" << std::endl;
Pause();
return false;
break;
} // player runs away
default:
{
std::cout << "Invalid Selection, please try agian!\n" << std::endl;
Pause();
break;
}
} // End Dining Hall switch statement
} // end Dining Hall while loop
} // player wins and moves on
} // player enters battle
else if (ChamberOne == 2)
{
player->GetStats();
Pause();
} // show player stats
else if (ChamberOne == 3)
{
player->PlayerInventory();
Pause();
} // show player inventory
else if (ChamberOne == 0)
{
std::cout << "You run away!!|n" << std::endl;
Pause();
return false;
} // player runs away
else
{
std::cout << "Invalid Selection, please try agian.\n" << std::endl;
Pause();
} // wrong selection
} // end first nested while loop
} // player wins and moves on
} // player decides to enter casle
else if (CastleEntrance == 2)
{
player->GetStats();
Pause();
} // show player stats
else if (CastleEntrance == 3)
{
player->PlayerInventory();
Pause();
} // show player inventory
else if (CastleEntrance == 0)
{
std::cout << "You run away!\n" << std::endl;
Pause();
return false;
} // player runs away
else
{
std::cout << "Invalid Selection, please try agian.\n" << std::endl;
Pause();
}
} // end while loop
return true;
}
I guess i could go the easy route and use goto statements...but from reading tutorials on this site and others i guess that is not considered good programming...so really dont want to do that.
Yeah its a horrible story line lol