跳到正文

休闲·娱乐

轮盘赌,版本1.0.0

cjn1122334约 11 分钟
原文
文章信息与版本

文章信息

收录
2025年12月24日
更新
2026年4月4日
篇幅
约 11 分钟

版本

  1. v2当前
  2. v1

我相信玩法我已经在代码中写的很清楚了

238行可放心食用,纯脚本。

1.1.0(道具更新),2.0.0(多人模式)敬请期待。


C++
#include<bits/stdc++.h>
using namespace std;
struct Node{
	bool b;
	int ri;
};
bool cmp(Node a,Node b){
	return a.ri>b.ri;
}
int empty_sum[3][100]{
	{2,3,2},
	{1,3,4,2,3,5,2,1,1,3,4,2,3,5,2,1,1,3,4,2,3,5,2,1},
	{2,4,3,2,4,3,5,1,3,2,4,3,2,4,3,5,1,3,2,4,3,2,4,3,5,1,3},
};
int full_sum[3][100]{
	{1,5,3},
	{1,5,4,3,5,3,3,1,1,5,4,3,5,3,3,1,1,5,4,3,5,3,3,1},
	{1,3,2,3,4,4,3,1,2,1,3,2,3,4,4,3,1,2,1,3,2,3,4,4,3,1,2},
};
int main(){
	string TI;
	cin>>TI;
	if(TI!="begin") return 0;
	cout<<"版本:1.0.0\n规则:朝自己开抢输入0,朝对方开抢输入1\n如果朝自己开抢时是空弹,则可重新开抢\n";
	cout<<"道具介绍:\n放大镜:可查看当前子弹类型\n啤酒:退掉一发子弹\n小刀:双倍伤害\n烟:回一点血\n手铐:紧固对面两回合\n";
	srand(time(0));
	for(int i=0;i<3;i++){
		int j=0;
		bool flag=true;
		cout<<"第"<<i+1<<"轮:\n";
		int red=4,blue=4;
		vector<int>blue_s;
		vector<int>red_s;
		if(i==0) red=2,blue=2;
		if(i>=1){
			for(int j=0;j<5;j++){
				blue_s.push_back(0);
				red_s.push_back(0);
				//0 glass 1 beer 2 knife 3 smoke 4 cuffs
			}
		}
		for(int j=0;flag;j++){
			if(i==1){
				int b1=rand()%5,b2=rand()%5;
				int r1=rand()%5,r2=rand()%5;
				blue_s[b1]++;
				blue_s[b2]++;
				red_s[r1]++;
				red_s[r2]++;
			}
			if(i==2){
				int b1=rand()%5,b2=rand()%5,b3=rand()%5,b4=rand()%5;
				int r1=rand()%5,r2=rand()%5,r3=rand()%5,r4=rand()%5;
				blue_s[b1]++;
				blue_s[b2]++;
				blue_s[b3]++;
				blue_s[b4]++;
				red_s[r1]++;
				red_s[r2]++;
				red_s[r3]++;
				red_s[r4]++;
			}
			vector<Node>bul;
			for(int k=0;k<full_sum[i][j];k++){
				Node x;
				x.b=true,x.ri=rand()%100;
				bul.push_back(x);
			}
			for(int k=0;k<empty_sum[i][j];k++){
				Node x;
				x.b=false,x.ri=rand()%100;
				bul.push_back(x);
			}
			sort(bul.begin(),bul.end(),cmp);
			vector<bool>bullet;
			for(int k=0;k<bul.size();k++){
				bullet.push_back(bul[k].b);
			}
			int l;
			bool b=true;
			bool blue_cuffs=false,red_cuffs=false;
			int reds=0,blues=0;
			cout<<"full:"<<full_sum[i][j]<<" empty:"<<empty_sum[i][j]<<endl;
			for(int k=0;k<bullet.size();k++){
				if(i>=1){
					cout<<"蓝方道具数量:\n";
					for(int l=0;l<blue_s.size();l++){
						//0 glass 1 beer 2 knife 3 smoke 4 cuffs
						if(l==0) cout<<"放大镜:"<<blue_s[l]<<"个 ";
						if(l==1) cout<<"啤酒:"<<blue_s[l]<<"个 ";
						if(l==2) cout<<"小刀:"<<blue_s[l]<<"个 ";
						if(l==3) cout<<"烟:"<<blue_s[l]<<"个 ";
						if(l==4) cout<<"手铐:"<<blue_s[l]<<"个\n";
					}
					cout<<"红方道具数量:\n";
					for(int l=0;l<blue_s.size();l++){
						//0 glass 1 beer 2 knife 3 smoke 4 cuffs
						if(l==0) cout<<"放大镜:"<<red_s[l]<<"个 ";
						if(l==1) cout<<"啤酒:"<<red_s[l]<<"个 ";
						if(l==2) cout<<"小刀:"<<red_s[l]<<"个 ";
						if(l==3) cout<<"烟:"<<red_s[l]<<"个 ";
						if(l==4) cout<<"手铐:"<<red_s[l]<<"个\n";
					}
				}
				if(b){
					cout<<"Blue:";
					l=1;
				}else{
					cout<<"Red:";
					l=0;
				}
				int USE=1;
				bool knife=false,glass=false,cuffs=false;
				if(i>=1){
					cout<<"请输入一串字符。注释:glass(放大镜) beer(啤酒) knife(小刀) smoke(烟) cuffs(手铐) empty(结束使用道具)\n";
					loop:
					string HI="empty";
					cin>>HI;
					if(l==1){
						if(HI=="glass"&&blue_s[0]>0&&glass==false){
							blue_s[0]--;
							glass=true;
							if(bullet[k]==0) cout<<"空弹\n";
							else cout<<"实弹\n";
							goto loop;
						}
						if(HI=="beer"&&blue_s[1]>0){
							blue_s[1]--;
							cout<<"退出的子弹为:";
							if(bullet[k]==0) cout<<"空弹\n";
							else cout<<"实弹\n";
							k++;
							if(k>=bullet.size()) break;
							goto loop;
						}
						if(HI=="knife"&&blue_s[2]>0&&knife==false){
							blue_s[2]--;
							knife=false;
							USE++;
							goto loop;
						}
						if(HI=="smoke"&&blue_s[3]>0){
							blue_s[3]--;
							blue++;
							goto loop;
						}
						if(HI=="cuffs"&&blue_s[4]>0&&cuffs==false){
							blue_s[4]--;
							cout<<"对方已被铐上\n";
							red_cuffs=true;
							cuffs=true;
							goto loop;
						}
					}else{
						if(HI=="glass"&&red_s[0]>0&&glass==false){
							red_s[0]--;
							glass=true;
							if(bullet[k]==0) cout<<"空弹\n";
							else cout<<"实弹\n";
							goto loop;
						}
						if(HI=="beer"&&red_s[1]>0){
							red_s[1]--;
							cout<<"退出的子弹为:";
							if(bullet[k]==0) cout<<"空弹\n";
							else cout<<"实弹\n";
							k++;
							if(k>=bullet.size()) break;
							goto loop;
						}
						if(HI=="knife"&&red_s[2]>0&&knife==false){
							red_s[2]--;
							knife=false;
							USE++;
							goto loop;
						}
						if(HI=="smoke"&&red_s[3]>0){
							red_s[3]--;
							red++;
							goto loop;
						}
						if(HI=="cuffs"&&red_s[4]>0&&cuffs==false){
							red_s[4]--;
							cout<<"对方已被铐上\n";
							blue_cuffs=true;
							cuffs=true;
							goto loop;
						}
					}
				}
				int DI;
				cin>>DI;
				if(bullet[k]==0) cout<<"空弹\n";
				else cout<<"实弹\n";
				if(DI==0&&bullet[k]==0){
					cout<<blue<<" "<<red<<endl;
					continue;
				}
				if(DI==0&&bullet[k]==1){
					if(l==1) blue-=USE;
					else red-=USE;
				}
				if(DI==1&&bullet[k]==1){
					if(l==1) red-=USE;
					else blue-=USE;
				}
				if(red<0) red++;
				if(blue<0) blue++;
				cout<<blue<<" "<<red<<endl;
				if(red==0){
					cout<<"Red died!!!\nBlue win!!!\n";
					flag=false;
					break;
				}
				if(blue==0){
					cout<<"Blue died!!!\nRed win!!!\n";
					flag=false;
					break;
				}
				if(red_cuffs==true) reds++;
				if(blue_cuffs==true) blues++;
				if(reds>=2){
					red_cuffs=false;
					reds=0;
					cout<<"红方手铐效果结束\n";
				}
				if(blues>=2){
					blue_cuffs=false;
					blues=0;
					cout<<"蓝方手铐效果结束\n";
				}
				if(b==true&&red_cuffs==false) b=false;
				else if(b==false&&blue_cuffs==false) b=true;
			}
		}
	}
    return 0;
}
原文