-
个人简介
小游戏 狼人杀 和 恶魔轮盘:
#include <iostream> #include <unistd.h> #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <queue> using namespace std;
int prop[10]; //你的道具 int pro[10]; //dealer的道具 //1:酒 2:烟 3:手铐 4:小刀 5:放大镜
queue<int> gun; //霰弹枪 1实弹,0空弹 int dealer, you; //血量 int red, black; // red红色实弹 black黑色空弹 bool de, yo; //是否戴着手铐 bool gunflag; //枪管是否被切除 string playername;
void win() //最好放在round(3); { system("cls"); cout << "你长出一口气,终于结束了" << endl; sleep (2); cout << "你擦了擦身上恶魔溅出的血,看向前方" << endl; sleep (2); cout << "黑暗中仿佛闪出了一双红色的眼睛,但马上又消失不见" << endl; sleep (2); cout << "两只机械臂伸出来,给你送来了一口大皮箱" << endl; sleep (2); cout << "你打开皮箱,里面装满了闪亮而崭新的美金" << endl; sleep (2); cout << "“......”" << endl; sleep (5); system("cls"); cout << "车辆颠簸地行驶着,车尾箱里放着那口沾血的大皮箱,和恶魔留在桌上的那把枪" << endl; sleep (2); cout << "你很多次差点就没命了" << endl; sleep (2); cout << "赌博对人有害,请勿陷入沉迷" << endl; sleep (2); cout << "“......”" << endl; sleep (1); cout << "你陷入了长久的沉默......" << endl; sleep (5); system("cls"); cout << "恭喜你,成功存活!" << endl; sleep (5); system("cls"); cout << "由于作者没有下载游戏,搞不清算分机制,所以算钱部分请忽略awa" << endl; sleep (3); cout << "作者技术不行,不会写恶魔的道具空间释放,所以道具数量没有上限,请见谅awa" << endl; sleep (3); cout << "感谢游玩!" << endl; sleep (2); cout << "游戏结束" << endl; sleep (2); system("cls"); }
void preparation(int r, int num) //随机子弹 { //r局数,num回合数 srand((unsigned int) time(0)); red = black = 0; if (r == 1) { //生成子弹 red = black = 1; if (num == 1) { if (rand() % 2 == 1) { gun.push(1); gun.push(0); } else { gun.push(0); gun.push(1); } } else { gun.push(1); gun.push(0); int s = rand() % 2; if (s == 1) { red++; gun.push(1); } else { black++; gun.push(0); } } return ; } if (r == 2) { if (num == 1) { red = black = 1; if (rand() % 2 == 1) { gun.push(1); gun.push(0); } else { gun.push(0); gun.push(1); } } else if (num == 2) { int t = 4; while (t--) { int s = rand() % (t + 1) % 2; if (s == 1) { red++; gun.push(1); } else { black++; gun.push(0); } } if (red == 0) { gun.push(1); gun.pop(); red++; black--; } if (black == 0) { gun.push(0); gun.pop(); black++; red--; } } else { int t = 6; while (t--) { int s = rand() % (t + 1) % 2; gun.push(s); if (s == 1) red++; else black++; } if (red == 0) { gun.push(1); gun.pop(); red++; black--; } if (black == 0) { gun.push(0); gun.pop(); black++; red--; } } return ; } if (r == 3) { int t = 8; while (t--) { int s = rand() % (t + 1) % 2; gun.push(s); if (s == 1) red++; else black++; } if (red == 0) { gun.push(1); gun.pop(); red++; black--; } if (black == 0) { gun.push(0); gun.pop(); black++; red--; } } return ; }
void round(int num);
void dead(int num) // 死亡;num为场数(I II III) { if (num == 3) { system("cls"); cout << "一阵眩晕过后,你睁开眼" << endl; sleep (2); cout << "面前的天空是一片空白,铁门生了锈,一堵墙横在身前" << endl; sleep (3); cout << "你走过去推开铁门,里面是一幅荒凉的景象" << endl; sleep (2); cout << "草地上,除了成千上万的顶天高的尖刺之外什么也没有" << endl; sleep (3); cout << "你不禁怀疑你在某个人的头皮上" << endl; sleep (2); cout << "你想起GOD的生死状" << endl; sleep (5); cout << "或许这里就是天堂" << endl; sleep (2); cout << "你抬起头看向花白的天空" << endl; sleep (10); cout << " YOU ARE" << endl; cout << " DEAD" << endl; sleep (5); return ; } cout << "你从厕所的地板醒过来" << endl; sleep (2); cout << "迎面看见一个乌漆嘛黑的人脸,他的手中拿着两个除颤仪" << endl; sleep (2); cout << "你认得他,他是之前趴在外面抽烟的人" << endl; sleep (2); cout << "“You're lucky it left you with a charge!”" << endl; cout << "他说" << endl; sleep (5); cout << "“Get up, " << playername << "." << endl; cout << "The night is young.”" << endl; sleep (3); cout << "说完,他便离开了。" << endl; sleep (2); cout << "你坐在地上缓了缓,接着走过去,再次一脚把门踹开" << endl; sleep (3); cout << "恶魔还等着你呢" << endl; sleep (2); cout << "恶魔又一次露出它诡异的笑容" << endl; sleep (2); cout << "“Welcome back.”" << endl; sleep (2); cout << "游戏,继续" << endl; if (num == 1) { round(1); } else { round(2); } }
bool flaggod = false; void random(int n) //抽取道具 { cout << "你看着这个小铁盒,将手伸了进去" << endl; sleep (1); srand((unsigned int) time(0)); int t = rand(); //玩家道具 cout << "(按任意键抽取道具)" << endl; sleep (2); for (int i = 1; i <= n; i++) { cout << "摸:"; string s; cin >> s; cout << endl; sleep (2); if (n == 4 && i == 2 && flaggod == false) //GOD的生死状 { cout << "你摸着摸着,没摸出道具,却摸出了一张纸" << endl; sleep (2); cout << "这张纸分明是你方才签的那一种生死状,而上面写着的名字,竟是“GOD”!" << endl; sleep (2); cout << "上面布满的血迹仿佛和你诉说着什么" << endl; sleep (1); cout << "一股不明的力量迫使你将生死状放了回去" << endl; sleep (2); cout << "你继续摸出你的道具" << endl; flaggod = true; } t = rand(); if ((t % 10 + 6 ) % 5 + 1 == 1) { cout << "你摸出来了一瓶酒" << endl; prop[1]++; } if ((t % 10 + 6 ) % 5 + 1 == 2) { cout << "你摸出来了一盒烟" << endl; prop[2]++; } if ((t % 10 + 6 ) % 5 + 1 == 3) { cout << "你摸出来了一副手铐" << endl; prop[3]++; } if ((t % 10 + 6 ) % 5 + 1 == 4) { cout << "你摸出来了一把小刀" << endl; prop[4]++; } if ((t % 10 + 6) % 5 + 1 == 5) { cout << "你摸出来了一个放大镜" << endl; prop[5]++; } sleep (2); } cout << "你摸完了道具,盒子缓缓地消失" << endl; sleep (4); system("cls"); //恶魔道具 for (int i = 1; i <= n; i++) { t = rand(); if ((t % 8 + 7) % 5 + 1 == 1) { pro[1]++; } if ((t % 8 + 7 ) % 5 + 1 == 2) { pro[2]++; } if ((t % 8 + 7 ) % 5 + 1 == 3) { pro[3]++; } if ((t % 8 + 7 ) % 5 + 1 == 4) { pro[4]++; } if ((t % 8 + 7 ) % 5 + 1 == 5) { pro[5]++; } } cout << "你看向对面,恶魔的道具有" << endl; cout << "酒:" << pro[1] << endl; cout << "烟:" << pro[2] << endl; cout << "手铐:" << pro[3] << endl; cout << "小刀:" << pro[4] << endl; cout << "放大镜:" << pro[5] << endl; sleep (5); }
void use(int num, int upper) { if (prop[1] + prop[2] + prop[3] + prop[4] + prop[5] <= 0) { cout << "你已无道具" << endl; return ; } cout << "你现在拥有以下道具:" << endl; sleep (1); cout << "如要使用,请输入每行对应的数字, 否则请输入0" << endl; sleep (1); cout << "1:酒" << prop[1] << "瓶" << endl; cout << "2:烟" << prop[2] << "盒" << endl; cout << "3:手铐" << prop[3] << "副" << endl; cout << "4:小刀" << prop[4] << "把" << endl; cout << "5:放大镜" << prop[5] << "个" << endl; int a; cin >> a; while (a > 0 && prop[1] + prop[2] + prop[3] + prop[4] + prop[5] > 0) //道具使用 { if (prop[1] + prop[2] + prop[3] + prop[4] + prop[5] <= 0) { cout << "你已无道具" << endl; break; } if (a == 1) { if (prop[1] <= 0) { cout << "可是你并没有酒" << endl; } else if (black + red <= 1) { cout << "枪中只剩一颗子弹,你退无可退" << endl; } else { prop[1]--; if (gun.front() == 0) { cout << "你退出了一发空弹" << endl; gun.pop(); black--; } else { cout << "你退出了一发实弹" << endl; gun.pop(); red--; } } } if (a == 2) { if (prop[2] <= 0) { cout << "可你没有烟" << endl; sleep (1); } else { prop[2]--; if (num == 3 && you <= 2) { cout << "你试着回复血量,但除颤器已坏,无法挽回" << endl; } else if (you < upper) { you++; cout << "你抽了一根烟,恢复了一点生命值,现在你的生命值:"; cout << you << endl; } else { cout << "你抽了一根烟,可惜你血量已满,并没有什么作用" << endl; } } } if (a == 3) { if (prop[3] <= 0) { cout << "你并没有手铐" << endl; } else if (de == false) { cout << "恶魔从你手中接过手铐,将自己牢牢拷上" << endl; de = true; prop[3]--; } else { cout << "恶魔静静地看着你,你没必要把手铐用两遍" << endl; } } if (a == 4) { if (gunflag == true) { cout << "可枪管已经切了" << endl; sleep (2); } else if (prop[4] <= 0) { cout << "由于没有小刀,你似乎没有办法将枪管徒手掰下来" << endl; sleep (2); } else { cout << "你麻利地拿起自己的小刀,将手中的枪的枪管切下一截" << endl; prop[4]--; gunflag = true; } } if (a == 5) { if (prop[5] <= 0) { cout << "在恶魔嘲讽的目光中,你发现你没有放大镜" << endl; sleep (1); } else { cout << "你将放大镜敲碎,检查了一下枪中的第一发子弹" << endl; sleep (1); if (gun.front() == 1) { cout << "是实弹" << endl; } else { cout << "是空弹" << endl; } prop[5]--; } } cout << "你现在拥有以下道具:" << endl; sleep (1); cout << "如要使用,请输入每行对应的数字, 否则请输入0" << endl; sleep (1); cout << "1:酒" << prop[1] << "瓶" << endl; cout << "2:烟" << prop[2] << "盒" << endl; cout << "3:手铐" << prop[3] << "副" << endl; cout << "4:小刀" << prop[4] << "把" << endl; cout << "5:放大镜" << prop[5] << "个" << endl; cin >> a; } }
void game(int num, int upper) //upper血量上限 { gunflag = false; //枪管暂未被切过 if (yo == false) { if (num != 1) // 道具赛 { cout << "道具赛" << endl; sleep (2); cout << "桌面上,一个小铁盒升起" << endl; sleep (2); int n = 0; if (num == 2) { cout << "“Two items each.”" << endl; sleep (2); random(2); } else { cout << "Four items each." << endl; sleep (2); random(4); } use(num, upper); }
//回合开始 cout << "你可以把子弹射向自己或者恶魔,而你选择:" << endl; //1:玩家打 cout << "1:YOU 2:DEALER" << endl; int a; cin >> a; while (a == 1) //打自己 { cout << "你将枪口朝向自己,扣下了扳机" << endl; sleep (3); if (gun.front() == 1) { cout << "一阵剧痛,你两眼一黑倒地不起" << endl; sleep (2); if (gunflag == true) { you -= 2; gunflag = false; } else { you -= 1; } if (you > 0) { cout << "你睁开眼睛,又站了起来。恶魔用除颤仪将你救醒。" << endl; sleep (2); if (num == 3 && you <= 2) { cout << "嘀嘀嘀..." << endl; sleep (1); cout << "除颤仪在身旁机器的运作中被彻底破坏" << endl; sleep (1); } cout << "你的血量:" << you << endl; cout << "恶魔的血量:" << dealer << endl; sleep (3); if (you == 1 && num != 3) { cout << "“Carefull now...”诡异而空灵的声音" << endl; sleep (3); } } else { return ; } red--; } else { cout << "一阵轻响,你松了口气,是空弹" << endl; sleep (3); black--; gunflag = false; } gun.pop(); if (red == 0 && black == 0) { cout << "弹夹已空,新的回合,旧的关" << endl; sleep (2); return ; } cout << "这一回合你打的是自己,你可以继续你的回合" << endl; if (num > 1) { use(num, upper); } cout << "你可以把子弹射向自己或者恶魔,而你选择:" << endl; cout << "1:YOU 2:DEALER" << endl; cin >> a; } if (a == 2) // 打对面 { cout << "你将枪口对向面前的深渊,毫不犹豫,狠狠扣下了扳机" << endl; sleep (3); if (gun.front() == 1) { cout << "巨大的响声,恶魔应声倒入黑暗之中" << endl; sleep (3); if (gunflag == true) { dealer -= 2; gunflag = false; } else { dealer -= 1; } cout << "你的血量:" << you << endl; cout << "恶魔的血量:" << dealer << endl; sleep (3); if (dealer <= 0) { cout << "鲜血溅出,布满你的脸。但它,尚存" << endl; sleep (2); return ; } else { cout << "你看着黑暗,静静地等待着" << endl; sleep (3); cout << "“......”" << endl; sleep (3); cout << "终于,恶魔张着满是尖牙的嘴,又从黑暗中扑出来" << endl; sleep (2); cout << "你知道它并没有这么容易消亡" << endl; sleep (2); } red--; } else { cout << "随着一声脆响,你的瞳孔微缩" << endl; sleep (2); cout << "是空弹。" << endl; sleep (2); gunflag = false; black--; } gun.pop(); if (red == 0 && black == 0) { cout << "弹夹已空,新的子弹出现" << endl; sleep (2); return ; } } } else { cout << "你想动,但手铐将你牢牢固定" << endl; sleep (2); yo = false; } //2:恶魔打 if (de == true) //恶魔被限制 { cout << "恶魔动了动被铐住的手,示意你继续你的操作" << endl;\ sleep (2); use(num, upper); cout << "你可以把子弹射向自己或者恶魔,而你选择:" << endl; //1:玩家打 cout << "1:YOU 2:DEALER" << endl; de = false; int a; cin >> a; while (a == 1) //打自己 { cout << "你将枪口朝向自己,扣下了扳机" << endl; sleep (3); if (gun.front() == 1) { cout << "一阵剧痛,你两眼一黑倒地不起" << endl; sleep (2); if (gunflag == true) { you -= 2; } else { you -= 1; } if (you > 0) { cout << "你睁开眼睛,又站了起来。恶魔用除颤仪将你救醒。" << endl; sleep (2); if (you == 1 && num != 3) { cout << "“Carefull now...”诡异而空灵的声音" << endl; sleep (3); } } else { return ; } red--; } else { cout << "一阵轻响,你松了口气,是空弹" << endl; sleep (3); black--; } if (red == 0 && black == 0) { cout << "弹夹已空,新的回合,旧的关" << endl; sleep (2); return ; } cout << "这一回合你打的是自己,你可以继续你的回合" << endl; cout << "你可以把子弹射向自己或者恶魔,而你选择:" << endl; cout << "1:YOU 2:DEALER" << endl; cin >> a; gun.pop(); } if (a == 2) // 打对面 { cout << "你将枪口对向面前的深渊,毫不犹豫,狠狠扣下了扳机" << endl; sleep (3); if (gun.front() == 1) { cout << "巨大的响声,恶魔应声倒入黑暗之中" << endl; sleep (3); if (gunflag == true) { dealer -= 2; } else { dealer -= 1; } if (dealer <= 0) { cout << "鲜血溅出,布满你的脸。但它,尚存" << endl; sleep (2); return ; } else { cout << "你看着黑暗,静静地等待着" << endl; sleep (3); cout << "“......”" << endl; sleep (3); cout << "终于,恶魔张着满是尖牙的嘴,又从黑暗中扑出来" << endl; sleep (2); cout << "你知道它并没有这么容易消亡" << endl; sleep (2); } red--; } else { cout << "随着一声脆响,你的瞳孔微缩" << endl; sleep (2); cout << "是空弹。" << endl; sleep (2); black--; } gun.pop(); if (red == 0 && black == 0) { cout << "弹夹已空,新的子弹出现" << endl; sleep (2); return ; } } } system("cls"); cout << "你静静地看着对方,等待着命运的安排" << endl; sleep (2); srand((unsigned int) time(0)); int ti = rand() % (pro[1] + pro[2] + pro[3] + pro[4] + pro[5] + 1);//恶魔使用道具次数 string choose = "?"; //恶魔的选择 string itknows = "?"; //恶魔是否知道下一发子弹 if (num > 1 && ti > 0) // 恶魔使用道具 { for (int i = 1; i <= ti; i++) { int s = rand() % 5 + 1; //使用哪一个道具 if (s == 1 && pro[1] > 0 && black + red > 1) { pro[1]--; cout << "恶魔拿起一瓶酒打开,一饮而尽" << endl; sleep (3); if (gun.front() == 1) { cout << "恶魔退出了一发实弹" << endl; red--; } else { cout << "恶魔退出了一发空弹" << endl; black--; } gun.pop(); sleep (2); } if (s == 2 && pro[2] > 0 || ti > 2 && dealer <= 1 && pro[2] > 0) { pro[2]--; if (num == 3 && dealer <= 2) { cout << "恶魔抽了一根烟,可惜它的血量已无法恢复,身旁的机器闪动,表示着它的除颤器已坏" << endl; sleep (3); continue; //除颤器已坏,无法加血 } cout << "恶魔不慌不忙地拿起一根烟,抽了一口" << endl; sleep (2); cout << "恶魔的血量:" << dealer << endl; sleep (2); } if (s == 3 && pro[3] > 0 && yo == false) { cout << "恶魔伸出它的长手,飞速将手铐铐在你的手上" << endl; pro[3]--; yo = true; sleep (2); } if (s == 4 && pro[4] > 0 && gunflag == false) { cout << "恶魔拿起小刀,狠狠插入,将枪管连带着下面的桌子一起切下来一块儿" << endl; choose = "player"; pro[4]--; gunflag = true; sleep (2); } if (s == 5 && pro[5] > 0 && itknows == "?") { cout << "恶魔拿起一个放大镜,狠狠砸碎,并查看了枪的第一发子弹" << endl; pro[5]--; sleep (5); cout << "“Very interesting...”" << endl; sleep (2); itknows = "!"; if (gun.front() == 1) { choose = "player"; if (pro[4] > 0 && gunflag == false) { cout << "恶魔拿起小刀,狠狠插入,将枪管连带着下面的桌子一起切下来一块儿" << endl; pro[4]--; gunflag = true; sleep (2); ti--; } } else { choose = "itself"; } } } } if (choose == "?") { if (ti % 2 == 1) { choose = "player"; } else { choose = "itself"; } } if (choose == "player" || black == 0) { cout << "恶魔拿起枪,对准了你" << endl; sleep (2); if (gun.front() == 1) { cout << "眼前一黑" << endl; sleep (1); if (gunflag == true) { you -= 2; gunflag = false; } else { you--; } if (you > 0) { cout << "你睁开眼睛,又站了起来。恶魔用除颤仪将你救醒。" << endl; sleep (2); if (num == 3 && you <= 2) { cout << "嘀嘀嘀..." << endl; sleep (1); cout << "除颤仪在身旁机器的运作中被彻底破坏" << endl; sleep (1); } cout << "你的血量:" << you << endl; cout << "恶魔的血量:" << dealer << endl; sleep (3); if (you == 1 && num != 3) { cout << "“Carefull now...”诡异而空灵的声音" << endl; sleep (3); } } else { return ; } red--; } else { black--; cout << "“咔擦...”" << endl; sleep (3); cout << "空弹。" << endl; sleep (2); gunflag = false; } gun.pop(); if (red == 0 && black == 0) { cout << "弹夹已空,新的回合,旧的关" << endl; sleep (2); return ; } } while (choose == "itself") { cout << "恶魔将枪管朝向了他自己" << endl; sleep (3); if (gun.front() == 1) { cout << "巨大的响声,恶魔应声倒入黑暗之中" << endl; sleep (3); if (gunflag == true) { dealer -= 2; gunflag = false; } else { dealer -= 1; } cout << "你的血量:" << you << endl; cout << "恶魔的血量:" << dealer << endl; sleep (3); if (dealer <= 0) { cout << "鲜血溅出,布满你的脸。但它,尚存" << endl; sleep (2); return ; } else { cout << "你看着黑暗,静静地等待着" << endl; sleep (3); cout << "“......”" << endl; sleep (3); cout << "终于,恶魔张着满是尖牙的嘴,又从黑暗中扑出来" << endl; sleep (2); cout << "你知道它并没有这么容易消亡" << endl; sleep (2); } red--; } else { cout << "一声脆响" << endl; sleep (2); cout << "是空弹" << endl; sleep (2); black--; gun.pop(); gunflag = false; } if (red <= 0 && black <= 0) { cout << "弹夹已空,进入新的回合" << endl; sleep (2); break; } ti = rand() % (pro[1] + pro[2] + pro[3] + pro[4] + pro[5] + 1);//恶魔使用道具次数 choose = "?"; //恶魔的选择 itknows = "?"; if (num > 1 && ti > 0) // 恶魔使用道具 { for (int i = 1; i <= ti; i++) { int s = rand() % 5 + 1; //使用哪一个道具 if (s == 1 && pro[1] > 0 && black + red > 1) { pro[1]--; cout << "恶魔拿起一瓶酒打开,一饮而尽" << endl; sleep (3); if (gun.front() == 1) { cout << "恶魔退出了一发实弹" << endl; red--; } else { cout << "恶魔退出了一发空弹" << endl; black--; } gun.pop(); sleep (2); } if (s == 2 && pro[2] > 0 || ti > 2 && dealer <= 1 && pro[2] > 0) { pro[2]--; if (num == 3 && dealer <= 2) { cout << "恶魔抽了一根烟,可惜它的血量已无法恢复,身旁的机器闪动,表示着它的除颤器已坏" << endl; sleep (3); continue; //除颤器已坏,无法加血 } cout << "恶魔不慌不忙地拿起一根烟,抽了一口,恢复了一点血量" << endl; sleep (2); cout << "恶魔的血量:" << dealer << endl; sleep (2); } if (s == 3 && pro[3] > 0 && yo == false) { cout << "恶魔伸出它的长手,飞速将手铐铐在你的手上" << endl; pro[3]--; yo = true; sleep (2); } if (s == 4 && pro[4] > 0 && gunflag == false) { cout << "恶魔拿起小刀,狠狠插入,将枪管连带着下面的桌子一起切下来一块儿" << endl; choose = "player"; pro[4]--; gunflag = true; sleep (2); } if (s == 5 && pro[5] > 0 && itknows == "?") { itknows = "!"; cout << "恶魔拿起一个放大镜,狠狠砸碎,并查看了枪的第一发子弹" << endl; pro[5]--; sleep (5); cout << "“Very interesting...”" << endl; sleep (2); if (gun.front() == 1) { choose = "player"; if (pro[4] > 0 && gunflag == false) { cout << "恶魔拿起小刀,狠狠插入,将枪管连带着下面的桌子一起切下来一块儿" << endl; pro[4]--; gunflag = true; sleep (2); } } else { choose = "itself"; } } } } if (choose == "?") { if (ti % 2 == 1 || black <= 0) { choose = "player"; } else { choose = "itself"; } } }
}
void round(int num) // 主体 { cout << "恶魔把子弹放入枪中,扔到桌上,等待你的操作。" << endl; sleep (2); gunflag = false; de = yo = false; if (num == 1) { dealer = you = 2; int cur = 0; while (dealer > 0 && you > 0) { preparation(1, cur % 3 + 1); cout << red << " LIVE ROUND. " << black << "BLANK." << endl; game(1, 2); cur++; system("cls"); } if (you <= 0) { dead(1); } else { sleep (1); cout << "“Let's make this a little more interesting...”" << endl; sleep (3); round(2); } } if (num == 2) { // 调试 cout << "--------------------------------------------" << endl; dealer = you = 4; int cur = 0; while (dealer > 0 && you > 0) { preparation(2, cur % 3 + 1); cout << red << " LIVE ROUND. " << black << "BLANK." << endl; game(2, 4); cur++; system("cls"); } if (you <= 0) { dead(2); } else { round(3); } } if (num == 3) { cout << "黑暗之中,恶魔的笑容越发诡异" << endl; sleep (1); cout << "一个不知名的机器升上来,一根棍子插进除颤仪电线下" << endl; sleep (2); cout << "可上面随时准备落下的刀是…" << endl; sleep (2); cout << "“Now, me and you, we are dancing on the edge of life and death.”" << endl; sleep (2); cout << "最后一关,当血量只剩2的时候,除颤仪的电线就会被剪断,一枪即死,亦无法回复血量" << endl; sleep (4); dealer = you = 8; int cur = 0; while (dealer > 0 && you > 0) { preparation(3, cur % 3 + 1); cout << red << " LIVE ROUND. " << black << "BLANK." << endl; sleep (2); game(3, 8); cur++; system("cls"); } if (dealer <= 0) { win(); } else { dead(3); } } }
int main() { cout << "没加速器下不了正版,只能自己写一个恶魔轮盘赌了awa" << endl; sleep (3); cout << "别管有些地方的奇怪" << endl; sleep (2); cout << "作者编程不好,这个代码看了几个小时,写了好几天,有些bug没找出来,将就着玩儿吧awa" << endl; sleep (5); system("cls"); cout << "Buckshot Roulette" << endl; cout << "输入1开始游戏,否则退出游戏" << endl; int a; cin >> a; if (a != 1) { cout << "已退出游戏" << endl; sleep (2); system("cls"); return 0; } sleep (1); system("cls"); cout << "场景变换——此刻你正站在厕所中" << endl; sleep (2); cout << "环顾四周,只见厕所的镜子上写着一个大写的——" << endl; sleep (2); cout << "AFRAID?" << endl; sleep (2); cout << "你没有说什么,推开厕所的门走出去。" << endl; sleep (2); system("cls"); cout << "外面响着带劲的音乐,明显下面有不少人在狂欢" << endl; sleep (2); cout << "你处于二楼,只能看见一个男人趴在栏杆上悠闲地抽着烟" << endl; sleep (2); cout << "而你的目标,是面前走廊尽头的那扇门" << endl; sleep (2); cout << "你走过去,一脚把门踹开,走进了房间" << endl; sleep (2); system("cls"); cout << "房间里很暗,四周堆着一些杂物,中间放着一个赌桌" << endl; sleep (2); cout << "身后的门自己猛地关上,紧接着,一直长相丑陋、带着诡异的笑容的恶魔从前面的黑暗中扑到了赌桌前,你的对面" << endl; sleep (2); cout << "诡异的声音响起" << endl; sleep (2); cout << "“Please sign the waiver.”" << endl; sleep (2); cout << "一张生死状递过来,你拿起一个简陋的打字机,写上了自己的名字。" << endl; cin >> playername; while (playername == "god" || playername == "God" || playername == "GOD") { cout << "你想伪装成神,但不知为何它按不下去,你只好输入别的名字" << endl; cin >> playername; } sleep (1); system("cls"); cout << "签好生死状,身旁的机器亮了起来,显示着一个:I,证明着此时是你能否拿到钱的第一关" << endl; sleep (2); round(1); return 0; }
狼人杀:
#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; }
-
通过的题目
题目标签
- 语言基础
- 32
- 循环语句
- 32
- 字符串
- 12
- 字符数组
- 12
- 输入输出
- 8
- 基础语法
- 7
- 其他
- 6
- 位运算
- 3
- 快速幂
- 2
- 递归
- 2
- 数据结构
- 2
- 语言入门
- 2
- 字符串、字符数组
- 2
- 搜索
- 2
- DFS
- 2
- 模拟
- 1
- 递推
- 1
- 分治
- 1
- 计算几何
- 1
- 坐标变换
- 1