跳到正文

休闲·娱乐

狼人杀

HUANGKE99约 6 分钟
原文
文章信息与版本

文章信息

发布
2024年6月27日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 6 分钟

版本

  1. v2当前
  2. v1

狼人杀

注意!这时88人的

如果想玩五人的

改动 JobList[]JobList[] 和一些数字即可

CodeCode:

C++
#include<bits/stdc++.h>
using namespace std;
const int N=12;
//1 狼  2 民  3 巫  4 预  5 猎
const int Job_List[N]={0,
					   1,
					   2,
					   1,
					   2,
					   3,
					   4,
					   2,
					   5};
int Live_of_Player[N];
int Witch_of_Panacea;
int Witch_of_Poison;
int main(){
	for(int i=1;i<=8;i++){
		printf("玩家%d:",i);
		int Game_Player=Job_List[i];
		if(Game_Player==1)
			printf("你是 邪恶的[狼人]\n每天早上伪装成平民,晚上可以杀人");
		else if(Game_Player==2)
			printf("你是 手无寸铁的[平民]\n只能用推理保全自己的性命");
		else if(Game_Player==3)
			printf("你是 善恶两面的[女巫]\n每天晚上可以用[灵药]救人,也可以用[毒药]杀人");
		else if(Game_Player==4)
			printf("你是 神通广大的[算命先生(俗称:预言家)]\n每天晚上可以预言一个人的身份");
		else
			printf("你是 保护百姓的[猎人]\n每天晚上可以杀一个玩家(不管是好的还是坏的)");
		char ch;
		scanf("%c",&ch);
		system("cls");
	}
	int Good_Player=6;
	int Bad_Player=2;
	Witch_of_Panacea=1;
	Witch_of_Poison=1;
	while(Good_Player>0&&Bad_Player>0){
		printf("天黑了……\n");
		printf("狼人出来觅食了……\n");
		printf("神职人员的使命……\n");
		char ch;
		scanf("%c",&ch);
		system("cls");
		printf("天黑,请闭眼\n");
		for(int i=1;i<=8;i++){
			if(Job_List[i]==2||Live_of_Player[i]==1)
				continue;
			printf("玩家%d:",i);
			if(Job_List[i]==1){
				printf("狼人,你要杀谁?");
				int Kill;
				scanf("%d",&Kill);
				Live_of_Player[Kill]=-1;
			}else if(Job_List[i]==3){
				bool flag=0;
				printf("女巫,");
				if(Witch_of_Panacea){
					printf("你有一瓶灵药,今天");
					int Help;
					for(int j=1;j<=8;j++)
						if(Live_of_Player[j]==-1)
							printf("玩家%d ",j);
					printf("\n被杀了,你要救谁?");
					scanf("%d",&Help);
					Live_of_Player[Help]=0;
					if(Help!=0)
						Witch_of_Panacea--;
					printf("\n");
					flag=1;
				}
				if(Witch_of_Poison){
					printf("你有一瓶毒药,你要杀谁?");
					int Kill;
					scanf("%d",&Kill);
					Live_of_Player[Kill]=-1;
					if(Kill!=0)
						Witch_of_Poison--;
					printf("\n");
					flag=1;
				}
				if(!flag)
					printf("你什么都没有了");
			}else if(Job_List[i]==4){
				printf("预言家,你要预言谁?");
				int Problem;
				scanf("%d",&Problem);
				printf("玩家%d,是",Problem);
				if(Job_List[Problem]==1)
					printf("坏人");
				else
					printf("好人");
				char c;
				scanf("%c",&c);
			}else if(Job_List[i]==5){
				printf("猎人,你要杀谁?");
				int Kill;
				scanf("%d",&Kill);
				Live_of_Player[Kill]=-1;
			}
			char c;
			scanf("%c",&c);
			system("cls");
		}
		printf("天亮了\n昨晚");
		bool flag=1;
		for(int i=1;i<=8;i++)
			if(Live_of_Player[i]==-1){
				printf("玩家%d",i);
				if(Job_List[i]==1)
					printf("(属于 [狼人]阵营)  ");
				else
					printf("(属于 [平民]阵营)  ");
				Live_of_Player[i]=1;
				if(Job_List[i]==1)
					Bad_Player--;
				else
					Good_Player--;
				flag=0;
			}
		if(!flag)
			printf("死了");
		else
			printf("是个平安夜");
		char c;
		scanf("%c",&c);
		system("cls");
	}
	if(Bad_Player==0){
		printf("平民赢了……\n");
		printf("村庄恢复了宁静……\n");
		printf("狼人的尸体在村庄中被火化……\n");
		printf("丛林中再也没有狼嚎……");
	}else{
		printf("狼人赢了……\n");
		printf("村庄……有着死一般的宁静……\n");
		printf("村民的尸体,被狼人吃得只剩白骨……\n");
		printf("狼人,又开始对下一个村庄的屠杀……");
	}
	return 0;
}
原文