Jump to content
  • Advertisement
Sign in to follow this  
lordoftools

debugging difficulties

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

THE REQUEST: hey guys im having somne trouble debugging this on my own and would appreciate some help. THE PURPOSE: im trying to make a clone of the drug wars game and im having trouble with the selling function. i need it to scan an array (strDrugArray) for the drugs put them into a list with numerical values referencing each option. use other arrays to store what the drug name is, the quantity of the drug that the person has (intQuantArray), how much the drug costed them (intInvArray), and what it is selling for (intDrugArray). Then is must check to see if the menu value which was choosen is valid and make sure that he actually has as much of that drug as he is trying to sell. THE PROBLEM: when i run it a few issues occur: 1. After buying some drugs (ie. weed and acid) i go to the sell menu and sometimes weed and acid appear but sometimes they do not. If i use the canel button (0) and reenter the sell menu without changing the drugs which i bought at random it will work or simply give me a different number of the drugs i have to appear. The appsents of a drug appearing is a possibility. 2. While the menu value checking for the choice of drugs appears to work the value checking for the quantity does not. It always considers your choice invalid even though when then conditions were tested they appear fine. IMPORTANT INFO; using MSVC++ THE PROBLEM FUNCTION:
[source code=cpp]
void SellDrugsMenu()
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	int cnt, cnt2, x, intSell[12], intChoice, intQuant;

	//print menu
	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);
	cout<<"What drugs do you want to sell?\n\n";

	cnt=0;
	cnt2=1;
	//prints the sell options (can only sell to citys who are buying)
	while (cnt<12 && strDrugArray[cnt] !=" ")
	{
		for (x=0;x<=11;x++)
		{
			if(strDrugArray[cnt]==strInvArray[x])
			{
				cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
				cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
				intSell[cnt2]=cnt;
				cnt2++;
			}
		}
		cnt++;
	}

	cout<<"\nSelect Drug to Sell (0 to cancel): ";
	cin>>intChoice;
	
	//reprint menu if invalid drug is choosen
	while (intChoice>cnt2-1 || intChoice<0)
	{
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"INVALID DRUG CHOICE PLEASE CHOOSE AGAIN!\n\n";
		cout<<"What drugs do you want to sell?\n\n";
		cnt=0;
		cnt2=1;
		//prints the sell options (can only sell to citys who are buying)
		while (cnt<12 && strDrugArray[cnt] !=" ")
		{
			for (x=0;x<=11;x++)
			{
				if(strDrugArray[cnt]==strInvArray[x])
				{
					cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
					cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
					intSell[cnt2]=cnt;
					cnt2++;
				}
			}
			cnt++;
		}
		
		cout<<"\nSelect Drug to Sell (0 to cancel): ";
		cin>>intChoice;
	}

	//if the cancel value is entered return to the city
	if (intChoice==0)
		goto City;

	cout<<"\nQuantity (0 to cancel): ";
	cin>>intQuant;

	//reprint menu if invalid quantity is choosen
	while ((intQuant>intQuantArray[intChoice]) || (intQuant<0))
	{
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"INVALID QUANTITY CHOICE PLEASE CHOOSE AGAIN!\n\n";
		cout<<"What drugs do you want to sell?\n\n";
		cnt=0;
		cnt2=1;
		//prints the sell options (can only sell to citys who are buying)
		while (cnt<12 && strDrugArray[cnt] !=" ")
		{
			for (x=0;x<=11;x++)
			{
				if(strDrugArray[cnt]==strInvArray[x])
				{
					cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
					cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
					intSell[cnt2]=cnt;
					cnt2++;
				}
			}
			cnt++;
		}

		cout<<"\nSelect Drug to Sell (0 to cancel): "<<intChoice<<"\n";

		cout<<"\nQuantity (0 to cancel): ";
		cin>>intQuant;
	}

	//if the cancel value is entered return to the city
	if (intQuant==0)
		goto City;

	//find the drug the selection is refering to and set the proper values for sale

	//debugger code
	getch();

	//return to the city
City:
	CityOperations(false);

	//reverts back to old colors
	SetConsoleColors(hConsole, 10, 0);

}

THE FULL CODE;
[source code=cpp]
//for VC++
#include "stdafx.h"

//for basic functions i.e. (cout,cin)
#include <iostream>
#include <afx.h>

//for file manipulation
#include <fstream>
#include <cstdlib>

//For getch()/getche()
#include <conio.h>

//For srand() and time()
#include <stdio.h>
#include <stdlib.h> //also for string to int convertions and visa versa
#include <time.h>

//for the string convertions
#include <sstream>
#include <cstring>
#include <stdexcept>

//for ease of use
using namespace std;

//Global Variable Declaration
struct USERDATA
{
	string Name, Gun, Location;
	int Cash, Debt, Bank, Hentchmen, Health, Space, Day;
	double GunRate;
};
struct LOCDATA
{
	string Name;
	int Police, minDrugs, maxDrugs;
};
int i;
struct LOCDATA loc;
struct USERDATA profile;
enum Drugs {ACID=1, COCAINE, HASHISH, HERION, LUDES, MDA, OPIUM, PCP, PEYOTE, SHROOMS, SPEED, WEED};
enum LOCS {BRONX=1, GHETTO, CENTRALPARK, MANHATTAN, CONEYISLAND, BROOKLYN, QUEENS, STATENISLAND};
int intDrugArray[12];
string strDrugArray[12];
int intInvArray[12];
string strInvArray[12];
int intQuantArray[12];
string strPath;

//function delcarations
WORD SetConsoleColors(HANDLE hConsole, WORD wColorText, WORD wColorBkg);
WORD GetConsoleColors(HANDLE hConsole);
wstring get_module_path_wide(void);
string wsts(const wstring &src_string);
int MainMenu();
int MenuHandler();
string ProfileMenu();
inline std::string stringify(int x);
string BufferStr(string strString, int MAX_LEN);
void BuyingDrugs(string Drug, int Price);
void PrintStats();
void CityOperations(bool NewDay);
void BankMenu();
void SellDrugsMenu();
void BuyDrugsMenu();
void BuyingGun(string Gun, int Price);
void ChangeLocMenu();
void LoanSharkMenu();
void SaveGame();
bool CheckSaved();

//Start off function
int main(int argc, char* argv[])
{
	//Initialize random generator 
	srand ( time(NULL) );

	//Initialize global variables
	intInvArray[250]=0;
	strPath=wsts(get_module_path_wide());

	//Runs the menus and terminates the program if needed
	return MenuHandler();
}

int MenuHandler()
{
	//Function level Delcarations
	string strProfile, SavedFile=strPath + "\\profiles.dat", strTemp;
	char chrLine[2000];
	int intMnuOpt;

	//Displays Main Menu
	intMnuOpt=MainMenu();

	//ERROR code
	if (intMnuOpt==0)
	{
		system("cls");
		cout<<"int MainMenu() returned ERROR code '0'\n";
	}

	//New Game code
	if (intMnuOpt==1)
	{
		//Variable initalization. 
		profile.Bank=0;
		profile.Health=100;
		profile.Day=1;
		profile.Cash=rand()%3000 + 2000;
		profile.Debt=rand()%9000 + 1000;
		profile.Gun="NONE";
		profile.GunRate=0;
		profile.Location="BRONX";
		profile.Hentchmen=rand()%4 + 7;
		profile.Space=profile.Hentchmen * 10;
		loc.maxDrugs=12;

		//Set user name.
		system("cls");
		cout<<"Enter your name: ";
		cin>>strTemp;
		profile.Name=strTemp.c_str();
		
		//Starts off in BRONX
		loc.Name="BRONX";
		loc.minDrugs=7;
		loc.Police=10;
		CityOperations(false);
	}

	//Load Profile code
	if (intMnuOpt==2)
	{
		//displays menu, prompts profile choice, stores the user ID
		strProfile=ProfileMenu();

		//ERROR checking
		if (strProfile=="NULL")
		{
			system("cls");
			cout<<"string ProfileMenu() returned ERROR code 'NULL' (Choice integer was left empty or invalid).\n\n";
			cout<<"Press any key to return to the Main Menu.";
			getch();
			MenuHandler();
		}

		//check for cancel msg
		if (strProfile=="MainMenu")
		{
			system("cls");
			MenuHandler();
		}

		//Load profile settings and start the game
		fstream inFile(SavedFile.c_str(), ios::in);

		inFile.getline(chrLine,2000);

		//convert to string array
		strTemp=chrLine[0];
		for (i=1; i<=1999; i++)
			strTemp=strTemp+chrLine;
		
		while (strTemp.find(strProfile)==std::string::npos)
		{
			inFile.getline(chrLine,2000);

			//convert to string array
			strTemp=chrLine[0];
			for (i=1; i<=1999; i++)
				strTemp=strTemp+chrLine;
		};

		//sets the profile.name
		strTemp=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
		profile.Name=strTemp;

		//sets the rest of the variables
		int x;
		for(x=1; x<=13; x++)
		{
			inFile.getline(chrLine,2000);
			//convert to string array
			strTemp=chrLine[0];
			for (i=1; i<=1999; i++)
				strTemp=strTemp+chrLine;

			switch (x)
			{
				case 1:
					profile.Gun=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
					break;
				case 2:
					profile.Location=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
					break;
				case 3:
					profile.Cash=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 4:
					profile.Debt=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 5:
					profile.Bank=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 6:
					profile.Hentchmen=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 7:
					profile.Health=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 8:
					profile.Space=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 9:
					profile.Day=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 10:
					profile.GunRate=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 11:
					loc.Name=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
					break;
				case 12:
					loc.Police=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 13:
					loc.minDrugs=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
				case 14:
					loc.maxDrugs=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
					break;
			}
		}		

		//start game
		CityOperations(false);
	}

	//Quit Code
	if (intMnuOpt==3)
	{
		system("cls");
		cout<<"Thank you for playing \"Drug Wars\" clone -- By: Derik Hammer.";
		getch();
	}

	//Application terminator
	return 0;
}

//Operates the features of this location
void CityOperations(bool NewDay)
{
	if (NewDay==true)
	{
		//increase the day
		profile.Day++;

		//increase debt due to interest
		if (profile.Day%7==0)
			profile.Debt=profile.Debt+(profile.Debt*.12);
	}

	system("cls");
	PrintStats();

	//sets up the drugs which are in this city (price, how many, what kind)
	int intTemp, cnt=0, DrugChecker;
	bool PickAgain;
	int intChoice;
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	
	intTemp=rand()%(loc.maxDrugs-loc.minDrugs)+loc.minDrugs;

	while (intTemp-1>=cnt)
	{
		do 
		{
			PickAgain=false;
			DrugChecker=rand()%12+1;
			for (i=0; i<=11; i++)
			{
				if (intDrugArray==DrugChecker)
					PickAgain=true;
			}
		}
		while (PickAgain==true);
		intDrugArray[cnt]=DrugChecker;
		cnt++;
	};

	for (i=intTemp; i<=11; i++)
		intDrugArray=0;

	//Converts the int array to a string with the drug names and then makes the int array
	//into the prices array at the same time.
	for (i=0; i<=11; i++)
	{
		switch (intDrugArray)
		{	
			case ACID:
				strDrugArray="ACID";
				intDrugArray=rand()%3400+1000;
				break;

			case COCAINE:
				strDrugArray="COCAINE";
				intDrugArray=rand()%14000+15000;
				break;

			case HASHISH:
				strDrugArray="HASHISH";
				intDrugArray=rand()%800+480;
				break;

			case HERION:
				strDrugArray="HERION";
				intDrugArray=rand()%7500+5500;
				break;

			case LUDES:
				strDrugArray="LUDES";
				intDrugArray=rand()%49+11;
				break;

			case MDA:
				strDrugArray="MDA (Ecstasy)";
				intDrugArray=rand()%2900+1500;
				break;

			case OPIUM:
				strDrugArray="OPIUM";
				intDrugArray=rand()%710+540;
				break;

			case PCP:
				strDrugArray="PCP";
				intDrugArray=rand()%1500+1000;
				break;

			case PEYOTE:
				strDrugArray="PEYOTE";
				intDrugArray=rand()%480+220;
				break;

			case SHROOMS:
				strDrugArray="SHROOMS";
				intDrugArray=rand()%670+630;
				break;

			case SPEED:
				strDrugArray="SPEED";
				intDrugArray=rand()%160+90;
				break;

			case WEED:
				strDrugArray="WEED";
				intDrugArray=rand()%575+315;
				break;

			default:
				strDrugArray="ERROR: NO_DRUG";
				break;
		}	
	}

	//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
	SetConsoleColors(hConsole, 12, 0);

	//Run cops coding here, seperate function for the battle run only option when un-armed
	if (NewDay==true)
	{
		if((rand()%99+1)<=(loc.Police-profile.GunRate))
		{
			int money=profile.Cash*.2;
			string st;
			profile.Cash=profile.Cash-money;
			system("cls");
			PrintStats();
			//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
			SetConsoleColors(hConsole, 12, 0);
			cout<<"BUSTED !! -- Gotta bribe the cops, and it costs you 20% of your cash.\n\n";
			cout<<BufferStr("LOST: "+stringify(money),20)<<"REMAINING: "<<profile.Cash<<"\n\n";
		}
	}

	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);
	//print city menu
	cout<<"Welcome to "<<loc.Name<<"!\n";
	
	//if its the home city [BRONX] then display spec menu
	if (loc.Name=="BRONX")
	{
specPickAgain:
		cout<<"1. Check out what's available.\n";
		cout<<"2. Sell Drugs.\n";
		cout<<"3. Change location.\n";
		cout<<"4. Visit Bank.\n";
		cout<<"5. Visit Loan Shark.\n";
		cout<<"6. Save Game.\n";
		cout<<"7. Quit.\n";
		cout<<"Selection: ";
		//await choice
		cin>>intChoice;

		switch (intChoice)
		{
			case 1:
				BuyDrugsMenu();
				break;

			case 2:
				SellDrugsMenu();
				break;

			case 3:
				ChangeLocMenu();
				break;

			case 4:
				BankMenu();
				break;

			case 5:
				LoanSharkMenu();
				break;

			case 6:
				SaveGame();
				break;

			case 7:
				system("cls");
				SetConsoleColors(hConsole, 15, 0);
				cout<<"Thank you for playing \"Drug Wars\" clone -- By: Derik Hammer.";
				getch();
				break;

			default:
				goto specPickAgain;
				break;
		}
	}
	else
	{
normPickAgain:
		cout<<"1. Check out available Drugs.\n";
		cout<<"2. Sell Drugs.\n";
		cout<<"3. Change location.\n";
		cout<<"Selection: ";
		//await choice
		cin>>intChoice;

		switch (intChoice)
		{

		case 1:
			BuyDrugsMenu();
			break;

		case 2:
			SellDrugsMenu();
			break;

		case 3:
			ChangeLocMenu();
			break;

		default:
			system("cls");
			PrintStats();
			//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
			SetConsoleColors(hConsole, 10, 0);
			cout<<"Invalid choice, please pick again.\n";
			goto normPickAgain;
			break;

		}
	}

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);
}

