#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <cmath>
#include <conio.h>
#include <fstream>

using namespace std;

int main()
{
	char name[100];
	char dec;
	char cont;
	int code = 0;
	int codeCounter = 0;
	int num;
	cout << " Enter agent name: " << endl;

	std::cin.getline(name, 100);
	cout << "Welcome agent " << name << " you have been chosen to fulfill a very important mission." << endl;
	cout << "Do you accept the mission?" << endl;
	cout << "Good. Let's begin. Press any character to continue " << endl;
	_getch();
	cout << "Okay first you should know that the address is 1337 E. Yanky Drive"
		<< " Now the first decision of the mission is whether to enter from the front or back"
		<< " Type F for front or B for back";

	std::cin >> dec;
		
	switch (dec)
	{
		case 'f':
		{
			srand(time(NULL));
			num = rand() % 1000 + 1;
			cout << num << endl;

			if (num % 2 == 0)
			{
				cout << "You triggered the alarm" << endl;

				while (code != 7331)
				{
					cout << "Enter the code to disable it: "
						<< " \n *HINT* Code involves the address. " << endl;
					cin >> code;
					codeCounter++;
					//After 3 tries user is given another hint.
					if (codeCounter == 3)
					{
						cout << "Hint: Reverse address" << endl;
					}
				}
			}
			else
			{
				cout << "You made it in safely. " << endl;
			}
		}
		break;

		case 'b':
		{
			cout << " Good!! You have successfully breached in the back" << endl;
		}

		case 'F':
		{
			num = rand() % 1000 + 1;

			if (num % 2 == 0)
			{
				cout << "You triggered the alarm" << endl;
				while (code != 7331)
				{
					cout << "Enter the code to disable it: "
						<< " \n *HINT* Code involves the address. " << endl;
					cin >> code;
					codeCounter++;
					//After 3 tries user is given another hint.
					if (codeCounter == 3)
					{
						cout << "Hint: Reverse address" << endl;
					}
				}
			}
			else
			{
				cout << "You made it in safely. " << endl;
			}
		}
		break;

		case 'B':
		{
			cout << "Good. You have successfully breached in the back. " << endl;
		}
		break;

		default:
		{
			cout << "F or B..." << endl;
		}
		break;
	}

	do{
		cout << "Now that you're in the house " << endl;
		cout << "Where do you want to look first (Enter corresponding letter) "
			<< " \n Kitchen (K) "
			<< " \n Living room (L) "
			<< " \n Basement (B) "
			<< " \n Upstairs Bedroom (U) "
			<< " \n Master Bedroom (M) "
			<< " \n Bathroom (N) "
			<< " \n Attic (A) "
			<< endl;

		// Kitchen we want a note leading the player to the basement to find more clues (randomize the note).
		// Living room we want the black box with the information of the terrorists.
		// Items: Crow bar, key, blue prints of the inside of the house, axe, screw driver, pen and paper from the note.
		// We want the items to be randomized in these locations and when the player types in " Living Room" he is then printed.....
		// .....


		char y_nTen;
		char y_nNine;
		char y_nEight;
		char y_nSeven;
		char y_nSix;
		char y_nFive;
		char y_nFour;
		char y_nThree;
		char y_nTwo;
		char y_nOne;
		char look;
		int screwdrive = 0;
		int crowbar = 0;
		int key = 0;
		int items = 0;
		int blueprint = 0;
		int letter = 0;
		int axe = 0;
		int p_p = 0;
		cin >> look;

		if (look == 'K' || look == 'K')
		{
			cout << "You notice a screwdriver on the counter. Do you pick it up? "
				<< "\t Y/N" << endl;
			cin >> y_nOne;

			if (y_nOne == 'Y' || y_nOne == 'y')
			{
				if (items < 3)
				{
					items++;
					screwdrive++;
					cout << "You now have a screwdriver." << endl;
				}
				else if (items >= 3){
					cout << "You already have three items. You can only have three." << endl;

				}
			}
		}

		if (look == 'L' || look == 'l')
		{
			cout << "You walk through the living room and notice there is a loose floor board. Do you examine it?"
				<< "\t Y/N" << endl;

			cin >> y_nTwo;

			if (y_nTwo == 'Y')
			{
				if (screwdrive == 1)
				{
					cout << "You use the screwdriver to pry it open. There is a box underneath. Do you want to open it?"
						<< "\t Y/N" << endl;

					cin >> y_nThree;

					if (y_nThree == 'Y' || y_nThree == 'y')
					{
						if (key == 1)
						{
							cout << "Congratulation! You found the terrorists plans and saved the world!" << endl;
						}
						else
						{
							cout << "The box is locked...you probably should've taken that key when you had the chance..." << endl;
						}
					}
				}
				else if (crowbar == 1)
				{
					cout << "You use the crowbar to pry it open. There is a box underneath. Do you want to open it?"
						<< "\t Y/N" << endl;
					cin >> y_nThree;
					if (y_nThree == 'Y' || y_nThree == 'y')
					{
						if (key == 1)
						{
							cout << "Congratulation! You found the terrorists plans and saved the world!" << endl;
						}
						else
						{
							cout << "The box is locked...you probably should've taken that key when you had the chance..." << endl;
						}
					}
				}
				else
				{
					cout << "It's stuck...you need some tools to open it. Perhaps a screwdriver or crowbar?" << endl;

				}
			}
		}

		if (look == 'b' || look == 'B')
		{
			cout << "As you examine the kitchen you notice a loose brick in the wall. After checking it out there is a key behind the brick. "
				<< "Do you want to pick it up?"
				<< "\n Y/N?" << endl;
			cin >> y_nFour;
			if (y_nFour == 'y' || y_nFour == 'Y')
			{
				if (items < 3)
				{
					items++;
					key++;
					cout << "You have a key now." << endl;
				}
				else if (items >= 3)
				{
					cout << "You already have 3 items. You can only carry three." << endl;

				}
				if (y_nFour == 'N' || y_nFour == 'n')
				{
					cout << "Suit yourself. " << endl;
				}
			}
		}

		cout << "While looking through the basement you find a crowbar. Do you want to keep the crow bar?"
			<< "\n Y/N" << endl;
		cin >> y_nFive;

		if (y_nFive == 'Y' || y_nFive == 'y')
		{
			if (items < 3)
			{
				items++;
				crowbar++;
				cout << "You now have a crowbar." << endl;
			}
			else if (items >= 3)
			{
				cout << "You already have three items. You can only carry three." << endl;
			}
		}

		if (y_nFive == 'n' || y_nFive == 'N')
		{
			cout << "Suit yourself." << endl;
		}

		if (look == 'U' || look == 'u')
		{
			cout << "While looking through the upstairs bedroom you find some an axe. Do you want to keep the axe?"
				<< "\n Y/N" << endl;
			cin >> y_nFive;
			if (y_nFive == 'Y' || y_nFive == 'y')
			{
				if (items < 3)
				{
					items++;
					axe++;
					cout << "You now have an axe." << endl;


				}
				else if (items >= 3){
					cout << "You already have three items. You can only carry three." << endl;

				}
			}
			if (y_nFive == 'n' || y_nFive == 'N'){
				cout << "Suit yourself." << endl;
			}
		}

		if (look == 'M' || look == 'm')
		{
			cout << "While looking through the master bedroom you find a letter addressed to no one in particular. Do you want to keep the letter?"
				<< "\n Y/N" << endl;
			cin >> y_nFive;
			if (y_nFive == 'Y' || y_nFive == 'y')
			{
				if (items < 3)
				{
					items++;
					letter++;
					cout << "You now have a letter." << endl;


				}
				else if (items >= 3){
					cout << "You already have three items. You can only carry three." << endl;
				}
			}
			if (y_nFive == 'n' || y_nFive == 'N')
			{
				cout << "Suit yourself." << endl;
			}
		}
		if (look == 'N' || look == 'n')
		{
			cout << "While looking through the bathroom you find a pen and paper . Do you want to take the pen and paper with you? (Only counts as one item)"
				<< "\n Y/N" << endl;
			cin >> y_nFive;
			if (y_nFive == 'Y' || y_nFive == 'y')
			{
				if (items < 3)
				{
					items++;
					p_p++;
					cout << "You now have blue prints." << endl;
				}
				else if (items >= 3){
					cout << "You already have three items. You can only carry three." << endl;
				}
			}
			if (y_nFive == 'n' || y_nFive == 'N'){
				cout << "Suit yourself." << endl;
			}
		}
		if (look == 'a' || look == 'A')
		{
			cout << "While looking through the attic you find some blueprints. Do you want to keep these blue prints?"
				<< "\n Y/N" << endl;
			cin >> y_nFive;
			if (y_nFive == 'Y' || y_nFive == 'y')
			{
				if (items < 3)
				{
					items++;
					blueprint++;
					cout << "You now have blue prints." << endl;


				}
				else if (items >= 3)
				{
					cout << "You already have three items. You can only carry three." << endl;
				}
			}
			if (y_nFive == 'n' || y_nFive == 'N'){
				cout << "Suit yourself." << endl;
			}

		}

	} while (true);

	return 0;
}


