I am trying to make a text based game for a university assignment, this is an extension of a game i coded previously, with a fhew improvements, i originally had it where you choose two potions, you mix them together, and give it to the princess, i now have to include an option of 3 potions when i choose a potion.(hopefully that makes sense)
what i have so far:
#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;
void printStoreMenu();
void printBuyPotionMenu();
int main()
{
cout << "************************************************************\n";
cout << "* The Sick Princess *\n";
cout << "************************************************************\n";
cout << "Welcome. You have now arrived at Nakor's Magic Store and \n";
cout << "have been asked by the King to purchase two magic potions \n";
cout << "in order to create a remedy that can heal the sick Princess.\n";
cout << "No current potion available BY ITSELF is able to cure the \n";
cout << "Princess. Your task is to choose the correct combination of \n";
cout << "potions in order to cure the princess. \n";
printStoreMenu();
}
void printStoreMenu()
{
char choice, potionMix = 'n', playAgain='N';
do
{
cout << "* Welcome to Nakor's Magic Store *\n";
cout << "***************************************************\n";
cout << "* Please choose one of the following: *\n";
cout << "* a) Purchase a potion *\n";
cout << "* b) Create a mixture from the potions *\n";
cout << "* c) Give potion to the princess *\n";
cout << "* d) Quit *\n";
cout << "***************************************************\n";
cout << "Enter your choice:";
cin >> choice;
switch(tolower(choice))
{
case 'a':
printBuyPotionMenu();
break;
case 'b':
if ( potion1 == '1' && potion2 == '2' && potionMix == 'y')
cout << "\nYou have already mixed the 2 potions. Stop wasting time!";
else if ( potion1 == '1' && potion2 == '2')
{
cout << "\nYou mixed the 2 potions. Good Luck!.";
potionMix = 'y';
}
else
cout << "\nYou haven\'t yet bought the 2 potions.";
break;
case 'c':
if ( potion1 == '1' && potion2 == '2' && potionMix == 'y')
{
cout << "\nYou gave the potion mix to the princess and...";
cout << "\n\n...you failed miserably!\n";
cout << "The Princess will sleep forever, and\n";
cout << "you will spend the rest of your days in the SCSSE's";
cout << " dungeons and sewers.\n";
do
{
cout << "\nDo you want to try again? ";
cin >> playAgain;
}while (tolower(playAgain) != 'y' && tolower(playAgain) != 'n');
if(tolower(playAgain == 'y'))
{
potion1 = '?';
potion2 = '?';
potionMix = 'n';
}
else
{
choice = 'd';
cout << "\nBetter luck next time!\n\n";
}
}
else
cout << "\nYou haven\'t yet mixed 2 potions.";
break;
case 'd':
cout << "\nThanks for playing!" << endl;
choice = 'd';
break;
default:
cout << '\n' << choice << " is not a valid choice. Try again\n";
}
}while(choice!='d');
}
void printBuyPotionMenu()
{
char potion1='?', char potion2='?';
char potionChoice;
do
{
cout << "***************************************************\n";
cout << "* Available Potions *\n";
cout << "***************************************************\n";
cout << "*The following potions are available for purchase:*\n";
cout << "* a) Hogswart *\n";
cout << "* b) Elven Tears *\n";
cout << "* c) Light of Heaven *\n";
cout << "* d) Back to main page *\n";
cout << "***************************************************\n";
cout << "Enter your choice:";
cin >> potionChoice;
switch(tolower(potionChoice))
{
case 'a':
potion1 = 1;
printStoreMenu();
break;
case 'b':
potion2 = 1;
printStoreMenu();
break;
case 'c':
cout << " You chose Light of Heaven " << endl;
break;
case 'd':
cout << " back to previous menu " << endl;
printStoreMenu();
break;
default:
cout << " Invalid Choice " << endl;
}
}while( potionChoice !='d');
return;
}
/*
void givePotions(int mix)
{
switch(mix)
{
case 0: cout << "You failed miserably!\n";
cout << "You did not mix 2 different potions as required.\n";
cout << "The princess has died and you will be hanged for it!\n";
break;
case 1: cout << "You failed the Princess!\n";
cout << "The Princess will sleep forever, and\n";
cout << "you will spend the rest of your days in the King's";
cout << "dungeons and sewers\n";
break;
case 2: cout << "The Princess recovers but develops chronic baldness.\n";
cout << "Your punishment is to look after the Princess' wig";
cout << " forever!\n";
break;
case 3: cout << "The Princess recovers, however she is not 100% cured!\n";
cout << "You have been banished from the Kingdom and \n";
cout << "have been forbidden in marrying your betrothed, the lovely";
cout << " lady Java.\n";
break;
case 4: cout << "Full dosages of Hogswart and Elven Tears should never be";
cout << " mixed\n";
cout << "The princess has died and you will be hanged for it!\n";
break;
case 5: cout << "Full strength Hogswart and Light of Heaven make a lethal"; cout
<< " mix\n";
cout << "The princess has died and you will be hanged for it!\n";
break;
case 6: cout << "The Princess recovers completely!!!\n";
cout << "You are made Baron of SCSSE.";
break;
}
return;
}
*/
i have created a few functions that will be required, (one if commented out to be included later)
I have also only worked on getting it to move to the multiple choice of potions, i am now stuck on how to get it to return the potions i chose, to the void printStoreMenu() function, thats my first and biggest issue at the moment, im thinking its something quite simple, but cant seem to get my head around it.
Hopefully it makes sense what i am asking, thank you for any assistance.