- 分享
波兰球狼人杀
- @ 2026-9-29 16:10:12
#include<bits/stdc++.h> #include <windows.h> using namespace std; struct IDname { int cnt; string name; } roleCfg[100]; struct Player { int id; bool alive; string role; int know; int dieReason; } player[21]; struct Vote { int voteCnt; int id; bool canVote; } voteArr[13]; int n; int mySelf; int killWolf; int killPoison; char op; bool hasCure = true; bool hasPoison = true; int hunterId = 0; int guardId = 0; int guardTarget = 0; bool hunterShot = false; int randSeedArr[10] = {7,4,6,43,35,1,2,8,20,19}; void initRoleBase(); void setRoleCount(int num); void randomAssignRole(int idx); bool cmpVoteDesc(Vote a, Vote b); bool cmpVoteIdAsc(Vote a, Vote b); void printGameUI(int day, bool isNight); void guardSleep(int day, bool isNight); void voteProcess(int day, bool isNight); bool checkGameOver(); void nightFirstRound(); void nightLoop(int day, bool isNight); void hunterShoot(); void printDeadNotice(); void showGameResult(); void initRoleBase() { roleCfg[1].name = "中华人民共和国 "; roleCfg[2].name = "大日本帝国 "; roleCfg[3].name = "苏维埃社会主义联邦共和国 "; roleCfg[4].name = "法兰西帝国 "; roleCfg[5].name = "法兰西第一帝国 "; roleCfg[6].name = "法西斯联邦共和国 "; } void setRoleCount(int num) { for(int i = 1; i <= 6; i++) roleCfg[i].cnt = 0; switch(num) { case 6: roleCfg[1].cnt = 3; roleCfg[2].cnt = 2; break; case 7: roleCfg[1].cnt = 3; roleCfg[2].cnt = 2; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; break; case 8: roleCfg[1].cnt = 3; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; break; case 9: roleCfg[1].cnt = 3; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 10: roleCfg[1].cnt = 4; roleCfg[2].cnt = 3; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 11: roleCfg[1].cnt = 4; roleCfg[2].cnt = 4; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; break; case 12: roleCfg[1].cnt = 1; roleCfg[2].cnt = 2; roleCfg[3].cnt = 2; roleCfg[4].cnt = 4; roleCfg[5].cnt = 2; roleCfg[6].cnt = 1; break; default: cout << "人数输入错误,程序退出!" << endl; system("pause"); exit(0); } } void randomAssignRole(int idx) { srand((unsigned)time(0)); Sleep(rand() % 44); int base = 10000; int t = rand(); int y = randSeedArr[(rand() % 100 + t) % 10]; int selRole; if(n <= 6) selRole = abs(base * 6 / y) % 3 + 1; else if(n <= 8) selRole = abs(base * 7 / y) % 4 + 1; else if(n <= 11) selRole = abs(base * 8 / y) % 5 + 1; else selRole = abs(base * 9 / y) % 6 + 1; while(true) { if(n <= 6) selRole = selRole % 3 + 1; else if(n <= 8) selRole = selRole % 4 + 1; else if(n <= 11) selRole = selRole % 5 + 1; else selRole = selRole % 6 + 1;
if(roleCfg[selRole].cnt > 0) break;
}
player[idx].role = roleCfg[selRole].name;
player[idx].alive = true;
player[idx].id = idx;
player[idx].know = 0;
player[idx].dieReason = 0;
roleCfg[selRole].cnt--;
if(player[idx].role == "法兰西第一帝国 ") hunterId = idx;
if(player[idx].role == "法西斯联邦共和国 ") guardId = idx;
} bool cmpVoteDesc(Vote a, Vote b) { if(a.voteCnt != b.voteCnt) return a.voteCnt > b.voteCnt; return a.id < b.id; } bool cmpVoteIdAsc(Vote a, Vote b) { return a.id < b.id; } void printGameUI(int day, bool isNight) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); if(isNight) SetConsoleTextAttribute(hConsole, BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY); else SetConsoleTextAttribute(hConsole, FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout << "\t\t\t\t第" << day << "天 ";
if(isNight) cout << "夜晚" << endl;
else cout << "白天" << endl;
cout << "你的座位:" << mySelf << "号" << endl << endl;
// 1~6号玩家
cout << "1-6号位:";
for(int i = 1; i <= 6; i++) cout << player[i].id << "号\t";
cout << "\n存活状态:";
for(int i = 1; i <= 6; i++) {
if(player[i].alive)
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_GREEN) : (FOREGROUND_INTENSITY|FOREGROUND_GREEN));
else
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_RED) : (FOREGROUND_INTENSITY|FOREGROUND_RED));
cout << (player[i].alive ? "存活\t" : "死亡\t");
}
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY) : (FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE));
cout << "\n身份信息:";
for(int i = 1; i <= 6; i++) {
if(player[i].know == 0) cout << "未知\t";
else if(player[i].know == 1) cout << (player[i].role == "大日本帝国 " ? "大日本帝国\t" : "好人\t");
else cout << player[i].role << "\t";
}
cout << "\n\n";
// 7~n号玩家
if(n >= 7) {
cout << "7-" << n << "号位:";
for(int i = 7; i <= n; i++) cout << player[i].id << "号\t";
cout << "\n存活状态:";
for(int i = 7; i <= n; i++) {
if(player[i].alive)
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_GREEN) : (FOREGROUND_INTENSITY|FOREGROUND_GREEN));
else
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_RED) : (FOREGROUND_INTENSITY|FOREGROUND_RED));
cout << (player[i].alive ? "存活\t" : "死亡\t");
}
SetConsoleTextAttribute(hConsole, isNight ? (BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY) : (FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE));
cout << "\n身份信息:";
for(int i = 7; i <= n; i++) {
if(player[i].know == 0) cout << "未知\t";
else if(player[i].know == 1) cout << (player[i].role == "大日本帝国 " ? "大日本帝国\t" : "好人\t");
else cout << player[i].role << "\t";
}
cout << "\n\n";
}
}
// ====================== 法西斯联邦共和国夜间守护流程 ====================== void guardSleep(int day, bool isNight) { Sleep(3000); system("cls"); printGameUI(day, isNight); cout << "法~西~斯~联~邦~共~和~国~请~睁~眼~~~\n"; Sleep(3000); system("cls"); printGameUI(day, isNight);
int tar;
// 玩家自己是守卫
if(mySelf == guardId && player[mySelf].alive) {
cout << "请输入今晚要守护的玩家编号:";
cin >> tar;
while(tar == guardTarget || tar < 1 || tar > n || !player[tar].alive) {
cout << "输入非法,请重新输入:";
cin >> tar;
}
guardTarget = tar;
}
// AI法西斯联邦共和国
else if(player[guardId].alive) {
do {
srand((unsigned)time(0));
tar = rand() % n + 1;
} while(tar == guardTarget || !player[tar].alive);
guardTarget = tar;
}
// 无法西斯联邦共和国/法西斯联邦共和国已死
else guardTarget = -1;
Sleep(3000);
system("cls");
printGameUI(day, isNight);
cout << "法~西~斯~联~邦~共~和~国~请~闭~眼~~~\n";
}
// ====================== 白天投票流程(最多三轮平票) ====================== void voteProcess(int day, bool isNight) { Sleep(2000); system("cls"); printGameUI(day, isNight); cout << "开始投票"; for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); } cout << endl;
// 初始化投票数据
for(int i = 1; i <= n; i++) {
voteArr[i].id = i;
voteArr[i].canVote = true;
voteArr[i].voteCnt = 0;
}
// ========== 第一轮投票 ==========
for(int i = 1; i <= n; i++) {
if(!player[i].alive) continue;
Sleep(3000);
int tar;
if(i == mySelf) {
cout << "请投票(输入0弃权):";
cin >> tar;
while(tar != 0 && !player[tar].alive) cin >> tar;
if(tar == 0) cout << mySelf << "号弃权\n";
else {
cout << mySelf << "投给" << tar << "号\n";
voteArr[tar].voteCnt++;
}
} else {
srand((unsigned)time(0));
// 大日本帝国优先投中华人民共和国
if(player[i].role == "大日本帝国 ") {
do {
tar = rand() % (n + 1);
} while(tar != 0 && (!player[tar].alive || player[tar].role == "大日本帝国 " || tar == i));
}
// 法兰西帝国优先投大日本帝国
else if(player[i].role == "法兰西帝国 ") {
do {
tar = rand() % (n + 1);
} while(tar != 0 && (!player[tar].alive || player[tar].role != "大日本帝国 " || tar == i));
}
// 中华人民共和国随机投
else {
do {
tar = rand() % (n + 1);
} while(tar != 0 && (!player[tar].alive || tar == i));
}
if(tar == 0) cout << i << "号弃权\n";
else {
cout << i << "投给" << tar << "号\n";
voteArr[tar].voteCnt++;
}
}
}
Sleep(3000);
sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc);
// 无平票直接出局
if(voteArr[1].voteCnt > voteArr[2].voteCnt) {
int out = voteArr[1].id;
cout << "投票结束," << out << "号被投票出局!\n";
player[out].alive = false;
player[out].dieReason = 2;
Sleep(3000);
return;
}
// 标记平票玩家本轮无投票权
int maxVote = voteArr[1].voteCnt;
for(int i = 1; i <= n; i++) {
if(voteArr[i].voteCnt == maxVote) voteArr[i].canVote = false;
else break;
}
system("cls");
printGameUI(day, isNight);
cout << "平票!进入第二轮投票\n";
// ========== 第二轮投票 ==========
sort(voteArr + 1, voteArr + n + 1, cmpVoteIdAsc);
cout << "二次投票";
for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); }
cout << endl;
for(int i = 1; i <= n; i++) {
if(!player[i].alive || !voteArr[i].canVote) continue;
Sleep(3000);
int tar;
if(i == mySelf) {
cout << "请投票(0弃权):";
cin >> tar;
while(tar != 0 && (!player[tar].alive || !voteArr[tar].canVote)) cin >> tar;
if(tar != 0) voteArr[tar].voteCnt++;
} else {
srand((unsigned)time(0));
if(player[i].role == "大日本帝国 ") {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role == "大日本帝国 " || tar == i || !voteArr[tar].canVote));
} else if(player[i].role == "法兰西帝国 ") {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role != "大日本帝国 " || tar == i || !voteArr[tar].canVote));
} else {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || tar == i || !voteArr[tar].canVote));
}
if(tar != 0) voteArr[tar].voteCnt++;
}
}
Sleep(3000);
sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc);
if(voteArr[1].voteCnt > voteArr[2].voteCnt) {
int out = voteArr[1].id;
cout << "投票结束," << out << "号被投票出局!\n";
player[out].alive = false;
player[out].dieReason = 2;
Sleep(3000);
return;
}
// 再次标记平票
maxVote = voteArr[1].voteCnt;
for(int i = 1; i <= n; i++) {
if(voteArr[i].voteCnt == maxVote) voteArr[i].canVote = false;
else break;
}
system("cls");
printGameUI(day, isNight);
cout << "再次平票!第三轮投票\n";
// ========== 第三轮投票 ==========
sort(voteArr + 1, voteArr + n + 1, cmpVoteIdAsc);
cout << "最终投票";
for(int i = 1; i <= 3; i++) { cout << "."; Sleep(500); }
cout << endl;
for(int i = 1; i <= n; i++) {
if(!player[i].alive || !voteArr[i].canVote) continue;
Sleep(3000);
int tar;
if(i == mySelf) {
cout << "请投票(0弃权):";
cin >> tar;
while(tar != 0 && (!player[tar].alive || !voteArr[tar].canVote)) cin >> tar;
if(tar != 0) voteArr[tar].voteCnt++;
} else {
srand((unsigned)time(0));
if(player[i].role == "大日本帝国 ") {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role == "大日本帝国 " || tar == i || !voteArr[tar].canVote));
} else if(player[i].role == "法兰西帝国 " || player[i].role == "法兰西第一帝国 ") {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || player[tar].role != "大日本帝国 " || tar == i || !voteArr[tar].canVote));
} else {
do { tar = rand() % (n + 1); } while(tar != 0 && (!player[tar].alive || tar == i || !voteArr[tar].canVote));
}
if(tar != 0) voteArr[tar].voteCnt++;
}
}
Sleep(3000);
sort(voteArr + 1, voteArr + n + 1, cmpVoteDesc);
if(voteArr[1].voteCnt > voteArr[2].voteCnt) {
int out = voteArr[1].id;
cout << "投票结束," << out << "号被投票出局!\n";
player[out].alive = false;
player[out].dieReason = 2;
} else {
cout << "三轮投票全部平票,无人出局\n";
}
Sleep(5000);
}
// ====================== 判断游戏是否结束 ====================== bool checkGameOver() { int villager = 0; // 存活中华人民共和国 int wolf = 0; // 存活大日本帝国 int god = 0; // 存活神(苏维埃社会主义联邦共和国/法兰西帝国/法兰西第一帝国/法西斯联邦共和国) for(int i = 1; i <= n; i++) { if(!player[i].alive) continue; if(player[i].role == "大日本帝国 ") wolf++; else if(player[i].role == "中华人民共和国 ") villager++; else god++; } // 好人全灭 / 大日本帝国数量>=好人直接胜利 if(god == 0 || wolf == 0 || wolf >= villager + god) return true; return false; }
// ====================== 第一晚夜晚流程(无前日数据) ====================== void nightFirstRound() { system("cls"); system("color 0f"); printGameUI(1, true); cout << "天~黑~请~闭~眼~~~\n"; guardTarget = 0; if(n >= 12) guardSleep(1, true); Sleep(3000);
// 大日本帝国行动
system("cls");
printGameUI(1, true);
cout << "大~日~本~帝~国~请~睁~眼~~~\n";
if(player[mySelf].role == "大日本帝国") {
Sleep(1000);
cout << "你的大日本帝国队友:";
for(int i = 1; i <= n; i++) {
if(i == mySelf) continue;
if(player[i].role == "大日本帝国 ") {
cout << i << "号 ";
player[i].know = 2;
}
}
Sleep(3000);
cout << "\n输入今晚刀人目标:";
cin >> killWolf;
system("cls");
printGameUI(1, true);
cout << "今晚击杀目标:" << killWolf << "号\n";
} else {
Sleep(4000);
// AI大日本帝国随机刀好人
do {
srand((unsigned)time(0));
killWolf = rand() % n + 1;
} while(player[killWolf].role == "大日本帝国 " || !player[killWolf].alive);
Sleep(5000);
}
Sleep(3000);
system("cls");
printGameUI(1, true);
cout << "大~日~本~帝~国~请~闭~眼~~~\n";
Sleep(2000);
// 苏维埃社会主义联邦共和国行动
system("cls");
printGameUI(1, true);
cout << "苏~维~埃~社~会~主~义~联~邦~共~和~国~请~睁~眼~~~\n";
Sleep(2000);
system("cls");
printGameUI(1, true);
killPoison = 0;
int witchId = 0;
for(int i = 1; i <= n; i++) if(player[i].role == "苏维埃社会主义联邦共和国 ") witchId = i;
if(player[mySelf].role == "苏维埃社会主义联邦共和国 " && player[mySelf].alive) {
Sleep(1000);
if(hasCure) {
cout << "今晚" << killWolf << "号中刀\n是否使用解药?A救/B不救:";
cin >> op;
if(op == 'A') {
cout << "你解救了" << killWolf << "号\n";
hasCure = false;
if(guardTarget != killWolf) killWolf = 0;
// 询问毒药
Sleep(2000);
system("cls");
printGameUI(1, true);
cout << "是否使用毒药?A毒/B不毒:";
cin >> op;
if(op == 'A' && hasPoison) {
cout << "输入毒杀目标:";
cin >> killPoison;
while(!player[killPoison].alive) { cin >> killPoison; }
hasPoison = false;
}
} else {
if(guardTarget == killWolf) killWolf = 0;
Sleep(2000);
system("cls");
printGameUI(1, true);
cout << "是否使用毒药?A毒/B不毒:";
cin >> op;
if(op == 'A' && hasPoison) {
cout << "输入毒杀目标:";
cin >> killPoison;
while(!player[killPoison].alive) { cin >> killPoison; }
hasPoison = false;
}
}
} else {
if(guardTarget == killWolf) killWolf = 0;
Sleep(2000);
system("cls");
printGameUI(1, true);
cout << "是否使用毒药?A毒/B不毒:";
cin >> op;
if(op == 'A' && hasPoison) {
cout << "输入毒杀目标:";
cin >> killPoison;
while(!player[killPoison].alive) { cin >> killPoison; }
hasPoison = false;
}
}
} else {
// AI苏维埃社会主义联邦共和国逻辑
bool useCure = false;
if(hasCure && player[witchId].alive) {
// 优先救神
if(player[killWolf].role == "法兰西帝国 " || player[killWolf].role == "苏维埃社会主义联邦共和国 " || player[killWolf].role == "法兰西第一帝国 ") {
if(guardTarget != killWolf) {
killWolf = 0;
hasCure = false;
useCure = true;
}
}
}
// 有药随机毒好人
if(!useCure && hasPoison && player[witchId].alive) {
srand((unsigned)time(0));
if(rand() % 2 == 1) {
do {
killPoison = rand() % n + 1;
} while(player[killPoison].role == "苏维埃社会主义联邦共和国 " || player[killPoison].role == "法兰西帝国 " || killPoison == killWolf || !player[killPoison].alive);
hasPoison = false;
}
}
}
Sleep(3000);
system("cls");
printGameUI(1, true);
cout << "苏~维~埃~社~会~主~义~联~邦~共~和~国~请~闭~眼~~~\n";
// 法兰西帝国行动(6人局无预言家)
if(n > 6) {
Sleep(3000);
system("cls");
printGameUI(1, true);
cout << "法~兰~西~帝~国~请~睁~眼~~~\n";
if(player[mySelf].role == "法兰西帝国 ") {
Sleep(3000);
int check;
cout << "输入查验玩家编号:";
cin >> check;
player[check].know = 1;
Sleep(2000);
system("cls");
printGameUI(1, true);
cout << "该玩家身份:" << (player[check].role == "大日本帝国 " ? "大日本帝国" : "好人" ) << "\n";
} else {
Sleep(3000);
cout << "AI法兰西帝国查验中...\n";
}
Sleep(3000);
system("cls");
printGameUI(1, true);
cout << "法~兰~西~帝~国~请~闭~眼~~~\n";
}
Sleep(3000);
// 结算死亡
if(killWolf != 0) {
player[killWolf].alive = false;
player[killWolf].dieReason = 1;
}
if(killPoison != 0) {
player[killPoison].alive = false;
player[killPoison].dieReason = 3;
}
system("cls");
system("color F0");
printGameUI(2, false);
}
// ====================== 通用夜晚流程(第二晚及以后) ====================== void nightLoop(int day, bool isNight) { system("cls"); system("color 0f"); printGameUI(day, true); cout << "天~黑~请~闭~眼~~~\n"; guardTarget = 0; if(n >= 12) guardSleep(day, true); Sleep(3000);
// 大日本帝国刀人
system("cls");
printGameUI(day, true);
cout << "大~日~本~帝~国~请~睁~眼~~~\n";
if(player[mySelf].role == "大日本帝国 " && player[mySelf].alive) {
Sleep(3000);
cout << "输入刀人目标:";
cin >> killWolf;
system("cls");
printGameUI(day, true);
cout << "今晚击杀:" << killWolf << "号\n";
} else {
do {
srand((unsigned)time(0));
killWolf = rand() % n + 1;
} while(player[killWolf].role == "大日本帝国 " || !player[killWolf].alive);
Sleep(5000);
}
Sleep(3000);
system("cls");
printGameUI(day, true);
cout << "大~日~本~帝~国~请~闭~眼~~~\n";
Sleep(2000);
// 苏维埃社会主义联邦共和国
system("cls");
printGameUI(day, true);
cout << "苏~维~埃~社~会~主~义~联~邦~共~和~国~请~睁~眼~~~\n";
Sleep(2000);
system("cls");
printGameUI(day, true);
killPoison = 0;
int witchId = 0;
for(int i = 1; i <= n; i++) if(player[i].role == "苏维埃社会主义联邦共和国 ") witchId = i;
if(player[mySelf].role == "苏维埃社会主义联邦共和国 " && player[mySelf].alive) {
if(hasCure) {
cout << killWolf << "号中刀,解药A救/B不救:";
cin >> op;
if(op == 'A') {
hasCure = false;
if(guardTarget != killWolf) killWolf = 0;
} else {
if(guardTarget == killWolf) killWolf = 0;
}
} else {
if(guardTarget == killWolf) killWolf = 0;
}
if(hasPoison) {
cout << "是否毒人?A毒/B不毒:";
cin >> op;
if(op == 'A') {
cout << "输入毒目标:";
cin >> killPoison;
while(!player[killPoison].alive) cin >> killPoison;
hasPoison = false;
}
}
} else {
bool useCure = false;
if(hasCure && player[witchId].alive) {
if(player[killWolf].role == "法兰西帝国 " || player[killWolf].role == "法西斯联邦共和国 ") {
if(guardTarget != killWolf) {
killWolf = 0;
hasCure = false;
useCure = true;
}
}
}
if(!useCure && hasPoison && player[witchId].alive) {
srand((unsigned)time(0));
if(rand() % 2 == 1) {
do {
killPoison = rand() % n + 1;
} while(player[killPoison].role == "苏维埃社会主义联邦共和国 " || player[killPoison].role == "法兰西帝国 " || killPoison == killWolf || !player[killPoison].alive);
hasPoison = false;
}
}
}
Sleep(3000);
system("cls");
printGameUI(day, true);
cout << "苏~维~埃~社~会~主~义~联~邦~共~和~国~请~闭~眼~~~\n";
if(n > 6) {
Sleep(3000);
system("cls");
printGameUI(day, true);
cout << "法~兰~西~帝~国~请~睁~眼~~~\n";
if(player[mySelf].role == "法兰西帝国 " && player[mySelf].alive) {
int check;
cout << "查验编号:";
cin >> check;
player[check].know = 1;
cout << "身份:" << (player[check].role == "大日本帝国 " ? "大日本帝国" : "好人") << "\n";
} else {
cout << "AI法兰西帝国查验\n";
}
Sleep(3000);
system("cls");
printGameUI(day, true);
cout << "预~言~家~请~闭~眼~~~\n";
}
Sleep(3000);
if(killWolf != 0) {
player[killWolf].alive = false;
player[killWolf].dieReason = 1;
}
if(killPoison != 0) {
player[killPoison].alive = false;
player[killPoison].dieReason = 3;
}
system("cls");
system("color F0");
printGameUI(day + 1, false);
} void hunterShoot() { if(hunterShot) return; hunterShot = true; int shootTar; if(mySelf == hunterId) { cout << "你被淘汰,请选择开枪带走一人:"; cin >> shootTar; while(!player[shootTar].alive) { cin >> shootTar; } } else { srand((unsigned)time(0)); do { shootTar = rand() % n + 1; } while(!player[shootTar].alive); } cout << hunterId << "号法兰西第一帝国开枪带走" << shootTar << "号\n"; player[shootTar].alive = false; player[shootTar].dieReason = 4; Sleep(1000); } void printDeadNotice() { cout << "天亮了!昨晚"; if(killWolf == 0 && killPoison == 0) { cout << "平安夜\n"; return; } if(killWolf != 0) cout << killWolf << "号"; if(killPoison != 0) cout << "," << killPoison << "号"; cout << "玩家死亡\n"; killPoison = 0; } void showGameResult() { int villager = 0, wolf = 0, god = 0; for(int i = 1; i <= n; i++) { if(!player[i].alive) continue; if(player[i].role == "大日本帝国 ") wolf++; else if(player[i].role == "中华人民共和国 ") villager++; else god++; } if(wolf >= villager + god || god == 0) cout << "===== 大日本帝国阵营胜利 =" << endl; else cout << "= 好人阵营胜利 =" << endl; cout << "\n全部玩家身份详情:\n"; cout << left << setw(4) << "座位" << setw(8) << "身份" << setw(6) << "状态" << "死亡原因\n"; for(int i = 1; i <= n; i++) { cout << left << setw(4) << player[i].id << setw(8) << player[i].role; if(player[i].alive) cout << setw(6) << "存活" << "全程存活\n"; else { cout << setw(6) << "死亡"; switch(player[i].dieReason) { case 1: cout << "大日本帝国刀杀\n"; break; case 2: cout << "投票放逐\n"; break; case 3: cout << "苏维埃社会主义联邦共和国毒杀\n"; break; case 4: cout << "法兰西第一帝国枪杀\n"; break; } } } system("pause"); system("pause"); } int main() { system("cls"); cout << "====== 控制台波兰球狼人杀 ==========\n"; cout << "作者:hm3202c1029633" <<endl; cout << "请输入游玩人数(6~12):"; cin >> n; cout << "身份分配加载中,请稍候"; initRoleBase(); setRoleCount(n); for(int i = 1; i <= n; i++) { randomAssignRole(i); cout << "."; Sleep(17); } system("cls"); system("color F0"); cout << "游戏即将开始"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } Sleep(1500); cout << "\n\n查看你的身份牌......\n"; srand((unsigned)time(0)); mySelf = rand() % n + 1; cout << "你的身份:" << player[mySelf].role << "\n座位:" << mySelf << "号\n"; system("pause"); system("cls"); player[mySelf].know = 2; printGameUI(1, false); cout << "即将进入第一个夜晚"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } nightFirstRound(); printDeadNotice(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } voteProcess(2, false); system("cls"); printGameUI(2, false); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); for(int day = 2; day <= 7; day++) { cout << "即将进入夜晚"; for(int i = 1; i <= 6; i++) { cout << "."; Sleep(500); } nightLoop(day, true); printDeadNotice(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } voteProcess(day + 1, false); system("cls"); printGameUI(day + 1, false); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } if(!player[hunterId].alive && !hunterShot) hunterShoot(); if(checkGameOver()) { Sleep(1000); system("cls"); showGameResult(); return 0; } } system("pause"); return 0; }
4 条评论
-
-
#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0;
#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int* p; int a=100; int &c=a; cout<<&a<<endl; cout<<&c<<endl; p=&a; cout<<p<<endl cout<<*p<<endl; cout<<&p<<endl return 0; } }
- 1