A Jack of all trades
Knowledge Is Power. France Is Bacon
my attitude to life”carpe diem”
https://www.luogu.com.cn/paste/av1ncuyf
https://www.luogu.com.cn/paste/7dob90n5
https://www.luogu.me/article/fibmklp4
https://www.luogu.me/article/uolotbm5
https://www.luogu.me/article/x9dex7yu
https://www.luogu.me/article/5r6hyyi3
#include<bits/stdc++.h>
using namespace std;
int life[5]={0,5,5},cards[5][15];//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<<"每人每轮都可以获得2至4个技能,分别如下(按3查看,按10退出)"<<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<<"---肾上腺素:盗窃对方一个道具,并立即使用(按8使用)"<<endl;
cout<<"---究极无敌螺旋爆炸青龙偃月大砍刀:对对方造成1点伤害,然后对自己造成1点伤害(按9使用)"<<endl;
cout<<"技能仅能在你持枪时使用"<<endl;
cout<<"祝你好运"<<endl;
cout<<endl;
while(true)
{
start:
memset(bullet,false,sizeof(bullet));
for(int i=1;i<=rand()%3+2;i++) cards[1][rand()%9+1]++;
for(int i=1;i<=rand()%3+2;i++) cards[2][rand()%9+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)
{
int f=0;
if(f==1) break;
cout<<"目前玩家1有"<<life[1]<<"点血量;"<<"玩家2有"<<life[2]<<"点血量"<<endl;
cout<<"此轮枪中有"<<sum<<"颗子弹,其中有"<<realb<<"个实弹"<<"和"<<fakeb<<"个空弹"<<endl;
cout<<"本轮倍数为"<<length<<"倍"<<endl;
cout<<"目前是玩家"<<curplayer<<"持枪"<<endl;
cin>>choice;
if(choice==0)
{
cout<<endl<<"自暴自弃,走一个儿";
return 0;
}
/*if(choice==114514)
{
cout<<"恭喜你触发彩蛋"<<endl;
for(int i=1;i<=8;i++) cards[curplayer][i]=100000000;
}
if(choice==1919810)
{
cout<<"恭喜你触发彩蛋"<<endl;
for(int i=1;i<=8;i++) cards[3-curplayer][i]=0;
life[3-curplayer]=1;
}*/
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]<<"个饮料;"<<cards[curplayer][8]<<"个肾上腺素;"<<cards[curplayer][9]<<"个究极无敌螺旋爆炸青龙偃月大砍刀;"<<endl;
cin>>op;
if(op==10) goto out;
if(cards[curplayer][op]==0)
{
cout<<"你没有此道具"<<endl;
goto out;
}
if(op==0)
{
cout<<endl<<"自暴自弃,走一个儿";
return 0;
}
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<<"玩家"<<curplayer<<"因吃过期药品中毒身亡"<<endl<<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]--;
}
if(op==8)
{
cards[curplayer][8]--;
a:
int g;
cout<<"你开始盗窃对方道具,对方有";
cout<<cards[3-curplayer][1]<<"个香烟;"<<cards[3-curplayer][2]<<"个放大镜;"<<cards[3-curplayer][3]<<"个手铐;"<<cards[3-curplayer][4]<<"个手锯;"<<cards[3-curplayer][5]<<"个逆转器;"<<cards[3-curplayer][6]<<"个过期药品;"<<cards[3-curplayer][7]<<"个饮料;"<<cards[3-curplayer][8]<<"个肾上腺素;"<<cards[3-curplayer][9]<<"个究极无敌螺旋爆炸青龙偃月大砍刀"<<endl;
cin>>g;
if(g>=10||cards[3-curplayer][g]==0)
{
cout << "对方没有此道具" << endl;
goto a;
}
if(g==1)
{
cout<<"你平复了心情,回复1点血量"<<endl;
cards[3-curplayer][1]--;
life[curplayer]++;
life[curplayer]=min(10,life[curplayer]);
}
if(g==2)
{
if(bullet[curbullet]) cout<<"下一颗子弹为实弹"<<endl;
else cout<<"下一颗子弹为空弹"<<endl;
cards[3-curplayer][2]--;
}
if(g==3)
{
cout<<"你将玩家"<<3-curplayer<<"铐住了"<<endl;
cards[3-curplayer][3]--;
hands[curplayer]=true;
}
if(g==4)
{
cout<<"枪管被锯短了,伤害加倍"<<endl;
cards[3-curplayer][4]--;
length++;
}
if(g==5)
{
cout<<"所有膛内的子弹被逆转了"<<endl;
cards[3-curplayer][5]--;
swap(realb,fakeb);
for(int i=curbullet;i<=cnt;i++) bullet[i]=1-bullet[i];
}
if(g==6)
{
int u=rand()%5-2;
cards[3-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<<"玩家"<<curplayer<<"因吃过期药品中毒身亡"<<endl<<endl;
cout<<"恭喜玩家"<<3-curplayer<<"获胜";
return 0;
}
}
if(g==7)
{
cout<<"你将饮料浇到枪上,";
if(bullet[curbullet])
{
cout<<"推出了一颗实弹"<<endl;
realb--;
sum--;
curbullet++;
}
else
{
cout<<"推出了一颗空弹"<<endl;
fakeb--;
sum--;
curbullet++;
}
cards[3-curplayer][7]--;
}
if(g==8)
{
cards[3-curplayer][8]--;
goto a;
}
if(g==9)
{
cards[3-curplayer][9]--;
cout<<"伤敌一千!"<<endl;
life[3-curplayer]--;
if(life[3-curplayer]<=0)
{
cout<<"玩家"<<3-curplayer<<"被究极无敌螺旋爆炸青龙偃月大砍刀紫菜了"<<endl<<endl;
cout<<"恭喜玩家"<<curplayer<<"获胜";
return 0;
}
cout<<"自损八百!"<<endl;
life[curplayer]--;
if(life[curplayer]<=0)
{
cout<<"玩家"<<curplayer<<"被究极无敌螺旋爆炸青龙偃月大砍刀紫菜了"<<endl<<endl;
cout<<"恭喜玩家"<<3-curplayer<<"获胜";
return 0;
}
}
}
if(op==9)
{
cards[curplayer][9]--;
cout<<"伤敌一千!"<<endl;
life[3-curplayer]--;
if(life[3-curplayer]<=0)
{
cout<<"玩家"<<3-curplayer<<"被究极无敌螺旋爆炸青龙偃月大砍刀紫菜了"<<endl<<endl;
cout<<"恭喜玩家"<<curplayer<<"获胜";
return 0;
}
cout<<"自损八百!"<<endl;
life[curplayer]--;
if(life[curplayer]<=0)
{
cout<<"玩家"<<curplayer<<"被究极无敌螺旋爆炸青龙偃月大砍刀紫菜了"<<endl<<endl;
cout<<"恭喜玩家"<<3-curplayer<<"获胜";
return 0;
}
}
}
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;
}