void BankMenu()
{
	//function level delcarations
	char chrChoice;
	int intAmt;
	bool boolDep=false, boolWithd=false;

	//reset screen and disp stats again
	system("cls");
	PrintStats();

	//print bank options
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	SetConsoleColors(hConsole, 10, 0);

	cout<<"Welcome to the Bank!\n\n";

	//check to see what he can do in the bank
	if (profile.Cash>0)
	{
		cout<<"D. Deposit (Up to $"<<profile.Cash<<")\n";
		boolDep=true;
	}
	if (profile.Bank>0)
	{
		cout<<"W. Withdraw (Up to $"<<profile.Bank<<")\n";
		boolWithd=true;
	}
	cout<<"L. Leave Bank.\n";	
	//await choice
	cout<<"Selection: ";
	cin>>chrChoice;

	if ((chrChoice=='d' || chrChoice=='D') && boolDep==true)
	{
		//disp deposit menu
		system("cls");
		PrintStats();
		SetConsoleColors(hConsole, 10, 0);
DepAgain:
		cout<<"Bank Deposit -- $"<<profile.Cash<<" available.\n\n";
		cout<<"Deposit Amount (0 to cancel): ";
		//await choice
		cin>>intAmt;
		if (intAmt>profile.Cash || intAmt<0)
		{
			system("cls");
			PrintStats();
			SetConsoleColors(hConsole, 10, 0);
			cout<<"Invalid $ amount please pick again.\n\n";
			goto DepAgain;
		}
		//alter $ amounts accordingly
		profile.Cash=profile.Cash-intAmt;
		profile.Bank=profile.Bank+intAmt;
	}
	else if ((chrChoice=='w' || chrChoice=='W') && boolWithd==true)
	{
		//disp withdraw menu
		system("cls");
		PrintStats();
		SetConsoleColors(hConsole, 10, 0);
WDrawAgain:
		cout<<"Bank Withdraw -- $"<<profile.Bank<<" available.\n\n";
		cout<<"Withdraw Amount (0 to cancel): ";
		//await choice
		cin>>intAmt;
		if (intAmt>profile.Bank || intAmt<0)
		{
			system("cls");
			PrintStats();
			SetConsoleColors(hConsole, 10, 0);
			cout<<"Invalid $ amount please pick again.\n\n";
			goto WDrawAgain;
		}
		//alter $ amounts accordingly
		profile.Bank=profile.Bank-intAmt;
		profile.Cash=profile.Cash+intAmt;

	}
	else if (chrChoice=='l' || chrChoice=='L')
	{
		//return to your city
		CityOperations(false);
	}
	else
		BankMenu();

	CityOperations(false);

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);
}
void SellDrugsMenu()
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	int cnt, cnt2, x, intSell[12], intChoice, intQuant;

	//print menu
	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);
	cout<<"What drugs do you want to sell?\n\n";

	cnt=0;
	cnt2=1;
	//prints the sell options (can only sell to citys who are buying)
	while (cnt<12 && strDrugArray[cnt] !=" ")
	{
		for (x=0;x<=11;x++)
		{
			if(strDrugArray[cnt]==strInvArray[x])
			{
				cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
				cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
				intSell[cnt2]=cnt;
				cnt2++;
			}
		}
		cnt++;
	}

	cout<<"\nSelect Drug to Sell (0 to cancel): ";
	cin>>intChoice;
	
	//reprint menu if invalid drug is choosen
	while (intChoice>cnt2-1 || intChoice<0)
	{
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"INVALID DRUG CHOICE PLEASE CHOOSE AGAIN!\n\n";
		cout<<"What drugs do you want to sell?\n\n";
		cnt=0;
		cnt2=1;
		//prints the sell options (can only sell to citys who are buying)
		while (cnt<12 && strDrugArray[cnt] !=" ")
		{
			for (x=0;x<=11;x++)
			{
				if(strDrugArray[cnt]==strInvArray[x])
				{
					cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
					cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
					intSell[cnt2]=cnt;
					cnt2++;
				}
			}
			cnt++;
		}
		
		cout<<"\nSelect Drug to Sell (0 to cancel): ";
		cin>>intChoice;
	}

	//if the cancel value is entered return to the city
	if (intChoice==0)
		goto City;

	cout<<"\nQuantity (0 to cancel): ";
	cin>>intQuant;

	//reprint menu if invalid quantity is choosen
	while ((intQuant>intQuantArray[intChoice]) || (intQuant<0))
	{
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"INVALID QUANTITY CHOICE PLEASE CHOOSE AGAIN!\n\n";
		cout<<"What drugs do you want to sell?\n\n";
		cnt=0;
		cnt2=1;
		//prints the sell options (can only sell to citys who are buying)
		while (cnt<12 && strDrugArray[cnt] !=" ")
		{
			for (x=0;x<=11;x++)
			{
				if(strDrugArray[cnt]==strInvArray[x])
				{
					cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
					cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
					intSell[cnt2]=cnt;
					cnt2++;
				}
			}
			cnt++;
		}

		cout<<"\nSelect Drug to Sell (0 to cancel): "<<intChoice<<"\n";

		cout<<"\nQuantity (0 to cancel): ";
		cin>>intQuant;
	}

	//if the cancel value is entered return to the city
	if (intQuant==0)
		goto City;

	//find the drug the selection is refering to and set the proper values for sale

	//debugger code
	getch();

	//return to the city
City:
	CityOperations(false);

	//reverts back to old colors
	SetConsoleColors(hConsole, 10, 0);

}

void BuyingDrugs(string Drug, int Price)
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	int intAmt;

	//print menu
	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);
	cout<<"How much "<<Drug<<" you want? ($"<<Price<<" each)"<<endl;
	cout<<"Quantity (0 to cancel): ";
	cin>>intAmt;
	
	while ((intAmt*Price>profile.Cash) || (intAmt>profile.Space))
	{
		//print menu
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"You don't have enough money or enough space for that much "<<Drug<<"!\n\n";
		cout<<"How much "<<Drug<<" you want? ($"<<Price<<" each)"<<endl;
		cout<<"Quantity (0 to cancel): ";
		cin>>intAmt;
	}

	//updates the space in your inv
	profile.Space=profile.Space-intAmt;
	profile.Cash=profile.Cash-(intAmt*Price);

	//fills the drug into the available array slot
	if (intAmt !=0)
	{
		for (i=0; i<=11; i++)
		{
			if (intInvArray==0)
			{
				strInvArray=Drug;
				intInvArray=Price;
				intQuantArray=intAmt;
				i=12;
			}
		}
	}

	//reverts back to old colors
	SetConsoleColors(hConsole, 10, 0);

	BuyDrugsMenu();
}

void CheckWhichDrug(char chrDrug, int intTemp[12])
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	int intChoice;

RePick:
	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);

	switch (chrDrug)
	{
		case 'h':
			cout<<"Did you want HASHISH or HERION?\n\n";
			cout<<"1. HASHISH.\n";
			cout<<"2. HERION.\n";
			cout<<"Selection (0 to cancel):";
			//await choice
			cin>>intChoice;

			switch (intChoice)
			{
				case 0:
					BuyDrugsMenu();
				case 1:
					BuyingDrugs("HASHISH", intTemp[3]);
					break;
				case 2:
					BuyingDrugs("HERION", intTemp[4]);
					break;
				default:
					goto RePick;
					break;
			}
			break;

		case 'p':
			cout<<"Did you want PCP or PEYOTE?\n\n";
			cout<<"1. PCP.\n";
			cout<<"2. PEYOTE.\n";
			cout<<"Selection (0 to cancel):";
			//await choice
			cin>>intChoice;

			switch (intChoice)
			{
				case 0:
					BuyDrugsMenu();
				case 1:
					BuyingDrugs("PCP", intTemp[8]);
					break;
				case 2:
					BuyingDrugs("PEYOTE", intTemp[9]);
					break;
				default:
					goto RePick;
					break;
			}
			break;

		case 's':
			cout<<"Did you want SHROOMS or SPEED?\n\n";
			cout<<"1. SHROOMS.\n";
			cout<<"2. SPEED.\n";
			cout<<"Selection (0 to cancel):";
			//await choice
			cin>>intChoice;

			switch (intChoice)
			{
				case 0:
					BuyDrugsMenu();
				case 1:
					BuyingDrugs("SHROOMS", intTemp[10]);
					break;
				case 2:
					BuyingDrugs("SPEED", intTemp[11]);
					break;
				default:
					goto RePick;
					break;
			}
			break;
	}
}

void BuyDrugsMenu()
{
	//Function level Declarations
	char chrChoice;	
	bool oneS=false, twoS=false, oneP=false, twoP=false, oneH=false, twoH=false;
	int intTemp[13], TradeIn;
	string buyGun;
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);

	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);

	for (i=0; i<=11; i++)
	{
		if (intDrugArray<=profile.Cash)
			goto SkipFor;
	}
	cout<<"Your broke! Go somewhere else or go sell some of your product to make up the $$$.\n";
	goto EndOfFunc;
SkipFor:

	//print menu options
	cout<<"So you wanta buy some dope? Here's your choices...\n\n";
