hello
i made this black jack game its showing few bugs and stuff , spent a long :sad: time and i cannot figure out what to do . please help correcting :cry:
i would also appeciate a smaller version of this progrm. :surprised
thank you :cry:
this is for "tc.exe"
# include <iostream.h>
# include <conio.h>
# include <stdlib.h>
void main ()
{
clrscr();
int mode=99;
int mode2=69;
int long bal=1000;
int long bet=0;
int con1=1;
int con2=1;
int con3=1;
int con4=1;
int x=0;
int y=0;
int m=0;
int n=0;
int t1=0;
int t2=0;
int c=0;
int d=0;
int order;
int order2;
int order3;
int order21;
int order22;
int t3=0;
int spil=0;
int spil2=0;
randomize();
cout<<"INTRO"; //YET TO BE FILLED
getch();
clrscr();
while (mode==99)
{
clrscr();
cout<<"Enter your bet (YOUR BALANCE= $"<<bal<<" ) : $";
cin>>bet;
if (bet==123456789)
{
return;
}
if(bet<0)
{
bet=-bet;
}
if (bet==420840)
{
cout<<"WOW! the cheat code aye!\n"; //CHEATCODE
bal=1420840;
}
if ((bet>bal) && (bal>5))
{
cout<<"You dont have enough cash"<<endl;
cout<<"Your default bet : $"<<bal/100<<endl;
bet=bal/100;
getch();
}
if ((bet>bal) && (bet>=1) && (bet<=5))
{
cout<<"You dont have enought cash"<<endl;
cout<<"Your default bet : $1"<<endl;
bet=1;
getch();
}
if (bal==0)
{
cout<<"You ran out of money"<<endl;
cout<<"We have decided to throw you out of the casino"<<endl;
getch();
return;
}
cout<<"Your bet is $"<<bet<<endl;
bal=bal-bet;
cout<<"Your new balance : $"<<bal<<endl;
getch();
mode2=69; //just took 69 for no reason
while(mode2==69)
{
clrscr();
if (con1==1)
{
x=random(14)+1;
if (x<=10)
{
cout<<"You got card "<<x<<endl;
}
if (x==11)
{
cout<<"You got a jack"<<endl;
x=10;
}
if (x==12)
{
cout<<"You got a queen"<<endl;
x=10;
}
if (x==13)
{
cout<<"You got a King"<<endl;
x=10;
}
if (x==14)
{
cout<<"You got a `A'"<<endl;
x=11;
}
}
if (con2==1)
{
y=random(14)+1;
if (y<=10)
{
cout<<"You got card "<<y<<endl;
}
if (y==11)
{
cout<<"You got a jack"<<endl;
y=10;
}
if (y==12)
{
cout<<"You got a queen"<<endl;
y=10;
}
if (y==13)
{
cout<<"You got a King"<<endl;
y=10;
}
if (y==14)
{
cout<<"You got a `A'"<<endl;
y=11;
}
}
cout<<"\n";
if (spil==0)
{
t1=t1+x+y;
cout<<"Your Total : "<<t1;
}
if (spil==1)
{
t1=t1+x;
t3=t3+y;
cout<<"Your total 1) "<<t1<<endl;
cout<<"Your total 2) "<<t2<<endl;
}
getch();
cout<<endl<<endl;
if ((t1==21) && (t2!=21))
{
cout<<"You got a Black jack"<<endl;
cout<<"You win"<<endl;
bet=bet*2.5;
bal=bal+bet;
c=1;
mode2=0;
d=1;
}
if ((t2==21) && (t1!=21))
{
cout<<"Dealer got a Black jack"<<endl;
cout<<"You lose"<<endl;
bet=0;
c=1;
mode2=0;
d=1;
}
if ((t2==t1) && (t1==21))
{
cout<<"You and the dealer got a blackjack"<<endl;
cout<<"So you dont win"<<endl;
c=1;
mode2=0;
bet=0;
d=1;
}
if ((t1>21) && (t2<=21) && (c==0))
{
cout<<"You burst...!"<<endl;
cout<<"You lose\n";
mode2=0;
d=1;
}
if ((t2>21) && (t1<=21) &&(c==0))
{
cout<<"dealer burst...!"<<endl;
cout<<"You w\n";
bet=bet*2;
bal=bal+bet;
mode2=0;
d=1;
}
if ((con3==1) && (c==0))
{
m=random(14)+1;
if (m<=10)
{
cout<<"Dealer got card "<<m<<endl;
}
if (m==11)
{
cout<<"Dealer got a jack"<<endl;
m=10;
}
if (m==12)
{
cout<<"Dealer got a queen"<<endl;
m=10;
}
if (m==13)
{
cout<<"Dealer got a King"<<endl;
m=10;
}
if (m==14)
{
cout<<"Dealer got a `A'"<<endl;
m=11;
}
}
if ((con4==1) && (c==0));
{
n=random(14)+1;
if (n<=10)
{
cout<<"Dealer got card "<<n<<endl;
}
if (n==11)
{
cout<<"Dealer got a jack"<<endl;
n=10;
}
if (n==12)
{
cout<<"Dealer got a queen"<<endl;
n=10;
}
if (n==13)
{
cout<<"Dealer got a King"<<endl;
n=10;
}
if (n==14)
{
cout<<"Dealer got a `A'"<<endl;
n=11;
}
}
if (spil2==1)
{
t2=t2+m;
}
else
{
t2=m+n;
}
cout<<"\n\n";
cout<<"Dealers total : "<<t2<<endl;
cout<<"\n\n\n";
if ((t1==21) && (t2!=21))
{
cout<<"You got a Black jack"<<endl;
cout<<"You win"<<endl;
bet=bet*2.5;
bal=bal+bet;
c=1;
mode2=0;
d=1;
}
if ((t2==21) && (t1!=21) && (d==0))
{
cout<<"Dealer got a Black jack"<<endl;
cout<<"You lose"<<endl;
bet=0;
c=1;
mode2=0;
d=1;
}
if ((t2==t1) && (t1==21))
{
cout<<"You and the dealer got a blackjack"<<endl;
cout<<"So you dont win"<<endl;
c=1;
mode2=0;
bet=0;
d=1;
}
if ((t1>21) && (t2<=21) && (c==0))
{
cout<<"You burst...!"<<endl;
cout<<"You lose\n";
mode2=0;
d=1;
}
if ((t2>21) && (t1<=21) &&(c==0))
{
cout<<"dealer burst...!"<<endl;
cout<<"You win\n";
bet=bet*2;
bal=bal+bet;
mode2=0;
d=1;
}
if ((t2>21) && (t1>21) && (c==0))
{
cout<<"You both burst"<<endl;
cout<<"No-one wins"<<endl;
cout<<"But still you dont get anything..HAHA!"<<endl;
bet=0;
mode2=0;
d=1;
}
cout<<"\nPress any key to continue\n\n\n";
getch();
if (d==0)
{
con2=0;
con4=0;
clrscr();
cout<<"CHOOSE YOUR ORDER"<<endl;
cout<<"1)stay\n";
cout<<"2)hit\n";
if (x==y)
{
cout<<"3)split\n";
}
cout<<"ENTER YOUR ORDER : ";
cin>>order;
cout<<"\n\n";
if (order==1)
{
cout<<"You chose to stay\n";
cout<<"Your final score now is "<<t1<<endl;
con1=0;
}
if (order==2)
{
cout<<"You chose to hit\n";
cout<<"Your current score is "<<t1<<endl;
}
if (spil==1)
{
t1=t1+x;
t3=t3+y;
if (order21==1)
{
t1=t1-x;
}
if (order22==1)
{
t3=t3-y;
}
cout<<"1)You got "<<t1<<endl;
cout<<"2)You got "<<t3<<endl;
if (order21==0)
{
cout<<"CHOOSE For the first"<<endl;
cout<<"1)stay\n";
cout<<"2)hit\n";
cout<<"Your choice : ";
cin>>order2;
if (order2==1)
{
cout<<"You decided to stay on that card\n";
order21=1;
}
if (order2==2)
{
cout<<"You decided to hit\n";
}
if (order2>2)
{
cout<<"Thats no choice, dude\n";
cout<<"For not paying attention\n";
cout<<"You have been kicked out of the casino\n";
return;
}
if (order22==0)
{
cout<<"CHOOSE For the second"<<endl;
cout<<"1)stay\n";
cout<<"2)hit\n";
cout<<"Your choice : ";
cin>>order3;
if (order3==1)
{
cout<<"You decided to stay on that card\n";
order22=1;
con2=1;
}
if (order3==2)
{
cout<<"You decided to hit\n";
}
if (order3>2)
{
cout<<"Thats no choice, dude\n";
cout<<"For not paying attention\n";
cout<<"You have been kicked out of the casino\n";
return;
}
}
}
}
}
if ((order==3) && (x==y) && (spil==0))
{
t1=x;
t3=y;
cout<<"You decided to split\n";
cout<<"Your two different games are of\n";
cout<<"1) "<<t1<<endl;
cout<<"2) "<<t3<<endl;
con2=1;
spil=1;
}
if ((order>=3) && (x=!y))
{
cout<<"Thats no choice, dude\n";
cout<<"For not paying attention\n";
cout<<"You have been kicked out of the casino\n";
return;
}
getch();
if (d==0)
{
cout<<"\n\n";
cout<<"Dealer chose to ";
if ((t1>t2) && (con1==0) && (con3==0))
{
cout<<"hit";
con4=0;
con3=1;
int n=1;
}
if ((t2>17) && ((con1!=0) || (con2!=0)))
{
cout<<"stay";
con4=0;
con3=0;
}
if ((t2<18) && (n!=1))
{
cout<<"hit";
con4=0;
con3=0;
}
}
getch();
cout<<endl;
spil2=1;
if ((con1==0) && (con2==0) && (con3==0) && (con4==0))
{
if ((t2>=t1) && (t2>=t3) && (spil==1))
{
cout<<"You lost";
}
if ((((t2>=t1) && (t2<t3)) || ((t2<t1) && (t2>t3))) && (spil==1))
{
cout<<"You won on one and lost on other";
bet=bet*2;
bal=bal+bet;
}
if ((t2<t1) && (t2<t3) && (spil==1))
{
cout<<"You won on both cards";
bet=bet+3;
bal=bal+bet;
}
if (t1>t2)
{
cout<<"You won";
bet=bet*2;
bal=bal+bet;
}
if (t2>=t1)
{
cout<<"You lost";
}
d=1;
t1=0;
t2=0;
}
if (d==1)
{
int theend;
cout<<"\nTo exit press 119\n";
cout<<"To play again press any other number\n";
cin>>theend;
t1=0;
t2=0;
t3=0;
con1=1;
con2=1;
con3=1;
con4=1;
spil=0;
spil2=0;
d=0;
c=0;
n=1;
if (theend==119)
{
mode2=0;
mode=0;
return;
}
if (theend==999)
{
mode2=0;
}
}
x=0;
y=0;
m=0;
n=0;
}
//return;
}
}
<< moderator edit: added code tags: [code][/code] >>