#include<bits/stdc++.h> 
#include<time.h>
#include<windows.h>
using namespace std;
int hpmax=4,hp=4,dhp,dhpmax,money=0;
int yyb=0; 
int dj[20],ddj[20];//1:放大镜 
int main(){
	srand(time(0));
	cout<<"呵,欢迎来到恶魔轮盘赌……你可以在这里获得无限的金钱,或是一无所有的死亡……"<<endl;
	system("pause");
	system("cls");
	memset(ddj,0,sizeof(ddj));
	while(hp>0){
		cout<<"1.进入赌场 2.商店 3.游戏规则"<<endl;
		cout<<"你的血量:"<<hp<<"/"<<hpmax<<endl;
		int p;cin>>p;
		if(p==1){
			cout<<"恶魔:欢迎你的到来……"<<endl;
			system("pause");
			system("cls");
			dhp=rand()%4+4;dhpmax=dhp;
			int lun=0;
			int sd=0,kd=0,xb=6;
			int zd[21],xd=0;
			while(hp>0&&dhp>0){
				if(xb==6){
					cout<<"现在是换弹时间~~~~~"<<endl;
					for(int i=1;i<=5;++i){
						zd[i]=rand()%2+1;
						if(zd[i]==1)sd++;
						else kd++;
					}
					xb=1;
					Sleep(1500);
					system("pause");
					system("cls");
					int tmpdj[20],tmpddj[20];
					memset(tmpdj,0,sizeof(tmpdj));
					memset(tmpddj,0,sizeof(tmpddj));
					for(int i=1;i<=2;++i){
						int tmp=rand()%3;
						tmpdj[tmp+1]++; 
					}
					for(int i=1;i<=2;++i){
						int tmp=rand()%3;
						tmpddj[tmp+1]++;
					}
					cout<<"你获得了";
					if(tmpdj[1]!=0)cout<<tmpdj[1]<<"个放大镜!",dj[1]+=tmpdj[1];
					if(tmpdj[2]!=0)cout<<tmpdj[2]<<"个华子!",dj[2]+=tmpdj[2];
					if(tmpdj[3]!=0)cout<<tmpdj[3]<<"个小刀",dj[3]+=tmpdj[3];
					cout<<endl<<"恶魔获得了";
					if(tmpddj[1]!=0)cout<<tmpddj[1]<<"个放大镜!",ddj[1]+=tmpddj[1];
					if(tmpddj[2]!=0)cout<<tmpddj[2]<<"个华子!",ddj[2]+=tmpddj[2];
					if(tmpddj[3]!=0)cout<<tmpddj[3]<<"个小刀",ddj[3]+=tmpddj[3];
					cout<<endl;
					system("pause");
					system("cls");
				}
				cout<<"你的血量:"<<hp<<"/"<<hpmax<<endl;
				cout<<"敌人血量:"<<dhp<<"/"<<dhpmax<<endl;
				cout<<sd<<"枚实弹,"<<kd<<"枚空弹"<<endl; 
				cout<<"现在是第"<<xb<<"枚子弹"<<endl; 
				cout<<"你的道具:"<<endl;
				cout<<"放大镜"<<dj[1]<<"个,华子"<<dj[2]<<"个,小刀"<<dj[3]<<"个"<<endl; 
				cout<<"恶魔的道具:"<<endl;
				cout<<"放大镜"<<ddj[1]<<"个,华子"<<ddj[2]<<"个,小刀"<<ddj[3]<<"个"<<endl; 
				int dan=zd[xb];
				if(lun==0){
					cout<<"你要做什么?"<<endl;
					Sleep(200);
					cout<<"1.向恶魔开枪"<<endl;
					cout<<"2.向自己开枪"<<endl;
					cout<<"3.使用放大镜"<<endl; 
					cout<<"4.吸华子"<<endl;
					cout<<"5.割军败(划掉)割枪口"<<endl; 
					int dp;cin>>dp;
					if(dp==1){
						if(dan==1){
							cout<<"你打出了实弹,你重创了恶魔"<<endl;
							system("pause");
							system("cls");
							dhp-=1+xd,sd--;
						}else{
							cout<<"可惜,你打出了空弹"<<endl;
							system("pause");
							system("cls");
							kd--;
						}
						lun=1;
					}else if(dp==2){
						if(dan==1){
							cout<<"我觉得你是傻逼,因为你重创了自己"<<endl;
							system("pause");
							system("cls");
							hp-=1+xd;lun=1;sd--;
						}else{
							cout<<"幸好,你打出了空弹"<<endl;
							system("pause");
							system("cls");kd--;
						}
					}else if(dp==3){
						if(dj[1]==0){
							cout<<"你没有!"<<endl;
							system("pause");
							system("cls");
							continue;
						}
						if(zd[xb]==1){
							cout<<"这发是实弹!"<<endl;
						}else{
							cout<<"这发是空弹!"<<endl; 
						}dj[1]--;
						system("pause");
						system("cls");
						continue;
					}else if(dp==4){
						if(dj[2]==0){
							cout<<"你没有!"<<endl;
							system("pause");
							system("cls");
							continue;
						}
						if(hp==hpmax){
							cout<<"你是不是傻逼?你没受伤!!!"<<endl;
							system("pause");
							system("cls"); 
							continue;
						}
						cout<<"你吸了一根华子,回了一滴血!"<<endl;
						hp++;dj[2]--;
						system("pause");
						system("cls");
						continue;
					}else if(dp==5){
						if(dj[3]==0){
							cout<<"你没有!"<<endl;
							system("pause");
							system("cls");
							continue;
						}
						if(xd==1){
							cout<<"你是不是傻逼?你已经割了!"<<endl;
							system("pause");
							system("cls"); 
							continue;
						}
						cout<<"你割掉了枪口,如果这发是实弹,攻击伤害+1"<<endl;
						xd=1;dj[3]--;
						system("pause");
						system("cls");
						continue;
					}else{
						cout<<"请勿乱输!"<<endl;
						system("pause");
						system("cls");
						continue;
					}
					xd=0;
				}else{
					if(dhp!=dhpmax&&ddj[2]!=0){
						cout<<"恶魔吸了一根华子,回了一滴血!"<<endl;
						dhp++;ddj[2]--;
						system("pause");
						system("cls");
						continue;
					}
					int dp=rand()%2+1,fdj=0;
					if(sd==0)dp=2;
					else if(kd==0)dp=1;
					else if(ddj[1]!=0){
						cout<<"恶魔使用了放大镜!"<<endl;
						Sleep(1000);
						cout<<"VERY INTERESTING"<<endl;
						Sleep(500);
						if(zd[xb]==1){
							dp=1;fdj=1;
						}else{
							dp=2;
						}
						ddj[1]--;
					}
					if(fdj==1&&ddj[3]!=0){
						cout<<"恶魔割掉了枪口,如果这发是实弹,攻击伤害+1"<<endl;
						xd=1,ddj[3]--;
					}
					if(dp==1){
						cout<<"祂向你开枪!"<<endl;
						system("pause");
						if(dan==1){
							cout<<"恶魔打出了实弹,祂重创了你"<<endl;
							system("pause");
							system("cls");
							hp-=1+xd;sd--;
						}else{
							cout<<"幸好,祂打出了空弹"<<endl;
							system("pause");
							system("cls");kd--;
						}
						lun=0;
					}else if(dp==2){
						cout<<"祂向自己开枪!"<<endl;
						if(dan==1){
							cout<<"我觉得祂是傻逼,因为祂重创了自己"<<endl;
							system("pause");
							system("cls");
							dhp-=1+xd;lun=0;sd--;
						}else{
							cout<<"不幸的是,祂打出了空弹"<<endl;
							system("pause");
							system("cls");kd--;
						}
					}
					xd=0;
				}
				xb++;
				system("cls");
			}
			if(hp<=0){
				cout<<"你死了,你永远的死了……………………"<<endl;
				return 0;
			}
			else{
				int htk=rand()%10000+1500;
				money+=htk;
				cout<<"你赢了!你获得了"<<htk<<"块钱!"<<endl;
				system("pause");
				system("cls"); 
			} 
		}else if(p==2){
			system("cls");
			Sleep(200);
			cout<<"你要买什么?"<<endl;
			cout<<"1.医药包(必须立即使用,增加1点最大血量,只能用三次) 5000元"<<endl;
			cout<<endl<<"你有"<<money<<"块钱"<<endl; 
			int dp;cin>>dp;
			if(dp==1){
				if(money<5000){
					cout<<"买不起!"<<endl;
				}else if(yyb==3){
					cout<<"有点贪心了吧,规则不是说只能用三次吗……………………"<<endl;
				}else{
					cout<<"你买下医药包,翻出了里面的针管,将其插入体内"<<endl;
					Sleep(1500);
					cout<<"你又将纱布封在伤口上……"<<endl;
					Sleep(1500); 
					hpmax+=1;money-=5000;
					yyb++;
				}
			}
			system("pause"); 
		}else if(p==3){
			Sleep(2000);
			cout<<"1.这里的猎枪有5颗子弹"<<endl;
			cout<<"2.子弹中又分为实弹和空弹"<<endl;
			cout<<"3.每轮你可以选择对自己开枪或对恶魔开枪"<<endl;
			cout<<"4.如果你对自己开枪,若为空弹,则可以继续行动,否则,停止行动"<<endl;
			cout<<"5.如果你对恶魔开枪,无论如何,都将停止行动"<<endl;
			cout<<"6.同时,每一次子弹打空时,都会进入下一个回合"<<endl;
			cout<<"7.每个回合开始时,你和恶魔都可以获得两个道具"<<endl;
			cout<<"8.你可以把道具带出来,恶魔却不行"<<endl; 
			cout<<"道具一览:"<<endl;
			Sleep(500);
			cout<<"1.放大镜,可以看见接下来将要打出的子弹"<<endl; 
			cout<<"2.华子,可以回复一滴血"<<endl;
			system("pause");
			system("cls");
		}else{
			cout<<"呵"<<endl;
			Sleep(2000);
			cout<<"你是……"<<endl;
			Sleep(1500);
			cout<<"真的无聊啊……"<<endl;
			Sleep(2000);
			while(1)malloc(114514);
		}
		system("cls"); 
	}
	return 0;
}