InvalidChoice:
	for (i=0; i<=11; i++)
	{
		if (strDrugArray=="ACID")
		{
			cout<<"A. ACID - $"<<intDrugArray<<endl;
			intTemp[1]=intDrugArray;
		}
		else if (strDrugArray=="COCAINE")
		{
			cout<<"C. COCAINE - $"<<intDrugArray<<endl;
			intTemp[2]=intDrugArray;
		}
		else if (strDrugArray=="HASHISH")
		{
			cout<<"H. HASHISH - $"<<intDrugArray<<endl;
			intTemp[3]=intDrugArray;
			oneH=true;
		}
		else if (strDrugArray=="HERION")
		{
			cout<<"H. HERION - $"<<intDrugArray<<endl;
			intTemp[4]=intDrugArray;
			twoH=true;
		}
		else if (strDrugArray=="LUDES")
		{
			cout<<"L. LUDES - $"<<intDrugArray<<endl;
			intTemp[5]=intDrugArray;
		}
		else if (strDrugArray=="MDA")
		{
			cout<<"M. MDA - $"<<intDrugArray<<endl;
			intTemp[6]=intDrugArray;
		}
		else if (strDrugArray=="OPIUM")
		{
			cout<<"O. OPIUM - $"<<intDrugArray<<endl;
			intTemp[7]=intDrugArray;
		}
		else if (strDrugArray=="PCP")
		{
			cout<<"P. PCP - $"<<intDrugArray<<endl;
			intTemp[8]=intDrugArray;
			oneP=true;
		}
		else if (strDrugArray=="PEYOTE")
		{
			cout<<"P. PEYOTE - $"<<intDrugArray<<endl;
			intTemp[9]=intDrugArray;
			twoP=true;
		}
		else if (strDrugArray=="SHROOMS")
		{
			cout<<"S. SHROOMS - $"<<intDrugArray<<endl;
			intTemp[10]=intDrugArray;
			oneS=true;
		}
		else if (strDrugArray=="SPEED")
		{
			cout<<"S. SPEED - $"<<intDrugArray<<endl;
			intTemp[11]=intDrugArray;
			twoS=true;
		}
		else if (strDrugArray=="WEED")
		{
			cout<<"W. WEED - $"<<intDrugArray<<endl;
			intTemp[12]=intDrugArray;
		}
	}

	//randomize the gun selection and determine price with trade-in value of old gun
	if (rand()%3+1==2)
	{
		if (profile.Gun=="BARETTA")
			TradeIn=1500;
		if (profile.Gun==".38SPEC")
			TradeIn=1725;
		if (profile.Gun=="RUGER")
			TradeIn=1450;
		if (profile.Gun=="SATNIGHTSPEC")
			TradeIn=1600;
		if (profile.Gun=="NONE")
			TradeIn=0;

		switch (rand()%3+1)
		{
			case 1:
				cout<<"\nG. Baretta (Reduces police by 7%, Current Rating="<<20-profile.GunRate<<"%) - $3000."<<endl;
				cout<<"\t$"<<3000-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
				intTemp[13]=3000-TradeIn;
				buyGun="Baretta";
				break;
			case 2:
				cout<<"\nG. .38 Special (Reduces police by 13%, Current Rating="<<20-profile.GunRate<<"%) - $3500."<<endl;
				cout<<"\t$"<<3500-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
				intTemp[13]=3500-TradeIn;
				buyGun=".38 Special";
				break;
			case 3:
				cout<<"\nG. Ruger (Reduces police by 5%, Current Rating="<<20-profile.GunRate<<"%) - $2900."<<endl;
				cout<<"\t$"<<2900-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
				intTemp[13]=2900-TradeIn;
				buyGun="Ruger";
				break;
			case 4:
				cout<<"\nG. Saturday night Special (Reduces police by 10%, Current Rating="<<20-profile.GunRate<<"%) - $3100."<<endl;
				cout<<"\t$"<<3100-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
				intTemp[13]=3100-TradeIn;
				buyGun="Saturday night Special";
				break;
		}
	}
	cout<<"\nB. Back to "<<profile.Location<<".\n";
	cout<<"Selection: ";
	cin>>chrChoice;

	//check for duplicate letters and proseed with purchase
	if (chrChoice=='A' || chrChoice=='a')
	{
		BuyingDrugs("ACID", intTemp[1]);
	}
	else if (chrChoice=='B' || chrChoice=='b')
	{
		CityOperations(false);
	}
	else if (chrChoice=='C' || chrChoice=='c')
	{
		BuyingDrugs("COCAINE", intTemp[13]);
	}
	else if (chrChoice=='G' || chrChoice=='g')
	{
		BuyingGun(buyGun, intTemp[13]);
	}
	//for duplicate H's
	else if ((chrChoice=='H' || chrChoice=='h') && (oneH==true && twoH==true))
	{
		CheckWhichDrug('h', intTemp);
	}
	//for none duplicate
	else if ((chrChoice=='H' || chrChoice=='h') && (oneH==false || twoH==false))
	{
		for (i=0; i<=11; i++)
		{
			if (strDrugArray=="HASHISH")
			{
				BuyingDrugs("HASHISH", intTemp[3]);
				i=12;
			}
			if (strDrugArray=="HERION")
			{
				BuyingDrugs("HERION", intTemp[4]);
				i=12;
			}
		}
	}
	else if (chrChoice=='L' || chrChoice=='l')
	{
		BuyingDrugs("LUDES", intTemp[5]);
	}
	else if (chrChoice=='M' || chrChoice=='m')
	{
		BuyingDrugs("MDA", intTemp[6]);
	}
	else if (chrChoice=='O' || chrChoice=='o')
	{
		BuyingDrugs("OPIUM", intTemp[7]);
	}
	//for duplicate P's
	else if ((chrChoice=='P' || chrChoice=='p') && (oneP==true && twoP==true))
	{
		CheckWhichDrug('p', intTemp);
	}
	//for none duplicate
	else if ((chrChoice=='P' || chrChoice=='p') && (oneP==false || twoP==false))
	{
		for (i=0; i<=11; i++)
		{
			if (strDrugArray=="PCP")
			{
				BuyingDrugs("PCP", intTemp[8]);
				i=12;
			}
			if (strDrugArray=="PEYOTE")
			{
				BuyingDrugs("PEYOTE", intTemp[9]);
				i=12;
			}
		}
	}
	//for duplicate S's
	else if ((chrChoice=='S' || chrChoice=='s') && (oneS==true && twoS==true))
	{
		CheckWhichDrug('s', intTemp);
	}
	//for none duplicate
	else if ((chrChoice=='S' || chrChoice=='s') && (oneS==false || twoS==false))
	{
		for (i=0; i<=11; i++)
		{
			if (strDrugArray=="SHROOMS")
			{
				BuyingDrugs("SHROOMS", intTemp[10]);
				i=12;
			}
			if (strDrugArray=="SPEED")
			{
				BuyingDrugs("SPEED", intTemp[11]);
				i=12;
			}
		}
	}
	else if (chrChoice=='W' || chrChoice=='w')
	{
		BuyingDrugs("WEED", intTemp[12]);
	}
	else
	{
		system("cls");
		PrintStats();
		SetConsoleColors(hConsole, 10, 0);
		cout<<"Invalid selection please pick again...\n\n";
		goto InvalidChoice;
	}

EndOfFunc:
	//reverts colors back
	SetConsoleColors(hConsole, 15, 0);
}

void BuyingGun(string Gun, int Price)
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	int intAmt=1;

	//print menu
	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	
	if ((intAmt*Price>profile.Cash))
	{
		//print menu
		system("cls");
		PrintStats();
		//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
		SetConsoleColors(hConsole, 10, 0);
		cout<<"You don't have enough money for the "<<Gun<<"!\n\n";
		cout<<"Press any key to return to the Buy Drugs menu."<<endl;
		getch();
		goto Back;
	}

	//updates info
	profile.Cash=profile.Cash-Price;
	if (Gun=="Saturday night Special")
	{
		profile.Gun="SATNIGHTSPEC";
		profile.GunRate=10;
	}
	if (Gun=="Baretta")
	{
		profile.Gun="BARETTA";
		profile.GunRate=13;
	}
	if (Gun==".38 Special")
	{
		profile.Gun=".38SPEC";
		profile.GunRate=7;
	}
	if (Gun=="Ruger")
	{
		profile.Gun="RUGER";
		profile.GunRate=5;
	}

	//reverts back to old colors
	SetConsoleColors(hConsole, 10, 0);

Back:
	BuyDrugsMenu();
}

void ChangeLocMenu()
{
	//Function level Declarations
	int intChoice;	
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);

	system("cls");
	PrintStats();
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);
LocPickAgain:
	cout<<"Where would you like to go?\n\n";
	cout<<"1. BRONX\n";
	cout<<"2. GHETTO\n";
	cout<<"3. CENTRAL PARK\n";
	cout<<"4. MANHATTAN\n";
	cout<<"5. CONEY ISLAND\n";
	cout<<"6. BROOKLYN\n";
	cout<<"7. QUEENS\n";
	cout<<"8. STATEN ISLAND\n";
	cout<<"9. Back to "<<loc.Name<<"\n";
	cout<<"Selection: ";
	//await selection
	cin>>intChoice;

	switch (intChoice)
	{
		case BRONX:
			if (profile.Location=="BRONX")
				intChoice=9;
			profile.Location="BRONX";
			loc.Name="BRONX";
			loc.minDrugs=7;
			loc.maxDrugs=12;
			loc.Police=10;
			break;

		case GHETTO:
			if (profile.Location=="GHETTO")
				intChoice=9;
			profile.Location="GHETTO";
			loc.Name="GHETTO";
			loc.minDrugs=8;
			loc.maxDrugs=12;
			loc.Police=5;
			break;

		case CENTRALPARK:
			if (profile.Location=="CENTRALPARK")
				intChoice=9;
			profile.Location="CENTRALPARK";
			loc.Name="CENTRAL PARK";
			loc.minDrugs=6;
			loc.maxDrugs=12;
			loc.Police=15;
			break;

		case MANHATTAN:
			if (profile.Location=="MANHATTAN")
				intChoice=9;
			profile.Location="MANHATTAN";
			loc.Name="MANHATTAN";
			loc.minDrugs=4;
			loc.maxDrugs=12;
			loc.Police=45;
			break;

		case CONEYISLAND:
			if (profile.Location=="CONEYISLAND")
				intChoice=9;
			profile.Location="CONEYISLAND";
			loc.Name="CONEY ISLAND";
			loc.minDrugs=6;
			loc.maxDrugs=12;
			loc.Police=20;
			break;

		case BROOKLYN:
			if (profile.Location=="BROOKLYN")
				intChoice=9;
			profile.Location="BROOKLYN";
			loc.Name="BROOKLYN";
			loc.minDrugs=4;
			loc.maxDrugs=12;
			loc.Police=35;
			break;

		case QUEENS:
			if (profile.Location=="QUEENS")
				intChoice=9;
			profile.Location="QUEENS";
			loc.Name="QUEENS";
			loc.minDrugs=6;
			loc.maxDrugs=12;
			loc.Police=30;
			break;

		case STATENISLAND:
			if (profile.Location=="STATENISLAND")
				intChoice=9;
			profile.Location="STATENISLAND";
			loc.Name="STATEN ISLAND";
			loc.minDrugs=6;
			loc.maxDrugs=12;
			loc.Police=20;
			break;

		case 9:
			break;

		default: 
			system("cls"); 
			PrintStats();
			//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
			SetConsoleColors(hConsole, 10, 0);
			cout<<"Invalid entry please pick again.\n\n";
			goto LocPickAgain;
			break;
	}

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);

	//if the city never changes then don't penalize with a new day
	if (intChoice==9)
	{
		CityOperations(false);
	}
	else
	{
		CityOperations(true);
	}
}
void LoanSharkMenu()
{
	//Function level Declarations
	int intChoice, intAmt;
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	
	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);

LoanChoiceAgain:

	//Prints the loan shark welcome msg
	system("cls");
	PrintStats();
	SetConsoleColors(hConsole, 10, 0);
	cout<<"Welcome to Shady Shawn's Shack!\n";
	cout<<"Rates are currently at 12% factored in each Sunday (7th day).\n\n";
	
	//allows you to pay off debt only when you have some
	if(profile.Debt>0)
	{
		//prints menu
		cout<<"1. Pay off debt.\n";
		cout<<"2. Leave Shady Shawn's.\n";
		cout<<"Selection: ";
		//await choice
		cin>>intChoice;

		switch (intChoice)
		{
			//run through pay off options/operations
			case 1:
				system("cls");
				PrintStats();
				SetConsoleColors(hConsole, 10, 0);
PLoanAgain:
				cout<<"Shady Shawn's Shack!\n\n";
				cout<<"Enter Amount to Pay off (0 to cancel): ";
				cin>>intAmt;
				if (intAmt>profile.Cash || intAmt<0)
				{
					system("cls");
					PrintStats();
					SetConsoleColors(hConsole, 10, 0);
					cout<<"Invalid $ amount please pick again.\n\n";
					goto PLoanAgain;
				}

				//redefines variables appropriatly
				profile.Cash=profile.Cash-intAmt;
				profile.Debt=profile.Debt-intAmt;

				break;

			//leaves the loan shark and heads back to the city without a day increase
			case 2:
				CityOperations(false);
				break;

			//sends you back to pick again due to invalid entry
			default:
				goto LoanChoiceAgain;
				break;

		}
	}
	else
	{
		//allows you to take out a loan when you have no debt
		cout<<"1. Take out a Loan.\n";
		cout<<"2. Leave Shady Shawn's.\n";
		cout<<"Selection: ";
		//await choice
		cin>>intChoice;

		switch (intChoice)
		{
			//prints options and runs the loan request operations
			case 1:
				system("cls");
				PrintStats();
				SetConsoleColors(hConsole, 10, 0);
PLoanAgain2:
				cout<<"Shady Shawn's Shack!\n\n";
				cout<<"Enter Amount of the Loan (0 to cancel): ";
				//await selection
				cin>>intAmt;

				//can't use negatives
				if (intAmt<0)
				{
					system("cls");
					PrintStats();
					SetConsoleColors(hConsole, 10, 0);
					cout<<"Invalid amount entered, try again man.\n\n";
					goto PLoanAgain2;
				}
				//only loans out up to 30000
				if (intAmt>=30000)
				{
					system("cls");
					PrintStats();
					SetConsoleColors(hConsole, 10, 0);
					cout<<"I only give out Loans of $30,000 and below, try again man.\n\n";
					goto PLoanAgain2;
				}

				//redefines variables appropriatly
				profile.Cash=profile.Cash+intAmt;
				profile.Debt=profile.Debt+intAmt;

				break;

			//send you back to the city without a day penalty
			case 2:
				CityOperations(false);
				break;

			//sends user through menu again due to invalid entry
			default:
				goto LoanChoiceAgain;
				break;
		}
	}

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);

	//sends user back to the city without day penalty
	CityOperations(false);
}

