#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int Your=6,Other=6;
string daojuname[]={"放大镜","手铐","小刀","烟","饮料"};
double Yourmoney;
int shi,kong;
int q[10],qlen;//1 实 2 空
int Rand(int x,int y){
int A=rand(),B=rand();
return A*1ll*B%(y-x+1)+x;
}
int T;//ou->you
int daojulen;
int daoju[10];
int daojulen1;
int daoju1[10];
void build_gun(){
kong=Rand(1,4);
shi=Rand(1,4);
qlen=0;
printf("%d发实弹,%d发空弹\n",shi,kong);
int a1=kong,a2=shi;
for(int i=1;i<=kong+shi;i++){
// Sleep(50);
int sum=Rand(1,a1+a2);
if(sum<=a1){
a1--;
q[++qlen]=2;
}else{
a2--;
q[++qlen]=1;
}
}
int maxn=min(4,8-daojulen);
printf("你获得了%d个道具:\n",maxn);
daojulen+=maxn;
for(int i=1;i<=maxn;i++){
// Sleep(50);
int kkk=Rand(0,4);
daoju[kkk]++;
cout<<daojuname[kkk];
if(i!=maxn){
printf(",");
}
}
printf("\n");
maxn=min(4,8-daojulen1);
printf("恶魔获得了%d个道具:\n",maxn);
daojulen1+=maxn;
for(int i=1;i<=maxn;i++){
int kkk=Rand(0,4);
daoju1[kkk]++;
cout<<daojuname[kkk];
if(i!=maxn){
printf(",");
}
}
printf("\n");
system("pause");
system("cls");
}
void IsOver(){
if(Your<=0){
printf("你输了\n");
system("pause");
exit(0);
}
if(Other<=0){
printf("你赢了\n你获得了奖金$%.2lf\n",Yourmoney);
system("pause");
exit(0);
}
}
void wait(){
for(int i=1;i<=3;i++){
Sleep(500);
printf(".");
}
Sleep(500);
}
int Hurt=1;
int shoukao_you;
void Timeyou(){
int x;
while(1){
printf("你的生命:%d/6\n恶魔生命:%d/6\n",Your,Other);
printf("剩余实弹数:%d 剩余空弹数:%d\n",shi,kong);
printf("你现在拥有的道具:\n");
for(int i=0;i<=4;i++){
cout<<daojuname[i];
printf("%d",daoju[i]);
printf("个");
if(i!=4){
printf(",");
}
}
printf("\n");
printf("恶魔现在拥有的道具:\n");
for(int i=0;i<=4;i++){
cout<<daojuname[i];
printf("%d",daoju1[i]);
printf("个");
if(i!=4){
printf(",");
}
}
printf("\n");
printf("现在是你的回合\n");
printf("你要\n1.向恶魔开枪\n2.向自己开枪\n");
for(int i=0;i<=4;i++){
printf("%d.使用",i+3);
cout<<daojuname[i]<<'\n';
}
scanf("%d",&x);
if(1<=x&&x<=7){
break;
}
printf("输入不合法\n");
Sleep(1145);
system("cls");
}
if(x==1){
printf("你决定向恶魔开枪");
T++;
wait();
if(q[qlen]==2){
Yourmoney+=(double)(2000.0*(Hurt*1.0)*(1+(double)(shi)*1.0/(double)(shi+kong)));
kong--;
qlen--;
Hurt=1;
printf("是空弹\n");
if(shoukao_you==1){
shoukao_you=0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}else{
// printf("((%lf))\n",Yourmoney);
Yourmoney+=(double)(5000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong)));
// printf("{
{%lf}}\n",Yourmoney);
shi--;
qlen--;
Other-=Hurt;
Hurt=1;
printf("是实弹\n");
Sleep(500);
IsOver();
if(shoukao_you==1){
shoukao_you=0;
Yourmoney+=1000.0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
}else if(x==2){
printf("你决定向自己开枪");
wait();
if(q[qlen]==0){
Yourmoney+=(double)(2000.0*(Hurt*1.0)*(1+(double)(kong)*1.0/(double)(shi+kong)));
kong--;
qlen--;
Hurt=1;
printf("是空弹\n");
}else{
Yourmoney+=5000.0*(1+(double)(shi)*1.0/(double)(shi+kong));
T++;
shi--;
qlen--;
Your-=Hurt;
Hurt=1;
printf("是实弹\n");
Sleep(500);
IsOver();
if(shoukao_you==1){
shoukao_you=0;
printf("因为你使用了手铐,所以可以再来一次\n");
Sleep(500);
T--;
}
}
}else if(x==3){//{"放大镜","手铐","小刀","烟","饮料"};
if(daoju[0]){
daoju[0]--;
daojulen--;
printf("你使用了放大镜\n");
wait();
printf("\n你看到了");
if(q[qlen]==1){
printf("实弹\n");
Yourmoney+=2500.0;
}else{
printf("空弹\n");
}
Sleep(500);
printf("\n");
}else{
printf("你现在没有放大镜\n");
Sleep(1145);
system("cls");
}
}else if(x==4){
if(daoju[1]){
if(!shoukao_you){
daoju[1]--;
daojulen--;