Example #1
0
void location::roommenu(player &mainchar, map &maplocation)
{
	if (mainchar.alive == false)
	{
		return;
	}
	
	bool validinput = false;
	
	while(validinput == false)
	{
		if((mainchar.gethealth() + 5) < mainchar.gethealthcap())
		{
			mainchar.sethealth(mainchar.gethealth() + 5);
		}
		if((mainchar.getmana() + 5) < mainchar.getmanacap())
		{
			mainchar.setmana(mainchar.getmana() + 5);
		}
		cout<<"The Menu:"<<endl;
		if(goN == true)
		{
			cout<<"(N) Go North"<<endl;
		}
		if(goS == true)
		{
			cout<<"(S) Go South"<<endl;
		}
		if(goE == true)
		{
			cout<<"(E) Go East"<<endl;
		}
		if(goW == true)
		{
			cout<<"(W) Go West"<<endl;
		}
		
		cout<<"(1) Inventory"<<endl;
		cout<<"(2) Stats"<<endl;
		cout<<"(3) Equip Weapon"<<endl;
		char input;
		cin>>input;
		switch(input)
		{
		case 'n':
		case 'N':
			if(goN == true)
			{
				maplocation.goN();
				validinput = true;
			}
			else
			{
				cout<<"Invalid Input.  Try Again."<<endl;
			}
			break;
		case 's':
		case 'S':
			if(goS == true)
			{
				maplocation.goS();
				validinput = true;
			}
			else
			{
				cout<<"Invalid Input.  Try Again."<<endl;
			}
			break;
		case 'e':
		case 'E':
			if(goE == true)
			{
				maplocation.goE();
				validinput = true;
			}
			else
			{
				cout<<"Invalid Input.  Try Again."<<endl;
			}
			break;
		case 'w':
		case 'W':
			if(goW == true)
			{
				maplocation.goW();
				validinput = true;
			}
			else
			{
				cout<<"Invalid Input.  Try Again."<<endl;
			}
			break;
		case '1':
			mainchar.displayinv();
			break;
		case '2':
			displaystats();
			break;
		case '3':
			mainchar.displayinv();
			cout<<"Which item would you like to equip (inventory slot number)?"<<endl;
			cin>>input;
			input -= 48;
			mainchar.equipweapon(input - 1);
			validinput = true;
			break;
		default:
			cout<<"Invalid Input.  Try Again."<<endl<<endl;
		}
	}
	}