//checks to see if the use already has a profile by that name saved
bool CheckSaved()
{
	string Data=strPath + "\\profiles.dat", strTemp;
	ifstream inFile(Data.c_str());

	//check for file existance
	if(!(inFile.good()))
	{
		inFile.close();
		//Create file
		ofstream outFile(Data.c_str());
		outFile.close();
	}

	while (inFile >> Data)
	{
		strTemp="profile.name=" + profile.Name;
		if (Data==strTemp)
		{
			inFile.close();
			return(true);
		}
	};
	
	inFile.close();
	return (false);
}

//rewrites the files needed for saving
void SaveGame()
{
	bool Saved;
	string Data=strPath + "\\profiles.dat", strOldData[100], strOldData2[100], strTemp;
	char chrLine[2000];
	int cnt=0;

	//empty strOldData incase this isn't the first save
	for (i=0; i<=99; i++)
		strOldData=" ";

	//empty strOldData2 incase this isn't the first save
	for (i=0; i<=99; i++)
		strOldData2=" ";

	//check to see if the game is overwritting or a new save
	Saved=CheckSaved();

	if (Saved==false)
	{
		fstream inFile(Data.c_str(), ios::in);

		//store information in file for reprint
		while (! inFile.eof())
		{
			inFile.getline(chrLine,2000);

			//convert to string array
			strOldData[cnt]=chrLine[0];
			for (i=1; i<=1999; i++)
				strOldData[cnt]=strOldData[cnt]+chrLine;

			cnt++;
		};
		inFile.close();
		
		//rewrite the old info
		cnt=1;
		fstream outFile(Data.c_str(), ios::out);
		
		if (!(strOldData[0]==" "))
			outFile<<strOldData[0];
		while (!(strOldData[cnt]==" "))
		{
			outFile<<endl<<strOldData[cnt];
			cnt++;
		};

		//write the new info
		outFile<<endl<<endl;
		outFile<<"profile.name="<<profile.Name<<endl;
		outFile<<"profile.gun="<<profile.Gun<<endl;
		outFile<<"profile.location="<<profile.Location<<endl;
		outFile<<"profile.cash="<<profile.Cash<<endl;
		outFile<<"profile.debt="<<profile.Debt<<endl;
		outFile<<"profile.bank="<<profile.Bank<<endl;
		outFile<<"profile.hentchmen="<<profile.Hentchmen<<endl;
		outFile<<"profile.health="<<profile.Health<<endl;
		outFile<<"profile.space="<<profile.Space<<endl;
		outFile<<"profile.day="<<profile.Day<<endl;
		outFile<<"profile.gunrate="<<profile.GunRate<<endl;
		outFile<<"loc.name="<<loc.Name<<endl;
		outFile<<"loc.police="<<loc.Police<<endl;
		outFile<<"loc.mindrugs="<<loc.minDrugs<<endl;
		outFile<<"loc.maxdrugs="<<loc.maxDrugs;	
		
		outFile.close();
		
	}
	else
	{
		//open file
		fstream inFile(Data.c_str(), ios::in);

		//store information in file before the saved game for reprint
		cnt=0;
		inFile.getline(chrLine,2000);

		//convert to string array
		strOldData[cnt]=chrLine[0];
		for (i=1; i<=1999; i++)
			strOldData[cnt]=strOldData[cnt]+chrLine;

		//load pre-saved game data
		while (strOldData[cnt].find(profile.Name)==std::string::npos)
		{
			cnt++;
			
			inFile.getline(chrLine,2000);

			//convert to string array
			strOldData[cnt]=chrLine[0];
			for (i=1; i<=1999; i++)
				strOldData[cnt]=strOldData[cnt]+chrLine;
		};

		//remove the profile from the pre-saved game data
		strOldData[cnt-1]=" ";
		strOldData[cnt]=" ";

		//if the profile was found on the first getline
		if (strOldData[1]==" ")
			strOldData[0]=" ";

		//store information in file after the saved game for reprint
		inFile.getline(chrLine,2000);

		//convert to string array
		strTemp=chrLine[0];
		for (i=1; i<=1999; i++)
			strTemp=strTemp+chrLine;

		//scan until it finds the line with the last stat in the saved game [loc.maxdrugs=12]
		while (strTemp.find("loc.maxdrugs=12")==std::string::npos)
		{
			inFile.getline(chrLine,2000);
			
			//convert to string array
			strTemp=chrLine[0];
			for (i=1; i<=1999; i++)
				strTemp=strTemp+chrLine;
		};

		//store the rest of the file
		cnt=0;
		while (!(inFile.eof()))
		{
			inFile.getline(chrLine,2000);

			//convert to string array
			strOldData2[cnt]=chrLine[0];
			for (i=1; i<=1999; i++)
				strOldData2[cnt]=strOldData2[cnt]+chrLine;

			cnt++;
		};

		//if the profile was found on the first getline
		if (strOldData2[1]==" ")
			strOldData2[0]=" ";

		inFile.close();
		
		//rewrite the begining old info [1]
		cnt=1;
		fstream outFile(Data.c_str(), ios::out);

		if (!(strOldData[0]==" "))
			outFile<<strOldData[0];

		while (!(strOldData[cnt]==" "))
		{
			outFile<<endl<<strOldData[cnt];
			cnt++;
		};

		//write new saved data
		outFile<<endl<<endl;
		outFile<<"profile.name="<<profile.Name<<endl;
		outFile<<"profile.gun="<<profile.Gun<<endl;
		outFile<<"profile.location="<<profile.Location<<endl;
		outFile<<"profile.cash="<<profile.Cash<<endl;
		outFile<<"profile.debt="<<profile.Debt<<endl;
		outFile<<"profile.bank="<<profile.Bank<<endl;
		outFile<<"profile.hentchmen="<<profile.Hentchmen<<endl;
		outFile<<"profile.health="<<profile.Health<<endl;
		outFile<<"profile.space="<<profile.Space<<endl;
		outFile<<"profile.day="<<profile.Day<<endl;
		outFile<<"profile.gunrate="<<profile.GunRate<<endl;
		outFile<<"loc.name="<<loc.Name<<endl;
		outFile<<"loc.police="<<loc.Police<<endl;
		outFile<<"loc.mindrugs="<<loc.minDrugs<<endl;
		outFile<<"loc.maxdrugs="<<loc.maxDrugs<<endl;	

		//rewrite the end old info [2]
		cnt=1;

		if (!(strOldData2[0]==" "))
			outFile<<strOldData2[0];

		while (!(strOldData2[cnt]==" "))
		{
			outFile<<endl<<strOldData2[cnt];
			cnt++;
		};

		outFile.close();
	}

	//resume game
	CityOperations(false);
}

 
 //this class checks for bad convertions with stringify(int x)
 class BadConversion : public std::runtime_error 
 {
 public:
   BadConversion(const std::string& s)
     : std::runtime_error(s)
     { }
 };
 
 //converts ints into strings
 inline std::string stringify(int x)
 {
   std::ostringstream o;
   if (!(o << x))
     throw BadConversion("stringify(int)");
   return o.str();
 }

//Prints the user data on the screen
void PrintStats()
{
	//Function level Declarations
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);
	string st;

	//make stats 'YELLOW' (14) with 'blk bg' (0) [stats std color]
	SetConsoleColors(hConsole, 14, 0);
    
	//print stats
	system("cls");
	cout<<BufferStr("[" + profile.Name + "]",20)<<"Location: "<<profile.Location<<"\n";
	st="Cash: " + stringify(profile.Cash);
	cout<<BufferStr(st,20)<<"Debt: "<<profile.Debt<<"\n";
	st="Bank: " + stringify(profile.Bank);
	cout<<BufferStr(st,20)<<"Hentchmen: "<<profile.Hentchmen<<"\n";
	st="Health: " + stringify(profile.Health);
	cout<<BufferStr(st,20)<<"Free Space: "<<profile.Space<<"\n";
	cout<<BufferStr("Gun: " + profile.Gun,20)<<"Day: "<<profile.Day<<"\n\n";

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);
}

//Fixes text into columns
string BufferStr(string strString, int MAX_LEN)
{
	//Function level delcarations
	int intSpaces;
	string strTemp;
	
	//add proper spaces after the string
	intSpaces=MAX_LEN-strString.length();
	strTemp=strString;
	for (i=1; i<=intSpaces; i++)
		strTemp=strTemp + " ";

	//return new str
	return (strTemp.c_str());
}

//Displays the profiles menu along with scanning the app's dir for the profile files within it.
string ProfileMenu()
{
	//Function level Declarations
	string Profile[100], Data=strPath + "\\profiles.dat", strTemp;
	int intChoice=200, cnt=0, intTemp;
	char chrLine[2000];
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);

	//initialize the profile array
	for (i=0; i<=99; i++)
		Profile=" ";

	//storing the profiles into an array to be printed
	ifstream inFile(Data.c_str());

	//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
	SetConsoleColors(hConsole, 12, 0);
	system("cls");

	//check for file existence
	if(!(inFile.good()))
	{
		//Print menu
		cout<<"Drug Wars --- By: Derik Hammer\n\n";
		cout<<"File 'profiles.dat' was not found no saved games are available.\n\n";
		cout<<"Press any key to return to the Main Menu.";
		getch();
		inFile.close();
		//return to main menu
		system("cls");
		MenuHandler();
	}

	while (!(inFile.eof()))
	{
		inFile.getline(chrLine,2000);
		strTemp=chrLine;
		//look for the name locator
		if(!(strTemp.find("profile.name=")==std::string::npos))
		{
			intTemp=strTemp.find("name=")+5;
			//remake the string with chrLine
			strTemp=chrLine[intTemp];
			for(i=intTemp+1;i<=1999;i++)
				strTemp=strTemp+chrLine;
			Profile[cnt]=strTemp;
			cnt++;
		}
	};

	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);

	//check for which menu to use
	if (!(Profile[0]==" "))
	{
		//Print menu
		cnt=0;
		system("cls");
		cout<<"Drug Wars --- By: Derik Hammer\n\n";

		while (!(Profile[cnt]==" "))
		{
			cout<<cnt+1<<". "<<Profile[cnt]<<".\n";
			cnt++;
		};

		cout<<"0. Back to Main Menu.\n";
		cout<<"\nSelection: ";
		//Await choice
		cin>>intChoice;
		strTemp=Profile[intChoice-1];

		//loops if invalid numbers are entered.
		while (strTemp==" ")
		{
			SetConsoleColors(hConsole, 10, 0);
			//Print menu
			cnt=0;
			system("cls");
			cout<<"Drug Wars --- By: Derik Hammer\n\n";

			while (!(Profile[cnt]==" "))
			{
				cout<<cnt+1<<". "<<Profile[cnt]<<".\n";
				cnt++;
			};

			cout<<"0. Back to Main Menu.\n";
			cout<<"\nINVALID SELECTION PLEASE CHOOSE AGAIN!\n";
			cout<<"Selection: ";
			//Await choice
			cin>>intChoice;
			strTemp=Profile[intChoice];
		}
	}
	else
	{
		//if there's no saved games print this menu
		system("cls");
		cout<<"Drug Wars --- By: Derik Hammer\n\n";
		cout<<"Sorry no saved games were found.\n\n";
		cout<<"Press any key to go back to the Main Menu.";
		intChoice=0;
		getch();
	}

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);

	//go back to main menu
	if (intChoice==0)
		return "MainMenu";
	
	//Returns the name of the profile needed to be used
	if (!(intChoice==200))
		return(Profile[intChoice-1]);

	//else return an error report
	return "NULL";
}

//Displays the options for the Main Menu
int MainMenu()
{
	//Function level Declarations
	char chrChoice;
	HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
									FILE_SHARE_READ | FILE_SHARE_WRITE, 0, 
									OPEN_EXISTING, 0, 0);

	//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
	SetConsoleColors(hConsole, 10, 0);

	//Print menu
	cout<<"Drug Wars --- By: Derik Hammer\n\n";
	cout<<"1. New Game.\n";
	cout<<"2. Load Profile.\n";
	cout<<"3. Quit.\n\n";
	cout<<"Selection: ";
	//Await choice
	cin>>chrChoice;
	
CheckAgain:
	switch (chrChoice)
	{
		//Proceed with new game
		case '1':
			//revert to old colors
			SetConsoleColors(hConsole, 15, 0);
			return (1);
			break;

		//Proceed with loading profile menu
		case '2':
			//revert to old colors
			SetConsoleColors(hConsole, 15, 0);
			return (2);
			break;

		//Proceed with exiting the application
		case '3':
			//revert to old colors
			SetConsoleColors(hConsole, 15, 0);
			return (3);
			break;

		//Clear screen, reprint menu, notify invalid selection, and allow a second choice
		default:
			system("cls");
			cout<<"Drug Wars --- By: Derik Hammer\n\n";
			cout<<"1. New Game.\n";
			cout<<"2. Load Profile.\n";
			cout<<"3. Quit.\n\n";
			//revert to old colors
			SetConsoleColors(hConsole, 1, 0);
			cout<<"INVALID SELECTION PLEASE CHOOSE AGAIN!\n";
			cout<<"Selection: ";
			cin>>chrChoice;
			//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
			SetConsoleColors(hConsole, 10, 0);
			goto CheckAgain;
	}

	//revert to old colors
	SetConsoleColors(hConsole, 15, 0);

	return(0);
}

