跳到正文

剪贴板

剪贴板 av1ncuyf

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include<bits/stdc++.h>
using namespace std;
int life[5]={0,5,5},cards[5][10];//players
bool hands[10];
int length,realb,fakeb,sum,curplayer=1,choice,curbullet,cnt;//gun
bool bullet[10];
int main()
{
	srand(time(0));
	cout<<"第1,2名玩家轮流拿枪,可以选择打自己或者打对方(分别为1和2)"<<endl;
	cout<<"每轮枪中都有若干棵实弹和空弹,空弹无伤害,实弹造成1点伤害"<<endl;
	cout<<"如果打自己"<<endl;
	cout<<"---空弹:打完后你继续持枪"<<endl;
	cout<<"---实弹:打完后换对手持枪"<<endl;
	cout<<"如果打对手,打完后必定换对手持枪"<<endl;
	cout<<"每人开局5点血量,换新的一轮(子弹打完换新)血量不变,血量归零则落败,血量最多10点"<<endl;
	cout<<"每人每轮都可以获得1至3个技能,分别如下(按3查看,按8退出)"<<endl;
	cout<<"---香烟:恢复1点生命值(按1使用)"<<endl;
	cout<<"---放大镜:检查弹膛中当前的子弹(按2使用)"<<endl;
	cout<<"---手铐:让对方下一回合无法行动(按3使用)"<<endl;
	cout<<"---手锯:霰弹枪造成2点伤害(按4使用)"<<endl;
	cout<<"---逆转器:切换弹膛内所有子弹为实弹或空弹(按5使用)"<<endl;
	cout<<"---过期药品:回复2至-2点血量(按6使用)"<<endl;
	cout<<"---饮料:可退掉当前枪内的1颗子弹(按7使用)"<<endl;
	cout<<"技能仅能在你持枪时使用"<<endl;
	cout<<"祝你好运"<<endl;
	cout<<endl;
	while(true)
	{
		start:
		memset(bullet,false,sizeof(bullet));
		memset(cards,0,sizeof(cards));
		for(int i=1;i<=rand()%4+1;i++) cards[1][rand()%7+1]++;
		for(int i=1;i<=rand()%4+1;i++) cards[2][rand()%7+1]++;
		sum=rand()%4+1;
		realb=2+rand()%(sum+1);
		sum+=4;
		cnt=sum;
		fakeb=sum-realb;
		curbullet=1;
		length=1;
		hands[1]=hands[2]=false;
		for(int i=1;i<=realb;i++)
		{
			int u=rand()%sum+1;
			if(bullet[u])
			{
				i--;
				continue;
			}
			else bullet[u]=true;
		}
		cout<<"新的一轮开始了"<<endl;
		while(true)
		{
			cout<<"目前玩家1有"<<life[1]<<"点血量;"<<"玩家2有"<<life[2]<<"点血量"<<endl;
			cout<<"此轮枪中有"<<sum<<"颗子弹,其中有"<<realb<<"个实弹"<<"和"<<fakeb<<"个空弹"<<endl;
			cout<<"本轮倍数为"<<length<<"倍"<<endl;
			cout<<"目前是玩家"<<curplayer<<"持枪"<<endl;
			cin>>choice;
			if(choice==3)
			{
				int op;
				cout<<"玩家"<<curplayer<<"有"<<cards[curplayer][1]<<"个香烟;"<<cards[curplayer][2]<<"个放大镜;"<<cards[curplayer][3]<<"个手铐;"<<cards[curplayer][4]<<"个手锯;"<<cards[curplayer][5]<<"个逆转器;"<<cards[curplayer][6]<<"个过期药品;"<<cards[curplayer][7]<<"个饮料"<<endl;
				cin>>op;
				if(op==8) goto out;
				if(cards[curplayer][op]==0)
				{
					cout<<"你没有此道具"<<endl;
					goto out;
				}
				if(op==1)
				{
					cout<<"你平复了心情,回复1点血量"<<endl;
					cards[curplayer][1]--;
					life[curplayer]++;
					life[curplayer]=min(10,life[curplayer]);
				}
				if(op==2)
				{
					if(bullet[curbullet]) cout<<"下一颗子弹为实弹"<<endl;
					else cout<<"下一颗子弹为空弹"<<endl;
					cards[curplayer][2]--;
				}
				if(op==3)
				{
					cout<<"你将玩家"<<3-curplayer<<"铐住了"<<endl;
					cards[curplayer][3]--;
					hands[curplayer]=true;
				}
				if(op==4)
				{
					cout<<"枪管被锯短了,伤害加倍"<<endl;
					cards[curplayer][4]--;
					length++;
				}
				if(op==5)
				{
					cout<<"所有膛内的子弹被逆转了"<<endl;
					cards[curplayer][5]--;
					swap(realb,fakeb);
					for(int i=curbullet;i<=cnt;i++) bullet[i]=1-bullet[i];
				}
				if(op==6)
				{
					int u=rand()%5-2;
					cards[curplayer][6]--;
					life[curplayer]+=u;
					life[curplayer]=min(10,life[curplayer]);
					cout<<"你食用了过期药品,";
					if(u==0) cout<<"什么也没有发生"<<endl;
					if(u>0) cout<<"回复了"<<u<<"点血量"<<endl;
					if(u<0) cout<<"扣除了"<<-u<<"点血量"<<endl;
					if(life[curplayer]<=0)
					{
						cout<<endl<<"玩家"<<curplayer<<"因吃过期药品中毒身亡"<<endl;
						cout<<"恭喜玩家"<<3-curplayer<<"获胜";
						return 0;
					}
				}
				if(op==7)
				{
					cout<<"你将饮料浇到枪上,";
					if(bullet[curbullet])
					{
						cout<<"推出了一颗实弹"<<endl;
						realb--;
						sum--;
						curbullet++;
					}
					else
					{
						cout<<"推出了一颗空弹"<<endl;
						fakeb--;
						sum--;
						curbullet++;
					}
					cards[curplayer][7]--;
				}
			}
			out:
			if(choice==1)
			{
				if(bullet[curbullet])
				{
					cout<<"啊!是实弹!"<<endl;
					life[curplayer]-=length;
					sum--;
					realb--;
					if(hands[curplayer]) hands[curplayer]=false;
					else curplayer=3-curplayer;
				}
				else
				{
					cout<<"砰,空弹!"<<endl;
					sum--;
					fakeb--;
				}
				curbullet++;
			}
			if(choice==2)
			{
				if(bullet[curbullet])
				{
					cout<<"啊!是实弹!"<<endl;
					life[3-curplayer]-=length;
					sum--;
					realb--;
					if(hands[curplayer]) hands[curplayer]=false;
					else curplayer=3-curplayer;
				}
				else
				{
					cout<<"砰,空弹!"<<endl;
					sum--;
					fakeb--;
					if(hands[curplayer]) hands[curplayer]=false;
					else curplayer=3-curplayer;
				}
				curbullet++;
			}
			if(life[1]<=0)
			{
				cout<<endl<<"恭喜玩家2获胜";
				return 0;
			}
			if(life[2]<=0)
			{
				cout<<endl<<"恭喜玩家1获胜";
				return 0;
			}
			if(sum==0) goto start;
		}
	}
	return 0;
}