2
已采纳
熊潇然
初级启示者
初级启示者
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
bool f;
string pipei[4]={"匹配中","匹配中.","匹配中..","匹配中..."};
int lieren[4],nvwu[4],yuyanjia[3],langren[4];//猎人4个 女巫4个 预言家3个 狼人4个
int a[35];//0 平民 1 狼人 2 猎人 3 女巫 4 预言家
int shengming[35];//30个人的生命值
string js;
int nn=1;
int vote[35];//30个人投票票数
bool fvote[35];//30个人是否已经投票
void cls(){//清屏
system("cls");
}
int changdu_l(string a){//提取字符长度
int ans=0,n=0,m=0;
while(a[n]!='\0'){
if((a[n]&0x80)!=0){
m+=2;
n+=2;
ans+=2;
}else{
n++;
ans++;
}
}
return ans;
}
void line(string a){//中对齐 该函数如需借鉴请先联系沙兴安
int l,w;
w=120;
if(a!="狼") l=changdu_l(a);//提取字符长度
else l=6;
for(int i=0;i<(w-l)/2;i++){
cout<<" ";
}
cout<<a;
return ;
}
void fenpei(){//分配角色
while(!(langren[0]&&langren[1]&&langren[2]&&langren[3])){//狼人 分配
int n=rand()%30+1;
if(!langren[0]){
a[n]=1;
langren[0]=n;
}else if(!langren[1]&&n!=langren[0]){
a[n]=1;
langren[1]=n;
}else if(!langren[2]&&n!=langren[0]&&n!=langren[1]){
a[n]=1;
langren[2]=n;
}else if(!langren[3]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]){
a[n]=1;
langren[3]=n;
}
}
cout<<endl;
line("狼人 匹配完成");
Sleep(rand()%5000+1500);
while(!(lieren[0]&&lieren[1]&&lieren[2]&&lieren[3])){//猎人 分配
int n=rand()%30+1;
if(!lieren[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]){
a[n]=2;
lieren[0]=n;
}else if(!lieren[1]&&n!=lieren[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]){
a[n]=2;
lieren[1]=n;
}else if(!lieren[2]&&n!=lieren[0]&&n!=lieren[1]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]){
a[n]=2;
lieren[2]=n;
}else if(!lieren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]){
a[n]=2;
lieren[3]=n;
}
}
cout<<endl;
line("猎人 匹配完成");
Sleep(rand()%5000+1500);
while(!(nvwu[0]&&nvwu[1]&&nvwu[2]&&nvwu[3])){//女巫 分配
int n=rand()%30+1;
if(!nvwu[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]){
a[n]=3;
nvwu[0]=n;
}else if(!nvwu[1]&&n!=nvwu[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]){
a[n]=3;
nvwu[1]=n;
}else if(!nvwu[2]&&n!=nvwu[0]&&n!=nvwu[1]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]){
a[n]=3;
nvwu[2]=n;
}else if(!nvwu[3]&&n!=nvwu[0]&&n!=nvwu[1]&&n!=nvwu[2]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]){
a[n]=3;
nvwu[3]=n;
}
}
cout<<endl;
line("女巫 匹配完成");
Sleep(rand()%5000+1500);
while(!(yuyanjia[0]&&yuyanjia[1]&&yuyanjia[2])){//预言家 分配
int n=rand()%30+1;
if(!yuyanjia[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]&&n!=nvwu[0]&&n!=nvwu[1]&&n!=nvwu[2]&&n!=nvwu[3]){
a[n]=4;
yuyanjia[0]=n;
}else if(!yuyanjia[1]&&n!=yuyanjia[0]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]&&n!=nvwu[1]&&n!=nvwu[2]&&n!=nvwu[3]){
a[n]=4;
yuyanjia[1]=n;
}else if(!yuyanjia[2]&&n!=yuyanjia[0]&&n!=yuyanjia[1]&&n!=langren[0]&&n!=langren[1]&&n!=langren[2]&&n!=langren[3]&&n!=lieren[0]&&n!=lieren[1]&&n!=lieren[2]&&n!=lieren[3]&&n!=nvwu[1]&&n!=nvwu[2]&&n!=nvwu[3]){
a[n]=4;
yuyanjia[2]=n;
}
}
cout<<endl;
line("预言家 匹配完成");
Sleep(rand()%5000+1500);
cout<<endl;
line("平民 匹配完成");
Sleep(rand()%5000+1500);
}
void cover_langrensha(){
line("狼人杀");
cout<<"\n------------------------------------------------------------------------------------------------------------------------\n";
if(!shengming[nn]){
line("你已**亡");
cout<<endl;
}else if(f){
string tmp;
if(a[nn]==0){
tmp="平民";
}else if(a[nn]==1){
tmp="狼人";
}else if(a[nn]==2){
tmp="猎人";
}else if(a[nn]==3){
tmp="女巫";
}else{
tmp="预言家";
}
line("你是 "+js+" 号 "+tmp);
cout<<endl;
}
}
bool check(){
for(int i=1;i<=30;i++){
if(a[i]!=-1){
return 0;
}
}
return 1;
}
int check_jieshu(){
int bad=0,good=0;
for(int i=1;i<=30;i++){
if(shengming[i]){
if(a[i]==1){
bad++;
}else{
good++;
}
}
}
if(bad>=good){
return 1;
}else if(bad==0){
return 2;
}else{
return 0;
}
}
void kaishiyouxi(){
cover_langrensha();
Sleep(1000);
line("开始匹配人数");
Sleep(1000);
for(int i=1;i<=3;i++){
cls();
cover_langrensha();
line(pipei[0]);
Sleep(500);
cls();
cover_langrensha();
line(pipei[1]);
Sleep(500);
cls();
cover_langrensha();
line(pipei[2]);
Sleep(500);
cls();
cover_langrensha();
line(pipei[3]);
Sleep(500);
}
cls();
cover_langrensha();
line("匹配成功!");
Sleep(3000);
cls();
cover_langrensha();
line("正在匹配其他人的角色,请耐心等待");
fenpei();
cls();
cover_langrensha();
int n=rand()%30+1;
char o1=n/10+'0',o2=n%10+'0';
nn=n;
js+=o1;
js+=o2;
line("你是 "+js+" 号!");
cout<<endl;
Sleep(1000);
if(a[nn]==0){
line("平民!");
}else if(a[nn]==1){
line("狼人!");
}else if(a[nn]==2){
line("猎人!");
}else if(a[nn]==3){
line("女巫!");
}else{
line("预言家!");
}
f=1;
Sleep(2000);
string h="";
while(!check()){
cls();
cover_langrensha();
memset(vote,0,sizeof(vote));
memset(fvote,0,sizeof(fvote));
Sleep(3000);
line("天黑请闭眼......");
cout<<endl;
Sleep(3000);
cls();
cover_langrensha();
for(int i=1;i<=30;i++){
n=rand()%30+1;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
int b;
if(i==nn&&a[i]!=0&&shengming[i]){
string ttt="剩余人数:";
for(int j=1;j<=30;j++){
if(shengming[j]){
o1=j/10+'0';
o2=j%10+'0';
ttt+=o1;
ttt+=o2;
ttt+=" ";
}
}
line(ttt);
cout<<endl;
if(a[i]==1||a[i]==2){
line("请选择你要杀的人");
cin>>b;
while(b<1||b>30){
cout<<endl;
line("输入错误");
cin>>b;
}
if(shengming[b]){
shengming[b]--;
}
h="";
o1=b/10+'0';
o2=b%10+'0';
h+=o1;
h+=o2;
line("你杀**了 "+h+" 号");
cout<<endl;
}else if(a[i]==3){
line("你要选择:1. 毒药 2. 解药");
char c;
c=getch();
cout<<endl;
if(c=='2'){
line("谁?");
cin>>n;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
if(!shengming[n]){
line("你救活了 "+h+" 号");
}else{
line("你给 "+h+" 号增加了1条生命");
}
shengming[n]++;
}else{
line("谁?");
cin>>n;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
line("你把一瓶毒药泼在了 "+h+" 号身上 TA**了");
shengming[n]=0;
}
}else if(a[i]==4){
line("你要预言谁?");
cin>>n;
if(a[n]==0){
line("TA是平民");
}else if(a[n]==1){
line("TA是狼人");
}else if(a[n]==2){
line("TA是猎人");
}else if(a[n]==3){
line("TA是女巫");
}else{
line("TA是预言家");
}
cout<<endl;
}
}else if(a[i]==1){
int cnt=0;
while(!shengming[n]){
n=rand()%30+1;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
if(cnt>=100){
break;
}
}
line("狼人杀**了 "+h+" 号");
shengming[n]--;
cout<<endl;
}else if(a[i]==2){
int cnt=0;
while(!shengming[n]){
n=rand()%30+1;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
if(cnt>=100){
break;
}
}
line("猎人杀**了 "+h+" 号");
shengming[n]--;
cout<<endl;
}else if(a[i]==3){
if(rand()%2==1){
if(!shengming[n]){
line("女巫救活了 "+h+" 号");
}else{
line("女巫给 "+h+" 号增加了1条生命");
}
shengming[n]++;
}else{
int cnt=0;
while(!shengming[n]){
n=rand()%30+1;
o1=n/10+'0';
o2=n%10+'0';
h="";
h+=o1;
h+=o2;
cnt++;
if(cnt>=100){
break;
}
}
line("女巫把一瓶毒药泼在了 "+h+" 号身上 TA**了");
shengming[n]=0;
}
cout<<endl;
}else if(a[i]==4){
line("预言家开始预言......");
n=rand()%30+1;
while(!shengming[n]){
n=rand()%30+1;
}
if(a[n]==1){
vote[n]++;
fvote[i]=1;
}
}
if(a[i]>0){
Sleep(3000);
cls();
cover_langrensha();
}
}
line("天亮了");
Sleep(3000);
cout<<endl;
if(check_jieshu()==1){
line("狼人胜利!");
break;
}else if(check_jieshu()==2){
line("好人胜利!");
break;
}
string ttt="存活人数:";
for(int i=1;i<=30;i++){
if(shengming[i]){
o1=i/10+'0';
o2=i%10+'0';
ttt+=o1;
ttt+=o2;
ttt+=" ";
}
}
line(ttt);
Sleep(3000);
cout<<endl;
line("开始投票......");
Sleep(3000);
cout<<endl;
if(shengming[nn]){
line("你要投谁?");
cin>>n;
cout<<endl;
while(!shengming[n]){
line("TA已**亡");
cin>>n;
cout<<endl;
}
vote[n]++;
}
for(int i=1;i<=30;i++){
if(i!=nn&&shengming[i]&&!fvote[i]){
n=rand()%30+1;
while(!shengming[n]){
n=rand()%30+1;
}
vote[n]++;
fvote[i]=1;
}
}
line("投票情况如下:");
cout<<endl;
int mx=0,pos;
for(int i=1;i<=30;i++){
if(shengming[i]){
if(vote[i]>mx){
mx=vote[i];
pos=i;
}
o1=i/10+'0';
o2=i%10+'0';
char o3=vote[i]/10+'0';
char o4=vote[i]%10+'0';
string t="";
t+=o3;
t+=o4;
h="";
h+=o1;
h+=o2;
Sleep(1500);
line(h+"号:"+t+"票");
cout<<endl;
}
}
Sleep(3000);
int fffff=0;
for(int i=1;i<=30;i++){
if(mx==vote[i]){
fffff++;
}
}
if(fffff>1){
line("没有人被投出去");
Sleep(3000);
continue;
}
o1=pos/10+'0';
o2=pos%10+'0';
h="";
h+=o1;
h+=o2;
line(h+" 号被投了出去");
shengming[pos]=0;
Sleep(3000);
if(check_jieshu()==1){
line("狼人胜利!");
break;
}else if(check_jieshu()==2){
line("好人胜利!");
break;
}
}
Sleep(3000);
cls();
shengming[nn]=1;
cover_langrensha();
line("1. 查看所有人的身份");
Sleep(1000);
cout<<endl;
line("2. 结束游戏");
char b;
b=getch();
while(b!='1'&&b!='2'){
cout<<endl;
line("输入错误");
b=getch();
}
if(b=='1'){
for(int i=1;i<=30;i++){
cout<<endl;
char o1,o2;
string j="";
o1=i/10+'0';
o2=i%10+'0';
j+=o1;
j+=o2;
if(a[i]==0){
j+=":平民";
}else if(a[i]==1){
j+=":狼人";
}else if(a[i]==2){
j+=":猎人";
}else if(a[i]==3){
j+=":女巫";
}else{
j+=":预言家";
}
line(j);
}
cout<<endl;
line("请点击任意继续......");
b=getch();
}
cls();
cover_langrensha();
line("欢迎下次再玩!");
}
void youxiguize(){//游戏规则
char a,b;
while(a!='0'){
cls();
cover_langrensha();
line("1. 平民");
cout<<endl;
line("2. 狼人");
cout<<endl;
line("3. 猎人");
cout<<endl;
line("4. 女巫");
cout<<endl;
line("5. 预言家");
cout<<endl;
line("0. 退出");
a=getch();
cls();
cover_langrensha();
if(a=='1'){
line("只有投票权,暂时没有其他技能");
}else if(a=='2'){
line("可以随机使一个人扣 1 点血");
}else if(a=='3'){
line("可以随机使一个人扣 1 点血");
}else if(a=='4'){
line("可以使用 毒药 和 解药");
cout<<endl;
Sleep(1000);
line("毒药:使一个人直接**亡");
cout<<endl;
Sleep(1000);
line("解药:使一个人增加 1 点血");
}else if(a=='5'){
line("可以预言一个人");
cout<<endl;
Sleep(1000);
line("如果预言家为人机,预言到狼人,就会在投票时投TA一票,否则随机投票");
}else{
break;
}
cout<<endl;
line("请点击任意继续......");
b=getch();
}
}
void guanyuzuozhe(){
line("姓名:熊潇然");
cout<<endl;
Sleep(1000);
line("前任工作室:EX-HSFX工作室副室长");
cout<<endl;
Sleep(1000);
line("现任工作室:WSX-HTC-365工作室副室长");
cout<<endl;
Sleep(1000);
line("酷丁问答里已达到新手天翼");
cout<<endl;
Sleep(1000);
line("line中对齐函数由兴安科技提供,此函数如需借鉴请先联系沙兴安 ");
cout<<endl;
Sleep(1000);
line("请点击任意继续......");
char a;
a=getch();
}
void langrensha_MAIN(){//狼人杀 主函数
srand(time(NULL));
for(int i=1;i<=30;i++){//生命值 初始化
shengming[i]=1;
}
system("color 01");
line("狼");
Sleep(1000);
system("color 06");
cout<<"人";
Sleep(1000);
system("color 04");
cout<<"杀\n";
Sleep(1000);
line("------------------------------------------------------------------------------------------------------------------------\n");
Sleep(1000);
char a;
while(a!='1'){
cls();
cover_langrensha();
line("1. 开始游戏(共30人)");
Sleep(1000);
cout<<endl;
line("2. 游戏规则");
Sleep(1000);
cout<<endl;
line("3. 关于作者");
a=getch();
cls();
cover_langrensha();
if(a=='2'){
youxiguize();
}else if(a=='3'){
guanyuzuozhe();
}
}
kaishiyouxi();
}
int main(){
langrensha_MAIN(); //狼人杀 主函数
return 0;
}
洛谷里面可以编译呀
1
1
马伟翔
初级光能
初级光能
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<windows.h>
using namespace std;
struct IDname{
int geshu;
string NAME;
};
IDname jue_se[100];
struct ID{
int num;
bool life;
string name;
int know;
int how;
};
ID player[21];
int n, MY, kill1, kill2;
char a;
bool jieyao = 1, duyao = 1;
int lieren, shouwei = 0;
void init1()
{
jue_se[1].NAME = "村民 ";
jue_se[2].NAME = "狼人 ";
jue_se[3].NAME = "女巫 ";
jue_se[4].NAME = "预言家 ";
jue_se[5].NAME = "猎人 ";
jue_se[6].NAME = "守卫 ";
}
void init2(int nn)
{
switch (nn)
{
case 6:
jue_se[1].geshu = 3;
jue_se[2].geshu = 2;
jue_se[3].geshu = 1;
jue_se[4].geshu = 0;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 7:
jue_se[1].geshu = 3;
jue_se[2].geshu = 2;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 8:
jue_se[1].geshu = 3;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 0;
jue_se[6].geshu = 0;
break;
case 9:
jue_se[1].geshu = 3;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 10:
jue_se[1].geshu = 4;
jue_se[2].geshu = 3;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 11:
jue_se[1].geshu = 4;
jue_se[2].geshu = 4;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 0;
break;
case 12:
jue_se[1].geshu = 4;
jue_se[2].geshu = 4;
jue_se[3].geshu = 1;
jue_se[4].geshu = 1;
jue_se[5].geshu = 1;
jue_se[6].geshu = 1;
break;
default:
cout << "输入错误,再见" << endl;
exit(0);
break;
}
}
int van[10] = { 7,4,6,43,35,1,2,8,20,19 };
void init3(int nn)
{
srand(time(0));
Sleep(rand() % 44);
int x = 10000;
int t = rand();
srand(time(NULL));
int y = van[(rand() % 100 * van[rand() % 10] + t) % 10];
if (nn <= 6)
x = abs(x * 6 / y) % 3 + 1;
else if (nn <= 8)
x = abs(x * 7 / y) % 4 + 1;
else if (nn <= 11)
x = abs(x * 8 / y) % 5 + 1;
else if (nn <= 14)
x = abs(x * 9 / y) % 6 + 1;
do
{
if (nn <= 6)
x = x % 3 + 1;
else if (nn <= 8)
x = x % 4 + 1;
else if (nn <= 11)
x = x % 5 + 1;
else if (nn <= 14)
x = x % 6 + 1;
if (jue_se[x].geshu > 0)
{
player[nn].name = jue_se[x].NAME;
if (player[nn].name == "猎人 ")
lieren = nn;
if (player[nn].name == "守卫 ")
shouwei = nn;
player[nn].life = 1;
player[nn].num = nn;
player[nn].know = 0;
jue_se[x].geshu--;
player[nn].how = 0;
break;
}
} while (jue_se[x].geshu == 0);
}
void printhhh()
{
int cm = 0;
int sz = 0;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 0)
continue;
else if (player[i].name == "村民 ")
cm++;
else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 " || player[i].name == "守卫 ")
sz++;
}
if (sz == 0 || cm == 0)
cout << "狼人阵营胜利" << endl;
else
cout << "好人阵营胜利" << endl;
for (int i = 1; i <= n; i++)
{
cout << left << setw(3) << player[i].num << ": " << player[i].name << " ";
if (player[i].life == 0)
cout << "**亡" << "\t";
else
cout << "存活" << "\t";
if (player[i].how == 0)
cout << "最终存活 " << endl;
else if (player[i].how == 1)
cout << "最终被狼人杀**" << endl;
else if (player[i].how == 2)
cout << "最终被投票投**" << endl;
else if (player[i].how == 3)
cout << "最终被女巫毒**" << endl;
else if (player[i].how == 4)
cout << "最终被猎人射杀" << endl;
}
system("pause");
system("pause");
system("pause");
}
void print(int day, int ti)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << "\t\t\t\t第" << day << "天 ";
if (ti == 0)
cout << "白天" << endl;
else
cout << "夜晚" << endl;
cout << "我的位置:" << MY << "号" << endl;
for (int i = 1; i <= 6; i++)
{
cout << player[i].num << "号位 ";
}
cout << endl;
for (int i = 1; i <= 6; i++)
{
if (player[i].life == 1)
{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
cout << "存活 ";
}
else
{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "已**亡 ";
}
}
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << endl;
for (int i = 1; i <= 6; i++)
{
if (player[i].know == 0)
cout << "未知 ";
else if (player[i].know == 1)
{
if (player[i].name == "狼人 ")
cout << "狼人 ";
else
cout << "好人 ";
}
else if (player[i].know == 2)
cout << player[i].name << " ";
}
cout << endl << endl;
for (int i = 7; i <= n; i++)
{
if (i < 10)
cout << player[i].num << "号位 ";
else
cout << player[i].num << "号位 ";
}
cout << endl;
for (int i = 7; i <= n; i++)
{
if (player[i].life == 1)
{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_GREEN);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_GREEN);
cout << "存活 ";
}
else
{
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY | FOREGROUND_RED);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED);
cout << "已**亡 ";
}
}
if (ti == 0)
SetConsoleTextAttribute(handle, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
else
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << endl;
for (int i = 7; i <= n; i++)
{
if (player[i].know == 0)
cout << "未知 ";
else if (player[i].know == 1)
{
if (player[i].name == "狼人 ")
cout << "狼人 ";
else
cout << "好人 ";
}
else if (player[i].know == 2)
cout << player[i].name << " ";
}
cout << endl << endl;
}
int shou = 0;
void shoushui(int hhh, int hhhh)
{
int x;
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "守~卫~请~睁~眼~~~" << endl;
Sleep(3000);
system("cls");
print(hhh, hhhh);
if (MY == shouwei && player[MY].life == 1)
{
cout << "请问你要守护谁?" << endl << "输入:";
cin >> x;
while (x == shou || x<1 || x>n || player[x].life == 0)
{
cout << "输入错误,请重新输入" << endl << "输入:";
cin >> x;
}
shou = x;
}
else if (player[shouwei].life == 1)
{
cout << "请问你要守护谁?" << endl;
Sleep(rand() % 98);
srand(time(0));
x = rand() % n + 1;
while (x == shou || player[x].life == 0)
{
Sleep(rand() % 98);
srand(time(0));
x = rand() % n + 1;
}
shou = x;
}
else
{
cout << "请问你要守护谁?" << endl;
Sleep(3000);
shou = -1;
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "守~卫~请~闭~眼~~~" << endl;
}
struct tou
{
int xxx;
int num;
int toupiaoquan;
};
tou TOU[13];
bool cmp(tou x, tou y)
{
if (x.xxx == y.xxx)
return x.num < y.num;
return x.xxx > y.xxx;
}
bool cmp1(tou x, tou y)
{
return x.num < y.num;
}
void toupiao(int ddd, int nnn)
{
//--------1--------
int x;
Sleep(2000);
system("cls");
print(ddd, nnn);
cout << "现在大家请投票";
for (int i = 1; i <= 3; i++)
{
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++)
{
TOU[i].num = i;
TOU[i].toupiaoquan = 1;
TOU[i].xxx = 0;
}
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1)
{
Sleep(3000);
if (i == MY)
{
cout << "请投票...(0弃权)" << endl;
cin >> x;
while (player[x].life == 0 && x != 0)
{
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
srand(time(0));
if (player[i].name == "狼人 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i))
{
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i))
{
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i))
{
Sleep(rand() % 98);
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx)
{
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
Sleep(3000);
return;
}
else
{
TOU[1].toupiaoquan = 0;
TOU[2].toupiaoquan = 0;
system("cls");
print(ddd, nnn);
cout << TOU[1].num << "号," << TOU[2].num << "号";
int i;
for (i = 3; i <= n; i++)
{
if (TOU[i].xxx == TOU[1].xxx)
{
TOU[i].toupiaoquan = 0;
cout << "," << TOU[i].num << "号";
}
else
break;
}
if (i == n + 1)
{
for (int i = 1; i <= n; i++)
TOU[i].toupiaoquan = 1;
}
cout << "平票" << endl;
}
//--------2--------
sort(TOU + 1, TOU + n + 1, cmp1);
cout << "请再次投票";
for (int i = 1; i <= 3; i++)
{
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
{
Sleep(3000);
if (i == MY)
{
cout << "请投票...(0弃权)" << endl;
cin >> x;
while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
{
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
srand(time(0));
if (player[i].name == "狼人 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0 && TOU[i].toupiaoquan == 1)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx)
{
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
Sleep(3000);
return;
}
else
{
TOU[1].toupiaoquan = 0;
TOU[2].toupiaoquan = 0;
system("cls");
print(ddd, nnn);
cout << TOU[1].num << "号," << TOU[2].num << "号";
int i;
for (i = 3; i <= n; i++)
{
if (TOU[i].xxx == TOU[1].xxx)
{
TOU[i].toupiaoquan = 0;
cout << "," << TOU[i].num << "号";
}
else
break;
}
if (i == n + 1)
{
for (int i = 1; i <= n; i++)
TOU[i].toupiaoquan = 1;
}
cout << "平票" << endl;
}
//--------3--------
sort(TOU + 1, TOU + n + 1, cmp1);
cout << "请再次投票";
for (int i = 1; i <= 3; i++)
{
cout << ".";
Sleep(500);
}
cout << endl;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1 && TOU[i].toupiaoquan == 1)
{
Sleep(3000);
if (i == MY)
{
cout << "请投票...(0弃权)" << endl;
cin >> x;
while ((player[x].life == 0 || TOU[x].toupiaoquan == 1) && x != 0)
{
cin >> x;
}
if (x == 0)
cout << MY << "号玩家弃权" << endl;
else
cout << MY << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
srand(time(0));
if (player[i].name == "狼人 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name == "狼人 " || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else if (player[i].name == "预言家 " || player[i].name == "猎人 ")
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || player[x].name != "狼人 " || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
else
{
x = rand() % (n + 1);
while (x != 0 && (player[x].life == 0 || x == i || TOU[x].toupiaoquan == 1))
{
srand(time(0));
x = rand() % (n + 1);
}
if (x == 0)
cout << i << "号玩家弃权" << endl;
else
cout << i << "号玩家投给了" << x << "号玩家" << endl;
}
}
if (x != 0 && TOU[i].toupiaoquan == 1)
TOU[x].xxx++;
}
}
Sleep(3000);
sort(TOU + 1, TOU + n + 1, cmp);
if (TOU[2].xxx != TOU[1].xxx)
{
cout << "投票结束," << TOU[1].num << "号投票出局" << endl;
player[TOU[1].num].life = 0;
player[TOU[1].num].how = 2;
}
else
{
cout << "投票结束,无人出局" << endl;
}
Sleep(5000);
}
bool game_over()
{
int pingmin = 0;
int langren = 0;
int shenzhi = 0;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 0)
continue;
if (player[i].name == "狼人 ")
langren++;
else if (player[i].name == "村民 ")
pingmin++;
else if (player[i].name == "女巫 " || player[i].name == "预言家 " || player[i].name == "猎人 ")
shenzhi++;
}
if (shenzhi == 0 || langren == 0 || pingmin == 0)
return 1;
return 0;
}
void night()
{
system("cls");
system("color 0f");
print(1, 1);
cout << "天~黑~请~闭~眼~~~" << endl;
if (n >= 12)
shoushui(1, 1);
Sleep(3000);
system("cls");
print(1, 1);
cout << "狼~人~请~睁~眼~~~" << endl;
if (player[MY].name == "狼人 ")
{
Sleep(1000);
cout << "你的同伴有:";
for (int i = 1; i <= n; i++)
{
if (i == MY)
continue;
if (player[i].name == "狼人 ")
{
cout << player[i].num << "号 ";
player[i].know = 2;
}
}
Sleep(3000);
cout << endl << "请问你们要杀谁:" << endl << "输入:";
cin >> kill1;
Sleep(1500);
system("cls");
print(1, 1);
cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
}
else
{
Sleep(4000);
system("cls");
print(1, 1);
cout << "请问你们要杀谁?" << endl;
do
{
Sleep(rand() % 18);
srand(time(0));
int x = rand() % n + 1;
if (player[x].name != "狼人 " && player[x].life == 1)
{
kill1 = x;
break;
}
} while (1);
Sleep(5000);
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "狼~人~请~闭~眼~~~" << endl;
Sleep(2000);
system("cls");
print(1, 1);
cout << "女~巫~请~睁~眼~~~" << endl;
Sleep(2000);
system("cls");
print(1, 1);
if (player[MY].name == "女巫 " && player[MY].life == 1)
{
Sleep(1000);
if (jieyao == 1)
{
cout << "今晚" << kill1 << "号玩家被杀" << endl;
Sleep(500);
cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
cin >> a;
if (a == 'A')
{
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl;
Sleep(2000);
system("cls");
print(1, 1);
cout << "今晚" << kill1 << "号玩家被你解救" << endl;
jieyao = 0;
if (shou != kill1)
kill1 = 0;
}
else
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(1, 1);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else
{
bool b = 0;
cout << "请问你是否要用解药???" << endl;
int FFF = 0, kkkk;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1 && player[i].name == "村民 ")
FFF++;
if (player[i].name == "女巫 ")
kkkk = i;
}
if (jieyao == 1 && player[kkkk].life == 1)
{
if (FFF == 1)
{
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
kill1 = 0;
b = 1;
}
else
for (int i = 1; i <= n; i++)
{
if (player[i].name == "女巫 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
else if (player[i].name == "预言家 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
}
}
Sleep(3000);
if (b == 0 && duyao == 1 && player[kkkk].life == 1)
{
system("cls");
print(1, 1);
cout << "请问你是否要用毒药???" << endl;
srand(time(0));
int x = rand() % 2;
Sleep(1500);
cout << "请问你要毒谁???" << endl;
if (x == 1)
{
duyao = 0;
int y = rand() % n + 1;
while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
y = rand() % n + 1;
kill2 = y;
}
}
else
{
Sleep(3000);
system("cls");
print(1, 1);
cout << "请问你是否要用毒药???" << endl;
Sleep(3000);
cout << "请问你要毒谁???" << endl;
Sleep(3000);
}
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "女~巫~请~闭~眼~~~" << endl;
if (n > 6)
{
Sleep(3000);
system("cls");
print(1, 1);
cout << "预~言~家~请~睁~眼~~~" << endl;
if (player[MY].name == "预言家 ")
{
Sleep(3000);
cout << "请问你想查验谁???" << endl << "输入:";
int x;
cin >> x;
player[x].know = 1;
Sleep(2000);
system("cls");
print(1, 1);
cout << "他的身份是:";
if (player[x].name == "狼人 ")
cout << "狼人" << endl;
else
cout << "好人" << endl;
Sleep(3000);
}
else
{
Sleep(3000);
cout << "请问你想查验谁???" << endl;
Sleep(3000);
system("cls");
print(1, 1);
cout << "他的身份是:......";
Sleep(3000);
}
Sleep(3000);
system("cls");
print(1, 1);
cout << "预~言~家~请~闭~眼~~~" << endl;
}
Sleep(3000);
if (kill1 != 0)
player[kill1].life = 0;
if (kill2 != 0)
player[kill2].life = 0;
player[kill1].how = 1;
player[kill2].how = 3;
system("cls");
system("color F0");
print(2, 0);
}
void night2(int hhh, int hhhh)
{
system("cls");
system("color 0f");
print(hhh, hhhh);
cout << "天~黑~请~闭~眼~~~" << endl;
if (n >= 12)
shoushui(hhh, hhhh);
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "狼~人~请~睁~眼~~~" << endl;
if (player[MY].name == "狼人 " && player[MY].life == 1)
{
Sleep(3000);
cout << endl << "请问你们要杀谁:" << endl << "输入:";
cin >> kill1;
Sleep(1500);
system("cls");
print(hhh, hhhh);
cout << "今晚你们要杀的是" << kill1 << "号玩家" << endl;
}
else
{
Sleep(4000);
system("cls");
print(hhh, hhhh);
cout << "请问你们要杀谁?" << endl;
do
{
srand(time(0));
int x = rand() % n + 1;
if (player[x].name != "狼人 " && player[x].life == 1)
{
kill1 = x;
break;
}
} while (1);
Sleep(5000);
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "狼~人~请~闭~眼~~~" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "女~巫~请~睁~眼~~~" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
if (player[MY].name == "女巫 " && player[MY].life == 1)
{
Sleep(1000);
if (jieyao == 1)
{
cout << "今晚" << kill1 << "号玩家被杀" << endl;
Sleep(500);
cout << "请问你要救吗???" << endl << "A. 救 B.不救" << endl << "输入:";
cin >> a;
if (a == 'A')
{
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "今晚" << kill1 << "号玩家被你解救" << endl;
jieyao = 0;
if (shou != kill1)
kill1 = 0;
}
else
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
}
else if (duyao == 1)
{
if (shou == kill1)
kill1 = 0;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl << "A. 毒 B.不毒" << endl << "输入:";
cin >> a;
if (a == 'A')
{
cout << "请问你要毒谁???" << endl << "输入:";
cin >> kill2;
while (player[kill2].life != 1)
{
cout << "输入错误,请重新输入:" << endl;
cin >> kill2;
}
duyao = 0;
}
}
else
{
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "请问你要毒吗???" << endl;
}
}
else
{
bool b = 0;
cout << "请问你是否要用解药???" << endl;
int FFF = 0, kkkk;
for (int i = 1; i <= n; i++)
{
if (player[i].life == 1 && player[i].name == "村民 ")
FFF++;
if (player[i].name == "女巫 ")
kkkk = i;
}
if (jieyao == 1 && player[kkkk].life == 1)
{
if (FFF == 1)
{
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
kill1 = 0;
b = 1;
}
else
for (int i = 1; i <= n; i++)
{
if (player[i].name == "女巫 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
else if (player[i].name == "预言家 " && kill1 == i)
{
kill1 = 0;
if (shou == kill1)
jieyao = 1;
else
jieyao = 0;
b = 1;
break;
}
}
}
Sleep(3000);
if (b == 0 && duyao == 1 && player[kkkk].life == 1)
{
system("cls");
print(hhh, hhhh);
cout << "请问你是否要用毒药???" << endl;
srand(time(0));
int x = rand() % 2;
Sleep(1500);
cout << "请问你要毒谁???" << endl;
if (x == 1)
{
duyao = 0;
int y = rand() % n + 1;
while ((player[y].name == "女巫 " || player[y].name == "预言家 " || y == kill1) || player[y].life == 0)
y = rand() % n + 1;
kill2 = y;
}
}
else
{
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "请问你是否要用毒药???" << endl;
Sleep(3000);
cout << "请问你要毒谁???" << endl;
Sleep(3000);
}
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "女~巫~请~闭~眼~~~" << endl;
if (n > 6)
{
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "预~言~家~请~睁~眼~~~" << endl;
if (player[MY].name == "预言家 " && player[MY].life == 1)
{
Sleep(3000);
cout << "请问你想查验谁???" << endl << "输入:";
int x;
cin >> x;
player[x].know = 1;
Sleep(2000);
system("cls");
print(hhh, hhhh);
cout << "他的身份是:";
if (player[x].name == "狼人 ")
cout << "狼人" << endl;
else
cout << "好人" << endl;
Sleep(3000);
}
else
{
Sleep(3000);
cout << "请问你想查验谁???" << endl;
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "他的身份是:......";
Sleep(3000);
}
Sleep(3000);
system("cls");
print(hhh, hhhh);
cout << "预~言~家~请~闭~眼~~~" << endl;
}
Sleep(3000);
if (kill1 != 0)
player[kill1].life = 0;
if (kill2 != 0)
player[kill2].life = 0;
player[kill1].how = 1;
player[kill2].how = 3;
system("cls");
system("color F0");
print(hhh + 1, 0);
}
bool lr = 0;
void panduanlieren()
{
if (lr == 1)
return;
if (MY == lieren)
{
cout << "请射杀一名玩家" << endl;
int x;
cin >> x;
while (player[x].life != 1)
{
cout << "输入错误,请重新输入" << endl;
cin >> x;
}
Sleep(1000);
cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
player[x].life = 0;
player[x].how = 4;
}
else if (n >= 9)
{
srand(time(0));
int x = rand() % n + 1;
while (player[x].life != 1)
{
x = rand() % n + 1;
}
Sleep(1000);
cout << lieren << "号猎人发动技能,开枪带走了" << x << "号" << endl;
player[x].life = 0;
player[x].how = 4;
}
lr = 1;
}
void print1()
{
cout << "天亮了,昨晚";
if (kill1 != 0 || kill2 != 0)
{
cout << kill1 << "号";
if (kill2 != 0)
{
cout << "," << kill2 << "号";
kill2 = 0;
}
cout << "被杀" << endl;
}
else
cout << "是平安夜" << endl;
}
int main()
{
system("cls");
cout << " " << "狼人杀online" << endl;
cout << "请输入人数个数:" << endl;
scanf("%d", &n);
cout << "加载时间长,请耐心等待";
init1();
init2(n);
int k = 1;
do
{
srand(time(0));
init3(k);
cout << ".";
Sleep(17);
k++;
} while (k <= n);
system("cls");
system("color F0");
cout << "游戏即将开始";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
Sleep(1500);
cout << endl << endl << "请大家查看身份牌......" << endl;
Sleep(45);
srand(time(0));
MY = rand() % n + 1;
cout << "您的身份是:" << player[MY].name << endl;
Sleep(500);
cout << "在" << player[MY].num << "号位上" << endl;
system("pause");
system("cls");
player[MY].know = 2;
print(1, 0);
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night();
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(2, 0);
system("cls");
print(2, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(2, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(3, 0);
system("cls");
print(3, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(3, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(4, 0);
system("cls");
print(4, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(4, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(5, 0);
system("cls");
print(5, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(5, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(6, 0);
system("cls");
print(6, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
cout << "即将进入夜晚";
for (int i = 1; i <= 6; i++)
{
cout << ".";
Sleep(500);
}
night2(6, 1);
print1();
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
if (player[lieren].life == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
toupiao(7, 0);
system("cls");
print(7, 0);
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
else if (player[lieren].life == 0 && lr == 0)
{
panduanlieren();
}
if (game_over())
{
Sleep(1000);
system("cls");
cout << "游戏结束" << endl; printhhh();
return 0;
}
while (1)
system("pause");
return 0;
}
0
0