// use Unicode (wide) version of GetModuleFileName
wstring get_module_path_wide(void)
{
	wchar_t wide_buf[65536];
	wstring module_name;

	if(!GetModuleFileNameW(GetModuleHandle(0), wide_buf, 65535))
		return module_name;

	wide_buf[65535] = L'\0';

	module_name = wide_buf;

	size_t pos = module_name.find_last_of(L'\\');

	if(pos != string::npos)
		module_name = module_name.substr(0, pos);

	return module_name;
}

// use this function to convert from wide wstring to ASCII string if need be
string wsts(const wstring &src_string)
{
	size_t src_len = src_string.length();

	if(src_len == 0)
		return "";

	char *buf = new(std::nothrow) char[src_len + 1];

	if(buf == 0)
		return "";

	wcstombs(buf, src_string.c_str(), src_len);
	buf[src_len] = '\0';

	string final_string = buf;

	if(buf != 0)
		delete [] buf;

	return final_string;
}

//Color Change functions
WORD GetConsoleColors(HANDLE hConsole)
{
    // get current console text attributes
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    return csbi.wAttributes;
}

WORD SetConsoleColors(HANDLE hConsole, WORD wColorText, WORD wColorBkg = 0)
{
    // get old text attributes
    WORD wOldColors = GetConsoleColors(hConsole);

    // set new text attributes
    SetConsoleTextAttribute(hConsole, wColorText | (wColorBkg << 4));
    return wOldColors;
}

Thank you -Lordoftools

Share this post


Link to post
Share on other sites
Advertisement

enum Drugs {ACID=1, COCAINE, HASHISH, HERION, LUDES, MDA, OPIUM, PCP, PEYOTE, SHROOMS, SPEED, WEED};
enum LOCS {BRONX=1, GHETTO, CENTRALPARK, MANHATTAN, CONEYISLAND, BROOKLYN, QUEENS, STATENISLAND};



Well at a quick glance your enumerating your items and drugs to go from 1-12, however since your arrays are 12 items long they will be referenced from 0-11.
This may cause overwrite errors as well as cause odd errors in which you expect one item and get another displayed.
Start your enumeration at 0 using this:


enum Drugs {ACID=0, COCAINE, HASHISH, HERION, LUDES, MDA, OPIUM, PCP, PEYOTE, SHROOMS, SPEED, WEED};
enum LOCS {BRONX=0, GHETTO, CENTRALPARK, MANHATTAN, CONEYISLAND, BROOKLYN, QUEENS, STATENISLAND};



That may help, but as I said I only glanced over your code (and I'm running on very little sleep)... so it may not be the change needed =/

Share this post


Link to post
Share on other sites
i understand how what you are saying but the enum variables start at 1 so that they can corrispond to the menu options 1-12 so if i changed them to start at 0 i'd just have to do the same convertion to figure out which menu option was selected.

unfortunatly that is not the fix that i need

Thanks anyways
-Lordoftools

Share this post


Link to post
Share on other sites
ok guys i figured out one of my problems and figured out a few things which would have caused problems in the future but i still got one delema on my plate. the first part of the menu which displays the drug's names, price, etc. is still only sometimes showing all the drugs and sometimes not with what appears to be identical controls in my tests. This is the updated problem function and app code.....

PROBLEM FUNCTION
[source code=cpp]
//THE ISSUE IS SOMEWHERE BETWEEN HERE AND....
void SellDrugsMenu()
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
int cnt, cnt2, x, intSell[12], intChoice, intQuant, tmpQuant[12];

//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"What drugs do you want to sell?\n\n";

cnt=0;
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
for (cnt=0;cnt<12;cnt++)
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x] && strDrugArray[cnt] !=" ")
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
tmpQuant[cnt2]=intQuantArray[x];
cnt2++;
}
}
}

cout<<"\nSelect Drug to Sell (0 to cancel): ";
cin>>intChoice;
//HERE BECAUSE AFTER THIS POINT THE REST OF THE FUNCTION WORKS FINE
//AT LEAST AS MUCH AS I'VE WRITEN IN IT SO FAR.
//BUT SOMEWHERE IN BETWEEN THOSE COMMENTS IT'S ONLY PRINTING SOME OF THE DRUGS
//(ALL OF THEM EVERYONCE IN A WHILE)

//reprint menu if invalid drug is choosen
while (intChoice>cnt2-1 || intChoice<0)
{
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"INVALID DRUG CHOICE PLEASE CHOOSE AGAIN!\n\n";
cout<<"What drugs do you want to sell?\n\n";
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
for (cnt=0;cnt<12;cnt++)
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x] && strDrugArray[cnt] !=" ")
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
cnt2++;
}
}
}

cout<<"\nSelect Drug to Sell (0 to cancel): ";
cin>>intChoice;
}

//if the cancel value is entered return to the city
if (intChoice==0)
goto City;

cout<<"\nQuantity (0 to cancel): ";
cin>>intQuant;

//reprint menu if invalid quantity is choosen
while ((intQuant>tmpQuant[intChoice]) || (intQuant<0))
{
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"INVALID QUANTITY CHOICE PLEASE CHOOSE AGAIN!\n\n";
cout<<"What drugs do you want to sell?\n\n";
cnt=0;
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
while (cnt<12 && strDrugArray[cnt] !=" ")
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x])
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: ";
cout<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
cnt2++;
}
}
cnt++;
}

cout<<"\nSelect Drug to Sell (0 to cancel): "<<intChoice<<"\n";

cout<<"\nQuantity (0 to cancel): ";
cin>>intQuant;
}

//if the cancel value is entered return to the city
if (intQuant==0)
goto City;

//find the drug the selection is refering to and set the proper values for sale

//debugger code
getch();

//return to the city
City:
CityOperations(false);

//reverts back to old colors
SetConsoleColors(hConsole, 10, 0);

}



FULL CODE:
[source code=cpp]
//for VC++
#include "stdafx.h"

//for basic functions i.e. (cout,cin)
#include <iostream>
#include <afx.h>

//for file manipulation
#include <fstream>
#include <cstdlib>

//For getch()/getche()
#include <conio.h>

//For srand() and time()
#include <stdio.h>
#include <stdlib.h> //also for string to int convertions and visa versa
#include <time.h>

//for the string convertions
#include <sstream>
#include <cstring>
#include <stdexcept>

//for ease of use
using namespace std;

//Global Variable Declaration
struct USERDATA
{
string Name, Gun, Location;
int Cash, Debt, Bank, Hentchmen, Health, Space, Day;
double GunRate;
};
struct LOCDATA
{
string Name;
int Police, minDrugs, maxDrugs;
};
int i;
struct LOCDATA loc;
struct USERDATA profile;
enum Drugs {ACID=1, COCAINE, HASHISH, HERION, LUDES, MDA, OPIUM, PCP, PEYOTE, SHROOMS, SPEED, WEED};
enum LOCS {BRONX=1, GHETTO, CENTRALPARK, MANHATTAN, CONEYISLAND, BROOKLYN, QUEENS, STATENISLAND};
int intDrugArray[12];
string strDrugArray[12];
int intInvArray[12];
string strInvArray[12];
int intQuantArray[12];
string strPath;

//function delcarations
WORD SetConsoleColors(HANDLE hConsole, WORD wColorText, WORD wColorBkg);
WORD GetConsoleColors(HANDLE hConsole);
wstring get_module_path_wide(void);
string wsts(const wstring &src_string);
int MainMenu();
int MenuHandler();
string ProfileMenu();
inline std::string stringify(int x);
string BufferStr(string strString, int MAX_LEN);
void BuyingDrugs(string Drug, int Price);
void PrintStats();
void CityOperations(bool NewDay);
void BankMenu();
void SellDrugsMenu();
void BuyDrugsMenu();
void BuyingGun(string Gun, int Price);
void ChangeLocMenu();
void LoanSharkMenu();
void SaveGame();
bool CheckSaved();

//Start off function
int main(int argc, char* argv[])
{
//Initialize random generator
srand ( time(NULL) );

//Initialize global variables
intInvArray[250]=0;
strPath=wsts(get_module_path_wide());

//Runs the menus and terminates the program if needed
return MenuHandler();
}

int MenuHandler()
{
//Function level Delcarations
string strProfile, SavedFile=strPath + "\\profiles.dat", strTemp;
char chrLine[2000];
int intMnuOpt;

//Displays Main Menu
intMnuOpt=MainMenu();

//ERROR code
if (intMnuOpt==0)
{
system("cls");
cout<<"int MainMenu() returned ERROR code '0'\n";
}

//New Game code
if (intMnuOpt==1)
{
//Variable initalization.
profile.Bank=0;
profile.Health=100;
profile.Day=1;
profile.Cash=rand()%3000 + 2000;
profile.Debt=rand()%9000 + 1000;
profile.Gun="NONE";
profile.GunRate=0;
profile.Location="BRONX";
profile.Hentchmen=rand()%4 + 7;
profile.Space=profile.Hentchmen * 10;
loc.maxDrugs=12;

//Set user name.
system("cls");
cout<<"Enter your name: ";
cin>>strTemp;
profile.Name=strTemp.c_str();

//Starts off in BRONX
loc.Name="BRONX";
loc.minDrugs=7;
loc.Police=10;
CityOperations(false);
}

//Load Profile code
if (intMnuOpt==2)
{
//displays menu, prompts profile choice, stores the user ID
strProfile=ProfileMenu();

//ERROR checking
if (strProfile=="NULL")
{
system("cls");
cout<<"string ProfileMenu() returned ERROR code 'NULL' (Choice integer was left empty or invalid).\n\n";
cout<<"Press any key to return to the Main Menu.";
getch();
MenuHandler();
}

//check for cancel msg
if (strProfile=="MainMenu")
{
system("cls");
MenuHandler();
}

//Load profile settings and start the game
fstream inFile(SavedFile.c_str(), ios::in);

inFile.getline(chrLine,2000);

//convert to string array
strTemp=chrLine[0];
for (i=1; i<=1999; i++)
strTemp=strTemp+chrLine;

while (strTemp.find(strProfile)==std::string::npos)
{
inFile.getline(chrLine,2000);

//convert to string array
strTemp=chrLine[0];
for (i=1; i<=1999; i++)
strTemp=strTemp+chrLine;
};

//sets the profile.name
strTemp=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
profile.Name=strTemp;

//sets the rest of the variables
int x;
for(x=1; x<=13; x++)
{
inFile.getline(chrLine,2000);
//convert to string array
strTemp=chrLine[0];
for (i=1; i<=1999; i++)
strTemp=strTemp+chrLine;

switch (x)
{
case 1:
profile.Gun=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
break;
case 2:
profile.Location=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
break;
case 3:
profile.Cash=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 4:
profile.Debt=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 5:
profile.Bank=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 6:
profile.Hentchmen=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 7:
profile.Health=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 8:
profile.Space=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 9:
profile.Day=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 10:
profile.GunRate=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 11:
loc.Name=strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())-strTemp.find("=")-1);
break;
case 12:
loc.Police=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 13:
loc.minDrugs=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
case 14:
loc.maxDrugs=atoi(strTemp.substr(strTemp.find("=")+1,strlen(strTemp.c_str())).c_str());
break;
}
}

//start game
CityOperations(false);
}

//Quit Code
if (intMnuOpt==3)
{
system("cls");
cout<<"Thank you for playing \"Drug Wars\" clone -- By: Derik Hammer.";
getch();
}

//Application terminator
return 0;
}

