3
已解决
熊潇然
初级启示者
初级启示者
熊潇然在2022-10-30 08:48:49追加了内容
建议建议建议!!!
有什么BUG,或者给狼人杀一点建议!
熊潇然在2022-10-30 09:10:38追加了内容
emmm......
这个链接:狼人杀 1.5版本
熊潇然在2022-10-30 09:13:47追加了内容
这个链接是 狼人杀1.0 版本:狼人杀 1.0版本
熊潇然在2022-10-31 13:57:04追加了内容
我ding
熊潇然在2022-11-01 09:53:54追加了内容
有没有什么意见,或者BUG,发给我
熊潇然在2022-11-01 14:08:38追加了内容
顶顶顶顶顶
熊潇然在2022-11-02 14:09:23追加了内容
当狼人杀 1.7版本制作完成时,本帖结
熊潇然在2022-11-03 09:28:14追加了内容
ddd
熊潇然在2022-11-05 16:57:21追加了内容
本人学业繁忙
狼人杀 1.7版本 可能在11月中旬或者下旬出,也可能在12月出
熊潇然在2022-11-12 14:09:49追加了内容
d
熊潇然在2022-11-13 09:53:12追加了内容
继续d
熊潇然在2022-12-08 12:39:58追加了内容
名字改一下
0
0
0
0
郝天尘
资深光能
资深光能
#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], shouwei[5]; //猎人4个 女巫4个 预言家3个 狼人4个 守卫5个
int a[35];//0 平民 1 狼人 2 猎人 3 女巫 4 预言家 5 守卫
int shengming[35];//30个人的生命值
string js;
int nn = 1;
int vote[35];//30个人投票票数
bool fvote[35];//30个人是否已经投票
void color(int corcorcor) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), corcorcor);
}
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() { //分配角色
Sleep(rand() % 5000 + 1500);
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);
while (!(shouwei[0] && shouwei[1] && shouwei[2] && shouwei[3] && shouwei[4])) { //守卫 分配
int n = rand() % 30 + 1;
if (!shouwei[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] && n != yuyanjia[0] && n != yuyanjia[1] && n != yuyanjia[2]) {
a[n] = 5;
shouwei[0] = n;
} else if (!shouwei[1] && n != shouwei[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] && n != yuyanjia[0] && n != yuyanjia[1] && n != yuyanjia[2]) {
a[n] = 5;
shouwei[1] = n;
} else if (!shouwei[2] && n != shouwei[1] && n != shouwei[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] && n != yuyanjia[0] && n != yuyanjia[1] && n != yuyanjia[2]) {
a[n] = 5;
shouwei[2] = n;
} else if (!shouwei[3] && n != shouwei[2] && n != shouwei[1] && n != shouwei[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] && n != yuyanjia[0] && n != yuyanjia[1] && n != yuyanjia[2]) {
a[n] = 5;
shouwei[3] = n;
} else if (!shouwei[4] && n != shouwei[3] && n != shouwei[2] && n != shouwei[1] && n != shouwei[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] && n != yuyanjia[0] && n != yuyanjia[1] && n != yuyanjia[2]) {
a[n] = 5;
shouwei[4] = 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 if (a[nn] == 4) {
tmp = "预言家";
} else if (a[nn] == 5) {
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() {
memset(a, 0, sizeof(a));
memset(lieren, 0, sizeof(lieren));
memset(nvwu, 0, sizeof(nvwu));
memset(yuyanjia, 0, sizeof(yuyanjia));
memset(langren, 0, sizeof(langren));
memset(shouwei, 0, sizeof(shouwei));
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 = "";
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 if (a[nn] == 4) {
line("预言家!");
} else {
line("守卫!");
}
f = 1;
Sleep(2000);
string h = "";
while (!check()) {
cls();
cover_langrensha();
memset(vote, 0, sizeof(vote));
memset(fvote, 0, sizeof(fvote));
system("color 04");
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 if (a[n] == 4) {
line("悄悄告诉你,TA是预言家");
} else if (a[n] == 5) {
line("悄悄告诉你,TA是守卫");
}
cout << endl;
} else {
line("你要守护谁?");
cin >> n;
o1 = n / 10 + '0';
o2 = n % 10 + '0';
h = "";
h += o1;
h += o2;
line("你守护了 " + h + " 号");
shengming[n]++;
}
Sleep(3000);
cls();
cover_langrensha();
} else if (shengming[i]) {
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;
}
} else if (a[i] == 5) {
n = rand() % 30 + 1;
o1 = n / 10 + '0';
o2 = n % 10 + '0';
h = "";
h += o1;
h += o2;
line("守卫守护了 " + h + " 号");
shengming[n]++;
}
if (a[i] > 0) {
Sleep(3000);
cls();
cover_langrensha();
}
}
}
cls();
color(240);
cls();
cover_langrensha();
Sleep(3000);
line("天亮了");
Sleep(3000);
cout << endl;
if (check_jieshu() == 1) {
line("狼人胜利!");
Sleep(3000);
break;
} else if (check_jieshu() == 2) {
line("好人胜利!");
Sleep(3000);
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 + " 号被投了出去");
cout << endl;
shengming[pos] = 0;
Sleep(3000);
if (check_jieshu() == 1) {
line("狼人胜利!");
break;
} else if (check_jieshu() == 2) {
line("好人胜利!");
break;
}
}
Sleep(3000);
cls();
}
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("6. 守卫");
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 if (a == '6') {
line("可以守护一个人,使他增加 1 点血");
} 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("------------------------------------------------------------------------------------------------------------------------");
cout << endl;
Sleep(1000);
while (1) {
char a;
cls();
cover_langrensha();
line("1. 开始游戏(共30人)");
Sleep(1000);
cout << endl;
line("2. 游戏规则");
Sleep(1000);
cout << endl;
line("3. 关于作者");
a = getch();
cls();
if (a == '1') {
break;
}
cover_langrensha();
if (a == '2') {
youxiguize();
} else if (a == '3') {
guanyuzuozhe();
}
}
while (1) {
f = 0;
cls();
cover_langrensha();
kaishiyouxi();
memset(shengming, 0, sizeof(shengming));
for (int i = 1; i <= 30; i++) {
shengming[i] = 1;
}
while (1) {
cls();
cover_langrensha();
line("1. 查看所有人的身份");
Sleep(1000);
cout << endl;
line("2. 再来一局");
Sleep(1000);
cout << endl;
line("3. 结束游戏");
char b;
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 if (a[i] == 4) {
j += ":预言家";
} else {
j += ":守卫";
}
line(j);
}
cout << endl;
line("请点击任意继续......");
b = getch();
} else if (b == '3') {
line("欢迎下次再玩!");
return ;
} else {
break;
}
}
}
}
int main() {
langrensha_MAIN(); //狼人杀 主函数
return 0;
}
0
0
汪声旭
高级守护
高级守护
0
0
蒋宇韩
中级守护
中级守护
意见:
1.我匹配到了女巫,全程没动,被sha了,也没到我
2.投票是否会投到**的人上
3.女巫是否会救活人
4.能sha人的单位是否会sha**人
5.匹配机制是否能优化
6.你可以考虑在原版狼人杀的基**上增加一些元素是游戏更加有趣
0
0
0
0
0
0
0
0