//Operates the features of this location
void CityOperations(bool NewDay)
{
if (NewDay==true)
{
//increase the day
profile.Day++;

//increase debt due to interest
if (profile.Day%7==0)
profile.Debt=profile.Debt+(profile.Debt*.12);
}

system("cls");
PrintStats();

//sets up the drugs which are in this city (price, how many, what kind)
int intTemp, cnt=0, DrugChecker;
bool PickAgain;
int intChoice;
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

intTemp=rand()%(loc.maxDrugs-loc.minDrugs)+loc.minDrugs;

while (intTemp-1>=cnt)
{
do
{
PickAgain=false;
DrugChecker=rand()%12+1;
for (i=0; i<=11; i++)
{
if (intDrugArray==DrugChecker)
PickAgain=true;
}
}
while (PickAgain==true);
intDrugArray[cnt]=DrugChecker;
cnt++;
};

for (i=intTemp; i<=11; i++)
intDrugArray=0;

//Converts the int array to a string with the drug names and then makes the int array
//into the prices array at the same time.
for (i=0; i<=11; i++)
{
switch (intDrugArray)
{
case ACID:
strDrugArray="ACID";
intDrugArray=rand()%3400+1000;
break;

case COCAINE:
strDrugArray="COCAINE";
intDrugArray=rand()%14000+15000;
break;

case HASHISH:
strDrugArray="HASHISH";
intDrugArray=rand()%800+480;
break;

case HERION:
strDrugArray="HERION";
intDrugArray=rand()%7500+5500;
break;

case LUDES:
strDrugArray="LUDES";
intDrugArray=rand()%49+11;
break;

case MDA:
strDrugArray="MDA (Ecstasy)";
intDrugArray=rand()%2900+1500;
break;

case OPIUM:
strDrugArray="OPIUM";
intDrugArray=rand()%710+540;
break;

case PCP:
strDrugArray="PCP";
intDrugArray=rand()%1500+1000;
break;

case PEYOTE:
strDrugArray="PEYOTE";
intDrugArray=rand()%480+220;
break;

case SHROOMS:
strDrugArray="SHROOMS";
intDrugArray=rand()%670+630;
break;

case SPEED:
strDrugArray="SPEED";
intDrugArray=rand()%160+90;
break;

case WEED:
strDrugArray="WEED";
intDrugArray=rand()%575+315;
break;

default:
strDrugArray="ERROR: NO_DRUG";
break;
}
}

//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
SetConsoleColors(hConsole, 12, 0);

//Run cops coding here, seperate function for the battle run only option when un-armed
if (NewDay==true)
{
if((rand()%99+1)<=(loc.Police-profile.GunRate))
{
int money=profile.Cash*.2;
string st;
profile.Cash=profile.Cash-money;
system("cls");
PrintStats();
//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
SetConsoleColors(hConsole, 12, 0);
cout<<"BUSTED !! -- Gotta bribe the cops, and it costs you 20% of your cash.\n\n";
cout<<BufferStr("LOST: "+stringify(money),20)<<"REMAINING: "<<profile.Cash<<"\n\n";
}
}

//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
//print city menu
cout<<"Welcome to "<<loc.Name<<"!\n";

//if its the home city [BRONX] then display spec menu
if (loc.Name=="BRONX")
{
specPickAgain:
cout<<"1. Check out what's available.\n";
cout<<"2. Sell Drugs.\n";
cout<<"3. Change location.\n";
cout<<"4. Visit Bank.\n";
cout<<"5. Visit Loan Shark.\n";
cout<<"6. Save Game.\n";
cout<<"7. Quit.\n";
cout<<"Selection: ";
//await choice
cin>>intChoice;

switch (intChoice)
{
case 1:
BuyDrugsMenu();
break;

case 2:
SellDrugsMenu();
break;

case 3:
ChangeLocMenu();
break;

case 4:
BankMenu();
break;

case 5:
LoanSharkMenu();
break;

case 6:
SaveGame();
break;

case 7:
system("cls");
SetConsoleColors(hConsole, 15, 0);
cout<<"Thank you for playing \"Drug Wars\" clone -- By: Derik Hammer.";
getch();
break;

default:
goto specPickAgain;
break;
}
}
else
{
normPickAgain:
cout<<"1. Check out available Drugs.\n";
cout<<"2. Sell Drugs.\n";
cout<<"3. Change location.\n";
cout<<"Selection: ";
//await choice
cin>>intChoice;

switch (intChoice)
{

case 1:
BuyDrugsMenu();
break;

case 2:
SellDrugsMenu();
break;

case 3:
ChangeLocMenu();
break;

default:
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid choice, please pick again.\n";
goto normPickAgain;
break;

}
}

//revert to old colors
SetConsoleColors(hConsole, 15, 0);
}

void BankMenu()
{
//function level delcarations
char chrChoice;
int intAmt;
bool boolDep=false, boolWithd=false;

//reset screen and disp stats again
system("cls");
PrintStats();

//print bank options
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
SetConsoleColors(hConsole, 10, 0);

cout<<"Welcome to the Bank!\n\n";

//check to see what he can do in the bank
if (profile.Cash>0)
{
cout<<"D. Deposit (Up to $"<<profile.Cash<<")\n";
boolDep=true;
}
if (profile.Bank>0)
{
cout<<"W. Withdraw (Up to $"<<profile.Bank<<")\n";
boolWithd=true;
}
cout<<"L. Leave Bank.\n";
//await choice
cout<<"Selection: ";
cin>>chrChoice;

if ((chrChoice=='d' || chrChoice=='D') && boolDep==true)
{
//disp deposit menu
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
DepAgain:
cout<<"Bank Deposit -- $"<<profile.Cash<<" available.\n\n";
cout<<"Deposit Amount (0 to cancel): ";
//await choice
cin>>intAmt;
if (intAmt>profile.Cash || intAmt<0)
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid $ amount please pick again.\n\n";
goto DepAgain;
}
//alter $ amounts accordingly
profile.Cash=profile.Cash-intAmt;
profile.Bank=profile.Bank+intAmt;
}
else if ((chrChoice=='w' || chrChoice=='W') && boolWithd==true)
{
//disp withdraw menu
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
WDrawAgain:
cout<<"Bank Withdraw -- $"<<profile.Bank<<" available.\n\n";
cout<<"Withdraw Amount (0 to cancel): ";
//await choice
cin>>intAmt;
if (intAmt>profile.Bank || intAmt<0)
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid $ amount please pick again.\n\n";
goto WDrawAgain;
}
//alter $ amounts accordingly
profile.Bank=profile.Bank-intAmt;
profile.Cash=profile.Cash+intAmt;

}
else if (chrChoice=='l' || chrChoice=='L')
{
//return to your city
CityOperations(false);
}
else
BankMenu();

CityOperations(false);

//revert to old colors
SetConsoleColors(hConsole, 15, 0);
}
void SellDrugsMenu()
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
int cnt, cnt2, x, intSell[12], intChoice, intQuant, tmpQuant[12];

//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"What drugs do you want to sell?\n\n";

cnt=0;
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
for (cnt=0;cnt<12;cnt++)
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x] && strDrugArray[cnt] !=" ")
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
tmpQuant[cnt2]=intQuantArray[x];
cnt2++;
}
}
}

cout<<"\nSelect Drug to Sell (0 to cancel): ";
cin>>intChoice;

//reprint menu if invalid drug is choosen
while (intChoice>cnt2-1 || intChoice<0)
{
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"INVALID DRUG CHOICE PLEASE CHOOSE AGAIN!\n\n";
cout<<"What drugs do you want to sell?\n\n";
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
for (cnt=0;cnt<12;cnt++)
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x] && strDrugArray[cnt] !=" ")
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: "<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
cnt2++;
}
}
}

cout<<"\nSelect Drug to Sell (0 to cancel): ";
cin>>intChoice;
}

//if the cancel value is entered return to the city
if (intChoice==0)
goto City;

cout<<"\nQuantity (0 to cancel): ";
cin>>intQuant;

//reprint menu if invalid quantity is choosen
while ((intQuant>tmpQuant[intChoice]) || (intQuant<0))
{
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"INVALID QUANTITY CHOICE PLEASE CHOOSE AGAIN!\n\n";
cout<<"What drugs do you want to sell?\n\n";
cnt=0;
cnt2=1;
//prints the sell options (can only sell to citys who are buying)
while (cnt<12 && strDrugArray[cnt] !=" ")
{
for (x=0;x<=11;x++)
{
if(strDrugArray[cnt]==strInvArray[x])
{
cout<<BufferStr(stringify(cnt2)+": "+strInvArray[x],12); cout<<" - Quantity: ";
cout<<intQuantArray[x]<<", bought @ $";
cout<<intInvArray[x]<<", selling @ $"<<intDrugArray[cnt]<<"\n";
intSell[cnt2]=cnt;
cnt2++;
}
}
cnt++;
}

cout<<"\nSelect Drug to Sell (0 to cancel): "<<intChoice<<"\n";

cout<<"\nQuantity (0 to cancel): ";
cin>>intQuant;
}

//if the cancel value is entered return to the city
if (intQuant==0)
goto City;

//find the drug the selection is refering to and set the proper values for sale

//debugger code
getch();

//return to the city
City:
CityOperations(false);

//reverts back to old colors
SetConsoleColors(hConsole, 10, 0);

}

void BuyingDrugs(string Drug, int Price)
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
int intAmt;

//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"How much "<<Drug<<" you want? ($"<<Price<<" each)"<<endl;
cout<<"Quantity (0 to cancel): ";
cin>>intAmt;

while ((intAmt*Price>profile.Cash) || (intAmt>profile.Space))
{
//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"You don't have enough money or enough space for that much "<<Drug<<"!\n\n";
cout<<"How much "<<Drug<<" you want? ($"<<Price<<" each)"<<endl;
cout<<"Quantity (0 to cancel): ";
cin>>intAmt;
}

//updates the space in your inv
profile.Space=profile.Space-intAmt;
profile.Cash=profile.Cash-(intAmt*Price);

//fills the drug into the available array slot
if (intAmt !=0)
{
//add it to drugs that are alrdy there
for (i=0; i<=11; i++)
{
if (strInvArray==Drug)
{
//divides the two costs out so that it accurately represents how much you paid for everything
intInvArray=((intQuantArray*intInvArray)+(Price*intAmt))/(intQuantArray+intAmt);
intQuantArray=intQuantArray+intAmt;
goto End_If;
}
}
//add it to empty spot if drug wasn't found in inv
for (i=0; i<=11; i++)
{
if (intInvArray==0)
{
strInvArray=Drug;
intInvArray=Price;
intQuantArray=intAmt;
i=12;
}
}
}
End_If:

//reverts back to old colors
SetConsoleColors(hConsole, 10, 0);

BuyDrugsMenu();
}

void CheckWhichDrug(char chrDrug, int intTemp[12])
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
int intChoice;

RePick:
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);

switch (chrDrug)
{
case 'h':
cout<<"Did you want HASHISH or HERION?\n\n";
cout<<"1. HASHISH.\n";
cout<<"2. HERION.\n";
cout<<"Selection (0 to cancel):";
//await choice
cin>>intChoice;

switch (intChoice)
{
case 0:
BuyDrugsMenu();
case 1:
BuyingDrugs("HASHISH", intTemp[3]);
break;
case 2:
BuyingDrugs("HERION", intTemp[4]);
break;
default:
goto RePick;
break;
}
break;

case 'p':
cout<<"Did you want PCP or PEYOTE?\n\n";
cout<<"1. PCP.\n";
cout<<"2. PEYOTE.\n";
cout<<"Selection (0 to cancel):";
//await choice
cin>>intChoice;

switch (intChoice)
{
case 0:
BuyDrugsMenu();
case 1:
BuyingDrugs("PCP", intTemp[8]);
break;
case 2:
BuyingDrugs("PEYOTE", intTemp[9]);
break;
default:
goto RePick;
break;
}
break;

case 's':
cout<<"Did you want SHROOMS or SPEED?\n\n";
cout<<"1. SHROOMS.\n";
cout<<"2. SPEED.\n";
cout<<"Selection (0 to cancel):";
//await choice
cin>>intChoice;

switch (intChoice)
{
case 0:
BuyDrugsMenu();
case 1:
BuyingDrugs("SHROOMS", intTemp[10]);
break;
case 2:
BuyingDrugs("SPEED", intTemp[11]);
break;
default:
goto RePick;
break;
}
break;
}
}

void BuyDrugsMenu()
{
//Function level Declarations
char chrChoice;
bool oneS=false, twoS=false, oneP=false, twoP=false, oneH=false, twoH=false;
int intTemp[13], TradeIn;
string buyGun;
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);

for (i=0; i<=11; i++)
{
if (intDrugArray<=profile.Cash)
goto SkipFor;
}
cout<<"Your broke! Go somewhere else or go sell some of your product to make up the $$$.\n";
goto EndOfFunc;
SkipFor:

//print menu options
cout<<"So you wanta buy some dope? Here's your choices...\n\n";
InvalidChoice:
for (i=0; i<=11; i++)
{
if (strDrugArray=="ACID")
{
cout<<"A. ACID - $"<<intDrugArray<<endl;
intTemp[1]=intDrugArray;
}
else if (strDrugArray=="COCAINE")
{
cout<<"C. COCAINE - $"<<intDrugArray<<endl;
intTemp[2]=intDrugArray;
}
else if (strDrugArray=="HASHISH")
{
cout<<"H. HASHISH - $"<<intDrugArray<<endl;
intTemp[3]=intDrugArray;
oneH=true;
}
else if (strDrugArray=="HERION")
{
cout<<"H. HERION - $"<<intDrugArray<<endl;
intTemp[4]=intDrugArray;
twoH=true;
}
else if (strDrugArray=="LUDES")
{
cout<<"L. LUDES - $"<<intDrugArray<<endl;
intTemp[5]=intDrugArray;
}
else if (strDrugArray=="MDA")
{
cout<<"M. MDA - $"<<intDrugArray<<endl;
intTemp[6]=intDrugArray;
}
else if (strDrugArray=="OPIUM")
{
cout<<"O. OPIUM - $"<<intDrugArray<<endl;
intTemp[7]=intDrugArray;
}
else if (strDrugArray=="PCP")
{
cout<<"P. PCP - $"<<intDrugArray<<endl;
intTemp[8]=intDrugArray;
oneP=true;
}
else if (strDrugArray=="PEYOTE")
{
cout<<"P. PEYOTE - $"<<intDrugArray<<endl;
intTemp[9]=intDrugArray;
twoP=true;
}
else if (strDrugArray=="SHROOMS")
{
cout<<"S. SHROOMS - $"<<intDrugArray<<endl;
intTemp[10]=intDrugArray;
oneS=true;
}
else if (strDrugArray=="SPEED")
{
cout<<"S. SPEED - $"<<intDrugArray<<endl;
intTemp[11]=intDrugArray;
twoS=true;
}
else if (strDrugArray=="WEED")
{
cout<<"W. WEED - $"<<intDrugArray<<endl;
intTemp[12]=intDrugArray;
}
}

//randomize the gun selection and determine price with trade-in value of old gun
if (rand()%3+1==2)
{
if (profile.Gun=="BARETTA")
TradeIn=1500;
if (profile.Gun==".38SPEC")
TradeIn=1725;
if (profile.Gun=="RUGER")
TradeIn=1450;
if (profile.Gun=="SATNIGHTSPEC")
TradeIn=1600;
if (profile.Gun=="NONE")
TradeIn=0;

switch (rand()%3+1)
{
case 1:
cout<<"\nG. Baretta (Reduces police by 7%, Current Rating="<<20-profile.GunRate<<"%) - $3000."<<endl;
cout<<"\t$"<<3000-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
intTemp[13]=3000-TradeIn;
buyGun="Baretta";
break;
case 2:
cout<<"\nG. .38 Special (Reduces police by 13%, Current Rating="<<20-profile.GunRate<<"%) - $3500."<<endl;
cout<<"\t$"<<3500-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
intTemp[13]=3500-TradeIn;
buyGun=".38 Special";
break;
case 3:
cout<<"\nG. Ruger (Reduces police by 5%, Current Rating="<<20-profile.GunRate<<"%) - $2900."<<endl;
cout<<"\t$"<<2900-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
intTemp[13]=2900-TradeIn;
buyGun="Ruger";
break;
case 4:
cout<<"\nG. Saturday night Special (Reduces police by 10%, Current Rating="<<20-profile.GunRate<<"%) - $3100."<<endl;
cout<<"\t$"<<3100-TradeIn<<" after the $"<<TradeIn<<" discount for trading in your current gun.\n";
intTemp[13]=3100-TradeIn;
buyGun="Saturday night Special";
break;
}
}
cout<<"\nB. Back to "<<profile.Location<<".\n";
cout<<"Selection: ";
cin>>chrChoice;

//check for duplicate letters and proseed with purchase
if (chrChoice=='A' || chrChoice=='a')
{
BuyingDrugs("ACID", intTemp[1]);
}
else if (chrChoice=='B' || chrChoice=='b')
{
CityOperations(false);
}
else if (chrChoice=='C' || chrChoice=='c')
{
BuyingDrugs("COCAINE", intTemp[13]);
}
else if (chrChoice=='G' || chrChoice=='g')
{
BuyingGun(buyGun, intTemp[13]);
}
//for duplicate H's
else if ((chrChoice=='H' || chrChoice=='h') && (oneH==true && twoH==true))
{
CheckWhichDrug('h', intTemp);
}
//for none duplicate
else if ((chrChoice=='H' || chrChoice=='h') && (oneH==false || twoH==false))
{
for (i=0; i<=11; i++)
{
if (strDrugArray=="HASHISH")
{
BuyingDrugs("HASHISH", intTemp[3]);
i=12;
}
if (strDrugArray=="HERION")
{
BuyingDrugs("HERION", intTemp[4]);
i=12;
}
}
}
else if (chrChoice=='L' || chrChoice=='l')
{
BuyingDrugs("LUDES", intTemp[5]);
}
else if (chrChoice=='M' || chrChoice=='m')
{
BuyingDrugs("MDA", intTemp[6]);
}
else if (chrChoice=='O' || chrChoice=='o')
{
BuyingDrugs("OPIUM", intTemp[7]);
}
//for duplicate P's
else if ((chrChoice=='P' || chrChoice=='p') && (oneP==true && twoP==true))
{
CheckWhichDrug('p', intTemp);
}
//for none duplicate
else if ((chrChoice=='P' || chrChoice=='p') && (oneP==false || twoP==false))
{
for (i=0; i<=11; i++)
{
if (strDrugArray=="PCP")
{
BuyingDrugs("PCP", intTemp[8]);
i=12;
}
if (strDrugArray=="PEYOTE")
{
BuyingDrugs("PEYOTE", intTemp[9]);
i=12;
}
}
}
//for duplicate S's
else if ((chrChoice=='S' || chrChoice=='s') && (oneS==true && twoS==true))
{
CheckWhichDrug('s', intTemp);
}
//for none duplicate
else if ((chrChoice=='S' || chrChoice=='s') && (oneS==false || twoS==false))
{
for (i=0; i<=11; i++)
{
if (strDrugArray=="SHROOMS")
{
BuyingDrugs("SHROOMS", intTemp[10]);
i=12;
}
if (strDrugArray=="SPEED")
{
BuyingDrugs("SPEED", intTemp[11]);
i=12;
}
}
}
else if (chrChoice=='W' || chrChoice=='w')
{
BuyingDrugs("WEED", intTemp[12]);
}
else
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid selection please pick again...\n\n";
goto InvalidChoice;
}

EndOfFunc:
//reverts colors back
SetConsoleColors(hConsole, 15, 0);
}

void BuyingGun(string Gun, int Price)
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
int intAmt=1;

//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]

if ((intAmt*Price>profile.Cash))
{
//print menu
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"You don't have enough money for the "<<Gun<<"!\n\n";
cout<<"Press any key to return to the Buy Drugs menu."<<endl;
getch();
goto Back;
}

//updates info
profile.Cash=profile.Cash-Price;
if (Gun=="Saturday night Special")
{
profile.Gun="SATNIGHTSPEC";
profile.GunRate=10;
}
if (Gun=="Baretta")
{
profile.Gun="BARETTA";
profile.GunRate=13;
}
if (Gun==".38 Special")
{
profile.Gun=".38SPEC";
profile.GunRate=7;
}
if (Gun=="Ruger")
{
profile.Gun="RUGER";
profile.GunRate=5;
}

//reverts back to old colors
SetConsoleColors(hConsole, 10, 0);

Back:
BuyDrugsMenu();
}

void ChangeLocMenu()
{
//Function level Declarations
int intChoice;
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
LocPickAgain:
cout<<"Where would you like to go?\n\n";
cout<<"1. BRONX\n";
cout<<"2. GHETTO\n";
cout<<"3. CENTRAL PARK\n";
cout<<"4. MANHATTAN\n";
cout<<"5. CONEY ISLAND\n";
cout<<"6. BROOKLYN\n";
cout<<"7. QUEENS\n";
cout<<"8. STATEN ISLAND\n";
cout<<"9. Back to "<<loc.Name<<"\n";
cout<<"Selection: ";
//await selection
cin>>intChoice;

switch (intChoice)
{
case BRONX:
if (profile.Location=="BRONX")
intChoice=9;
profile.Location="BRONX";
loc.Name="BRONX";
loc.minDrugs=7;
loc.maxDrugs=12;
loc.Police=10;
break;

case GHETTO:
if (profile.Location=="GHETTO")
intChoice=9;
profile.Location="GHETTO";
loc.Name="GHETTO";
loc.minDrugs=8;
loc.maxDrugs=12;
loc.Police=5;
break;

case CENTRALPARK:
if (profile.Location=="CENTRALPARK")
intChoice=9;
profile.Location="CENTRALPARK";
loc.Name="CENTRAL PARK";
loc.minDrugs=6;
loc.maxDrugs=12;
loc.Police=15;
break;

case MANHATTAN:
if (profile.Location=="MANHATTAN")
intChoice=9;
profile.Location="MANHATTAN";
loc.Name="MANHATTAN";
loc.minDrugs=4;
loc.maxDrugs=12;
loc.Police=45;
break;

case CONEYISLAND:
if (profile.Location=="CONEYISLAND")
intChoice=9;
profile.Location="CONEYISLAND";
loc.Name="CONEY ISLAND";
loc.minDrugs=6;
loc.maxDrugs=12;
loc.Police=20;
break;

case BROOKLYN:
if (profile.Location=="BROOKLYN")
intChoice=9;
profile.Location="BROOKLYN";
loc.Name="BROOKLYN";
loc.minDrugs=4;
loc.maxDrugs=12;
loc.Police=35;
break;

case QUEENS:
if (profile.Location=="QUEENS")
intChoice=9;
profile.Location="QUEENS";
loc.Name="QUEENS";
loc.minDrugs=6;
loc.maxDrugs=12;
loc.Police=30;
break;

case STATENISLAND:
if (profile.Location=="STATENISLAND")
intChoice=9;
profile.Location="STATENISLAND";
loc.Name="STATEN ISLAND";
loc.minDrugs=6;
loc.maxDrugs=12;
loc.Police=20;
break;

case 9:
break;

default:
system("cls");
PrintStats();
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid entry please pick again.\n\n";
goto LocPickAgain;
break;
}

//revert to old colors
SetConsoleColors(hConsole, 15, 0);

//if the city never changes then don't penalize with a new day
if (intChoice==9)
{
CityOperations(false);
}
else
{
CityOperations(true);
}
}
void LoanSharkMenu()
{
//Function level Declarations
int intChoice, intAmt;
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);

LoanChoiceAgain:

//Prints the loan shark welcome msg
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Welcome to Shady Shawn's Shack!\n";
cout<<"Rates are currently at 12% factored in each Sunday (7th day).\n\n";

//allows you to pay off debt only when you have some
if(profile.Debt>0)
{
//prints menu
cout<<"1. Pay off debt.\n";
cout<<"2. Leave Shady Shawn's.\n";
cout<<"Selection: ";
//await choice
cin>>intChoice;

switch (intChoice)
{
//run through pay off options/operations
case 1:
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
PLoanAgain:
cout<<"Shady Shawn's Shack!\n\n";
cout<<"Enter Amount to Pay off (0 to cancel): ";
cin>>intAmt;
if (intAmt>profile.Cash || intAmt<0)
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid $ amount please pick again.\n\n";
goto PLoanAgain;
}

//redefines variables appropriatly
profile.Cash=profile.Cash-intAmt;
profile.Debt=profile.Debt-intAmt;

break;

//leaves the loan shark and heads back to the city without a day increase
case 2:
CityOperations(false);
break;

//sends you back to pick again due to invalid entry
default:
goto LoanChoiceAgain;
break;

}
}
else
{
//allows you to take out a loan when you have no debt
cout<<"1. Take out a Loan.\n";
cout<<"2. Leave Shady Shawn's.\n";
cout<<"Selection: ";
//await choice
cin>>intChoice;

switch (intChoice)
{
//prints options and runs the loan request operations
case 1:
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
PLoanAgain2:
cout<<"Shady Shawn's Shack!\n\n";
cout<<"Enter Amount of the Loan (0 to cancel): ";
//await selection
cin>>intAmt;

//can't use negatives
if (intAmt<0)
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"Invalid amount entered, try again man.\n\n";
goto PLoanAgain2;
}
//only loans out up to 30000
if (intAmt>=30000)
{
system("cls");
PrintStats();
SetConsoleColors(hConsole, 10, 0);
cout<<"I only give out Loans of $30,000 and below, try again man.\n\n";
goto PLoanAgain2;
}

//redefines variables appropriatly
profile.Cash=profile.Cash+intAmt;
profile.Debt=profile.Debt+intAmt;

break;

//send you back to the city without a day penalty
case 2:
CityOperations(false);
break;

//sends user through menu again due to invalid entry
default:
goto LoanChoiceAgain;
break;
}
}

//revert to old colors
SetConsoleColors(hConsole, 15, 0);

//sends user back to the city without day penalty
CityOperations(false);
}

//checks to see if the use already has a profile by that name saved
bool CheckSaved()
{
string Data=strPath + "\\profiles.dat", strTemp;
ifstream inFile(Data.c_str());

//check for file existance
if(!(inFile.good()))
{
inFile.close();
//Create file
ofstream outFile(Data.c_str());
outFile.close();
}

while (inFile >> Data)
{
strTemp="profile.name=" + profile.Name;
if (Data==strTemp)
{
inFile.close();
return(true);
}
};

inFile.close();
return (false);
}

//rewrites the files needed for saving
void SaveGame()
{
bool Saved;
string Data=strPath + "\\profiles.dat", strOldData[100], strOldData2[100], strTemp;
char chrLine[2000];
int cnt=0;

//empty strOldData incase this isn't the first save
for (i=0; i<=99; i++)
strOldData=" ";

//empty strOldData2 incase this isn't the first save
for (i=0; i<=99; i++)
strOldData2=" ";

//check to see if the game is overwritting or a new save
Saved=CheckSaved();

if (Saved==false)
{
fstream inFile(Data.c_str(), ios::in);

//store information in file for reprint
while (! inFile.eof())
{
inFile.getline(chrLine,2000);

//convert to string array
strOldData[cnt]=chrLine[0];
for (i=1; i<=1999; i++)
strOldData[cnt]=strOldData[cnt]+chrLine;

cnt++;
};
inFile.close();

//rewrite the old info
cnt=1;
fstream outFile(Data.c_str(), ios::out);

if (!(strOldData[0]==" "))
outFile<<strOldData[0];
while (!(strOldData[cnt]==" "))
{
outFile<<endl<<strOldData[cnt];
cnt++;
};

//write the new info
outFile<<endl<<endl;
outFile<<"profile.name="<<profile.Name<<endl;
outFile<<"profile.gun="<<profile.Gun<<endl;
outFile<<"profile.location="<<profile.Location<<endl;
outFile<<"profile.cash="<<profile.Cash<<endl;
outFile<<"profile.debt="<<profile.Debt<<endl;
outFile<<"profile.bank="<<profile.Bank<<endl;
outFile<<"profile.hentchmen="<<profile.Hentchmen<<endl;
outFile<<"profile.health="<<profile.Health<<endl;
outFile<<"profile.space="<<profile.Space<<endl;
outFile<<"profile.day="<<profile.Day<<endl;
outFile<<"profile.gunrate="<<profile.GunRate<<endl;
outFile<<"loc.name="<<loc.Name<<endl;
outFile<<"loc.police="<<loc.Police<<endl;
outFile<<"loc.mindrugs="<<loc.minDrugs<<endl;
outFile<<"loc.maxdrugs="<<loc.maxDrugs;

outFile.close();

}
else
{
//open file
fstream inFile(Data.c_str(), ios::in);

//store information in file before the saved game for reprint
cnt=0;
inFile.getline(chrLine,2000);

//convert to string array
strOldData[cnt]=chrLine[0];
for (i=1; i<=1999; i++)
strOldData[cnt]=strOldData[cnt]+chrLine;

//load pre-saved game data
while (strOldData[cnt].find(profile.Name)==std::string::npos)
{
cnt++;

inFile.getline(chrLine,2000);

//convert to string array
strOldData[cnt]=chrLine[0];
for (i=1; i<=1999; i++)
strOldData[cnt]=strOldData[cnt]+chrLine;
};

//remove the profile from the pre-saved game data
strOldData[cnt-1]=" ";
strOldData[cnt]=" ";

//if the profile was found on the first getline
if (strOldData[1]==" ")
strOldData[0]=" ";

//store information in file after the saved game for reprint
inFile.getline(chrLine,2000);

//convert to string array
strTemp=chrLine[0];
for (i=1; i<=1999; i++)
strTemp=strTemp+chrLine;

//scan until it finds the line with the last stat in the saved game [loc.maxdrugs=12]
while (strTemp.find("loc.maxdrugs=12")==std::string::npos)
{
inFile.getline(chrLine,2000);

//convert to string array
strTemp=chrLine[0];
for (i=1; i<=1999; i++)
strTemp=strTemp+chrLine;
};

//store the rest of the file
cnt=0;
while (!(inFile.eof()))
{
inFile.getline(chrLine,2000);

//convert to string array
strOldData2[cnt]=chrLine[0];
for (i=1; i<=1999; i++)
strOldData2[cnt]=strOldData2[cnt]+chrLine;

cnt++;
};

//if the profile was found on the first getline
if (strOldData2[1]==" ")
strOldData2[0]=" ";

inFile.close();

//rewrite the begining old info [1]
cnt=1;
fstream outFile(Data.c_str(), ios::out);

if (!(strOldData[0]==" "))
outFile<<strOldData[0];

while (!(strOldData[cnt]==" "))
{
outFile<<endl<<strOldData[cnt];
cnt++;
};

//write new saved data
outFile<<endl<<endl;
outFile<<"profile.name="<<profile.Name<<endl;
outFile<<"profile.gun="<<profile.Gun<<endl;
outFile<<"profile.location="<<profile.Location<<endl;
outFile<<"profile.cash="<<profile.Cash<<endl;
outFile<<"profile.debt="<<profile.Debt<<endl;
outFile<<"profile.bank="<<profile.Bank<<endl;
outFile<<"profile.hentchmen="<<profile.Hentchmen<<endl;
outFile<<"profile.health="<<profile.Health<<endl;
outFile<<"profile.space="<<profile.Space<<endl;
outFile<<"profile.day="<<profile.Day<<endl;
outFile<<"profile.gunrate="<<profile.GunRate<<endl;
outFile<<"loc.name="<<loc.Name<<endl;
outFile<<"loc.police="<<loc.Police<<endl;
outFile<<"loc.mindrugs="<<loc.minDrugs<<endl;
outFile<<"loc.maxdrugs="<<loc.maxDrugs<<endl;

//rewrite the end old info [2]
cnt=1;

if (!(strOldData2[0]==" "))
outFile<<strOldData2[0];

while (!(strOldData2[cnt]==" "))
{
outFile<<endl<<strOldData2[cnt];
cnt++;
};

outFile.close();
}

//resume game
CityOperations(false);
}


//this class checks for bad convertions with stringify(int x)
class BadConversion : public std::runtime_error
{
public:
BadConversion(const std::string& s)
: std::runtime_error(s)
{ }
};

//converts ints into strings
inline std::string stringify(int x)
{
std::ostringstream o;
if (!(o << x))
throw BadConversion("stringify(int)");
return o.str();
}

//Prints the user data on the screen
void PrintStats()
{
//Function level Declarations
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);
string st;

//make stats 'YELLOW' (14) with 'blk bg' (0) [stats std color]
SetConsoleColors(hConsole, 14, 0);

//print stats
system("cls");
cout<<BufferStr("[" + profile.Name + "]",20)<<"Location: "<<profile.Location<<"\n";
st="Cash: " + stringify(profile.Cash);
cout<<BufferStr(st,20)<<"Debt: "<<profile.Debt<<"\n";
st="Bank: " + stringify(profile.Bank);
cout<<BufferStr(st,20)<<"Hentchmen: "<<profile.Hentchmen<<"\n";
st="Health: " + stringify(profile.Health);
cout<<BufferStr(st,20)<<"Free Space: "<<profile.Space<<"\n";
cout<<BufferStr("Gun: " + profile.Gun,20)<<"Day: "<<profile.Day<<"\n\n";

//revert to old colors
SetConsoleColors(hConsole, 15, 0);
}

//Fixes text into columns
string BufferStr(string strString, int MAX_LEN)
{
//Function level delcarations
int intSpaces;
string strTemp;

//add proper spaces after the string
intSpaces=MAX_LEN-strString.length();
strTemp=strString;
for (i=1; i<=intSpaces; i++)
strTemp=strTemp + " ";

//return new str
return (strTemp.c_str());
}

//Displays the profiles menu along with scanning the app's dir for the profile files within it.
string ProfileMenu()
{
//Function level Declarations
string Profile[100], Data=strPath + "\\profiles.dat", strTemp;
int intChoice=200, cnt=0, intTemp;
char chrLine[2000];
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

//initialize the profile array
for (i=0; i<=99; i++)
Profile=" ";

//storing the profiles into an array to be printed
ifstream inFile(Data.c_str());

//make stats 'RED' (12) with 'blk bg' (0) [warning std color]
SetConsoleColors(hConsole, 12, 0);
system("cls");

//check for file existence
if(!(inFile.good()))
{
//Print menu
cout<<"Drug Wars --- By: Derik Hammer\n\n";
cout<<"File 'profiles.dat' was not found no saved games are available.\n\n";
cout<<"Press any key to return to the Main Menu.";
getch();
inFile.close();
//return to main menu
system("cls");
MenuHandler();
}

while (!(inFile.eof()))
{
inFile.getline(chrLine,2000);
strTemp=chrLine;
//look for the name locator
if(!(strTemp.find("profile.name=")==std::string::npos))
{
intTemp=strTemp.find("name=")+5;
//remake the string with chrLine
strTemp=chrLine[intTemp];
for(i=intTemp+1;i<=1999;i++)
strTemp=strTemp+chrLine;
Profile[cnt]=strTemp;
cnt++;
}
};

//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);

//check for which menu to use
if (!(Profile[0]==" "))
{
//Print menu
cnt=0;
system("cls");
cout<<"Drug Wars --- By: Derik Hammer\n\n";

while (!(Profile[cnt]==" "))
{
cout<<cnt+1<<". "<<Profile[cnt]<<".\n";
cnt++;
};

cout<<"0. Back to Main Menu.\n";
cout<<"\nSelection: ";
//Await choice
cin>>intChoice;
strTemp=Profile[intChoice-1];

//loops if invalid numbers are entered.
while (strTemp==" ")
{
SetConsoleColors(hConsole, 10, 0);
//Print menu
cnt=0;
system("cls");
cout<<"Drug Wars --- By: Derik Hammer\n\n";

while (!(Profile[cnt]==" "))
{
cout<<cnt+1<<". "<<Profile[cnt]<<".\n";
cnt++;
};

cout<<"0. Back to Main Menu.\n";
cout<<"\nINVALID SELECTION PLEASE CHOOSE AGAIN!\n";
cout<<"Selection: ";
//Await choice
cin>>intChoice;
strTemp=Profile[intChoice];
}
}
else
{
//if there's no saved games print this menu
system("cls");
cout<<"Drug Wars --- By: Derik Hammer\n\n";
cout<<"Sorry no saved games were found.\n\n";
cout<<"Press any key to go back to the Main Menu.";
intChoice=0;
getch();
}

//revert to old colors
SetConsoleColors(hConsole, 15, 0);

//go back to main menu
if (intChoice==0)
return "MainMenu";

//Returns the name of the profile needed to be used
if (!(intChoice==200))
return(Profile[intChoice-1]);

//else return an error report
return "NULL";
}

//Displays the options for the Main Menu
int MainMenu()
{
//Function level Declarations
char chrChoice;
HANDLE hConsole = CreateFile("CONOUT$", GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
OPEN_EXISTING, 0, 0);

//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);

//Print menu
cout<<"Drug Wars --- By: Derik Hammer\n\n";
cout<<"1. New Game.\n";
cout<<"2. Load Profile.\n";
cout<<"3. Quit.\n\n";
cout<<"Selection: ";
//Await choice
cin>>chrChoice;

CheckAgain:
switch (chrChoice)
{
//Proceed with new game
case '1':
//revert to old colors
SetConsoleColors(hConsole, 15, 0);
return (1);
break;

//Proceed with loading profile menu
case '2':
//revert to old colors
SetConsoleColors(hConsole, 15, 0);
return (2);
break;

//Proceed with exiting the application
case '3':
//revert to old colors
SetConsoleColors(hConsole, 15, 0);
return (3);
break;

//Clear screen, reprint menu, notify invalid selection, and allow a second choice
default:
system("cls");
cout<<"Drug Wars --- By: Derik Hammer\n\n";
cout<<"1. New Game.\n";
cout<<"2. Load Profile.\n";
cout<<"3. Quit.\n\n";
//revert to old colors
SetConsoleColors(hConsole, 1, 0);
cout<<"INVALID SELECTION PLEASE CHOOSE AGAIN!\n";
cout<<"Selection: ";
cin>>chrChoice;
//make stats 'GREEN' (10) with 'blk bg' (0) [menu std color]
SetConsoleColors(hConsole, 10, 0);
goto CheckAgain;
}

//revert to old colors
SetConsoleColors(hConsole, 15, 0);

return(0);
}

// use Unicode (wide) version of GetModuleFileName
wstring get_module_path_wide(void)
{
wchar_t wide_buf[65536];
wstring module_name;

if(!GetModuleFileNameW(GetModuleHandle(0), wide_buf, 65535))
return module_name;

wide_buf[65535] = L'\0';

module_name = wide_buf;

size_t pos = module_name.find_last_of(L'\\');

if(pos != string::npos)
module_name = module_name.substr(0, pos);

return module_name;
}

// use this function to convert from wide wstring to ASCII string if need be
string wsts(const wstring &src_string)
{
size_t src_len = src_string.length();

if(src_len == 0)
return "";

char *buf = new(std::nothrow) char[src_len + 1];

if(buf == 0)
return "";

wcstombs(buf, src_string.c_str(), src_len);
buf[src_len] = '\0';

string final_string = buf;

if(buf != 0)
delete [] buf;

return final_string;
}

//Color Change functions
WORD GetConsoleColors(HANDLE hConsole)
{
// get current console text attributes
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
return csbi.wAttributes;
}

WORD SetConsoleColors(HANDLE hConsole, WORD wColorText, WORD wColorBkg = 0)
{
// get old text attributes
WORD wOldColors = GetConsoleColors(hConsole);

// set new text attributes
SetConsoleTextAttribute(hConsole, wColorText | (wColorBkg << 4));
return wOldColors;
}



Thanks
-Lordoftools

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!