#include <iostream>
#include <list>
#include <cstdio>
#include <string>
#include <vector>
#include <ctime>
#include <algorithm>
#include <conio.h>
#include <windows.h>
using namespace std;
class Node {
public:
int x, y;
Node(int x1, int y1);
};
class UserData {
public:
string name;
long long score;
int gt;
int gr;
UserData(string s, long long sc,int gametime,int grade);
friend bool operator < (UserData a, UserData b);
};
#define RIGHT 0x4d
#define LEFT 0x4b
#define UP 0x48
#define DOWN 0x50
#define YELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define CYAN FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define ORANGE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define PURPLE FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define RED FOREGROUND_RED | FOREGROUND_INTENSITY
const int STARTX = 8;
const int STARTY = 4;
const int RANGEX = 60;
const int RANGEY = 20;
int point=10;
const int ENDX = STARTX + RANGEX;
const int ENDY = STARTY + RANGEY;
bool isSnake[RANGEY + 10 ][RANGEX + 10];
int speed;
int sysj;
int gametime;
list<Node> snake;
int curDiraction; //蛇的当前前进方向, 1上, 2下, 3左, 4右
int score; //当前分数
int grade;
int snakeLen; //蛇的长度
int foodx, foody; //食物坐标
int gox, goy; //蛇头坐标
int mj;
void GoTo(short x, short y); //定位光标
void DrawBoard(); //绘制边框
void ShowInformation(); //展示游戏信息
void Init(); //初始化游戏
void RunSnake(int x, int y); //绘制蛇身
void Try(int& x, int& y); //试走
bool IsGoodCoord(int x, int y); //前进坐标是否合法
void AddFood();
void EartFood();
void InitSnake();
bool EndGame();
bool StartGame();
bool GameMenu(); //游戏菜单
void ShowRanking(); //排行榜
void ShowAbout(); //相关信息
void InputData(); //输入玩家名字
int main() {
system("title 贪吃蛇小游戏 by 徐翌宸");
while (true) {
if (!GameMenu()) return 0;
}
return 0;
}
Node::Node(int x1, int y1) { //构造Node对象
x = x1; y = y1;
}
int SuiJi()
{
srand((unsigned)time(NULL));
return (rand()*rand()+rand()*rand())%14;
}
bool operator < (UserData a, UserData b) { //重载运算符,按分数由大到小排列
if(a.score != b.score)
return a.score > b.score;
if(a.gt !=b.gt)
return a.gt > b.gt;
else
return a.gr > b.gr;
}
UserData::UserData(string s, long long sc,int gametime_,int _grade) { //构造UserData对象
name = s; score = sc; gt=gametime_; gr=_grade;
}
void color(WORD A)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), A);
}
void Color(int a)
{
switch (a%4)
{
case 0:color(RED);break;
case 1:color(CYAN);break;
case 2:color(YELLOW);break;
case 3:color(PURPLE);break;
}
}
void GoTo(short x, short y) { //定位光标
COORD coord = { x, y };
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void ShowInformation() { //输出游戏信息
color(YELLOW);
GoTo(78, 5);
printf("贪吃蛇游戏");
GoTo(78,18);
gametime=(clock()-mj)/1000;
grade=snakeLen-3;
printf("生存时间:%3d 秒",(clock()-mj)/1000);
GoTo(78, 8);
printf("游戏规则:");
GoTo(78, 10);
printf("请按 ↑ ↓ ← → 来控制您的蛇吃东西");
GoTo(78, 12);
printf("吃的越多,蛇就越长,您的等级也将越高");
GoTo(78, 14);
printf("当蛇吃到自己或撞上墙时,游戏结束。");
GoTo(78,16);
printf("自动前进时间:%3dms",speed);
GoTo(78, 20);
printf("当前等级: %8d", snakeLen-3);
GoTo(78, 23);
printf("您的分数: %d", score);
color(CYAN);
printf("+%d=%d",score/3,score*3/2);
color(YELLOW);
GoTo(78,25);
printf("剩余时间:%d秒",20+(snakeLen-3)*5-gametime);
sysj=20+(snakeLen-3)*5-gametime;
}
void DrawBoard() { //绘制墙体
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); //获得输出句柄
CONSOLE_CURSOR_INFO cursor_info = { 1, 0 }; //光标信息
SetConsoleCursorInfo(hOut, &cursor_info); //隐藏光标
COORD size = { 120, 30 };
SetConsoleScreenBufferSize(hOut, size); //重设缓冲区大小
SMALL_RECT rc = { 0 , 0, 120, 30 };
SetConsoleWindowInfo(hOut, true, &rc); //重设窗口大小
SetConsoleTextAttribute(hOut, CYAN);
for (int i = STARTX - 2; i <= ENDX + 2; i += 2) { //横向墙体
GoTo(i, STARTY - 1);
printf("■");
GoTo(i, ENDY + 1);
printf("■");
}
for (int i = STARTY - 1; i <= ENDY + 1; ++i) { //竖向墙体
GoTo(STARTX - 2, i);
printf("■");
GoTo(ENDX + 2, i);
printf("■");
}
}
void draw()
{
char m=snakeLen+62;
Color(score);
cout<<m;
}
void Init() { //初始化游戏
system("cls");
memset(isSnake, 0, sizeof(isSnake));
speed = 200;
curDiraction = 4;
score = 0;
DrawBoard();
InitSnake();
ShowInformation();
AddFood();
mj=clock();
point=20;
sysj=20;
}
void RunSnake(int x, int y) { //绘制蛇身
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
score += snakeLen + 1;
if (x == foodx && y == foody) {
EartFood();
AddFood();
return;
}
DrawBoard();
snake.push_front(Node(x, y));
isSnake[y][x] = true;
GoTo(x, y);
draw();
Node back = snake.back();
snake.pop_back();
isSnake[back.y][back.x] = false;
GoTo(back.x, back.y);
printf(" ");
}
void Try(int& x, int& y) { //试走
int key, cnt = 100;
while (cnt--) { //多次检测键盘状态
if (_kbhit()) {
key = getch();
switch (key) {
case UP:
// if (curDiraction == 1 || curDiraction == 2) break;
--y; curDiraction = 1; return;
case DOWN:
// if (curDiraction == 1 || curDiraction == 2) break;
++y; curDiraction = 2; return;
case LEFT:
// if (curDiraction == 3 || curDiraction == 4) break;
x -= 2; curDiraction = 3; return;
case RIGHT:
// if (curDiraction == 3 || curDiraction == 4) break;
x += 2; curDiraction = 4; return;
}
}
}
if (curDiraction == 1) --y; //用户没有输入时
else if (curDiraction == 2) ++y;
else if (curDiraction == 3) x -= 2;
else x += 2;
}
bool IsGoodCoord(int x, int y) { //判断光标是否合法
if (x <= ENDX && y <= ENDY && x >= STARTX && y >= STARTY)
return true;
else
return false;
}
void AddFood() { //增加食物
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), PURPLE);
srand((unsigned)time(NULL));
while (true) {
foodx = (rand()%ENDX) + 1;
foody = (rand()%ENDY) + 1;
if (foodx&1) foodx++;
if (!isSnake[foody][foodx] && IsGoodCoord(foodx, foody)) break;
}
GoTo(foodx, foody);
int a=rand()%5;
if(a>=4)
printf("★");
else if(a<=1)
printf("○");
else
printf("▲");
}
void EartFood() { //吃东西
point+=4;
int sb=gametime=(clock()-mj)/1000;
sysj=point-sb;
score+=score/2;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
snake.push_front(Node(foodx, foody));
isSnake[foody][foodx] = true;
++snakeLen;
if (speed >= 55) speed -= 5;
GoTo(foodx, foody);
draw();
AddFood();
}
void InitSnake() { //初始化蛇身
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
snakeLen = 3, gox = 18, goy = 14;
snake.clear();
snake.push_front(Node(12, 14));
snake.push_front(Node(14, 14));
snake.push_front(Node(16, 14));
for (int i = 12; i <= 16; i += 2) {
GoTo(i, 14);
draw();
isSnake[14][i] = true;
}
}
bool EndGame() { //结束游戏
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
GoTo(28, 10);
printf("您的本局游戏得分: %d分", score);
GoTo(32, 18);
printf("....你挂了....");
GoTo(27, 20);
printf("是否继续游戏: 是(1), 否(0)");
GoTo(27, 22);
char key = getch();
while (true) {
if (key == '1') return false;
else if (key == '0')
{GoTo(ENDX+1,ENDY+2);
exit(0);return true;
}
else key = getch();
}
}
bool StartGame() { //启动游戏
Init();
while (sysj>0) { //开挂
RunSnake(gox, goy);
ShowInformation();
Try(gox, goy);
Sleep(speed);
}
InputData();
return true;
}
bool GameMenu() { //游戏菜单
system("cls");
DrawBoard();
GoTo(STARTX + 22, STARTY + 4);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
printf("欢迎进入贪吃蛇游戏!");
GoTo(STARTX + 24, STARTY + 10);
printf("1: 新游戏");
GoTo(STARTX + 24, STARTY + 12);
printf("2: 排行榜");
GoTo(STARTX + 24, STARTY + 14);
printf("3: 关于游戏");
GoTo(STARTX + 24, STARTY + 16);
printf("4: 退出游戏");
while (true) {
if (_kbhit()) {
char key = getch();
switch (key) {
case '1':
if (!StartGame()) return false;
else return true;
case '2':
ShowRanking(); return true;
case '3':
ShowAbout(); return true;
case '4':
GoTo(1,ENDY+2);
return false;
default:
return true;
}
}
}
}
void ShowRanking() { //展示排行榜
vector<UserData> vu;
FILE *fp = fopen("Gamedata2.txt", "r");
if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
char name[20];
int len = 0;
while (fscanf(fp, "%s", name) != EOF) {
++len;
int score,g=grade;
fscanf(fp, "%d%d%d%*c", &score,&gametime,&g);
vu.push_back(UserData(string(name), score,gametime,g));
}
fclose(fp);
sort(vu.begin(), vu.end()); //对得分进行排名
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), CYAN);
GoTo(STARTX + 8, STARTY + 2);
printf("用户");
GoTo(STARTX + 20, STARTY + 2);
printf("分数");
GoTo(STARTX + 32, STARTY + 2);
printf("生存时间");
GoTo(STARTX + 44, STARTY + 2);
printf("排行");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
for (int i = 0; i < len && i < 10; ++i) { //打印前十名用户数据
char const *p = vu[i].name.c_str();
Color(score);
GoTo(STARTX + 8, STARTY + 4 + i);
printf("%s", p);
GoTo(STARTX + 20, STARTY + 4 + i);
printf("%d分", vu[i].score);
GoTo(STARTX + 32, STARTY + 4 + i);
printf("%d秒", vu[i].gt);
GoTo(STARTX + 44, STARTY + 4 + i);
printf(" %d", i + 1);
}
GoTo(STARTX + 4, ENDY - 2);
printf("----------------- 按'1'返回游戏菜单 ---------------");
while (true) {
if (_kbhit()) {
char key = getch();
if (key == '1') break;
}
}
}
void ShowAbout() { //展示游戏相关
system("cls");
DrawBoard();
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), YELLOW);
GoTo(STARTX + 4, STARTY + 2);
printf("------------------- 贪吃蛇游戏 -------------------");
GoTo(STARTX + 10, STARTY + 4);
printf("制作人: ");
GoTo(STARTX + 10, STARTY + 6);
printf("宋彦樱");
GoTo(STARTX + 10,STARTY + 8);
printf("贪吃蛇游戏");
GoTo(STARTX + 10,STARTY + 10);
printf("游戏规则:");
GoTo(STARTX + 10,STARTY + 12);
printf("请按 ↑ ↓ ← → 来控制您的蛇吃东西");
GoTo(STARTX + 10,STARTY + 14);
printf("吃的越多,蛇就越长,您的等级也将越高");
GoTo(STARTX + 10,STARTY + 16);
printf("当蛇吃到自己或撞上墙时,游戏结束。");
GoTo(STARTX + 4, ENDY - 2);
printf("----------------- 按'1'返回游戏菜单 ---------------");
while (true) {
if (_kbhit()) {
char key = getch();
if (key == '1') break;
}
}
}
void InputData() { //用户输入名字
char name[20];
if(score>=1000)
{
GoTo(STARTX + 10, STARTY + 10);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), RED);
printf("请输入你的名字: ");
COORD coord = { STARTX + 10, STARTY + 12 };
SetConsoleCursorPosition(GetStdHandle(STD_INPUT_HANDLE), coord);
while (true) { //忽略非法字符
scanf("%s", name);
if (name[0] != 0 && name[0] != ' ') break;
}FILE *fp = fopen("Gamedata2.txt", "a");
if (fp == NULL) fp = fopen("Gamedata2.txt", "w+");
fprintf(fp, "%s %d %d \n", name, score,gametime);
fclose(fp);
}
else
{
GoTo(STARTX + 20, STARTY + 10);
cout<<"哟!这分数也能上榜??"<<endl;
Sleep(1000);
}
EndGame();
}
```.cpp
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int ROW = 13;
const int COL = 13;
const int BOX_NUM = 3;
void GotoXY(int x, int y){
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void HideCursor()
{
CONSOLE_CURSOR_INFO c;
c.dwSize = 1;
c.bVisible = FALSE;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &c);
}
char map[ROW][COL];
int px, py;
int dir4[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
void FindPlayer();
bool IsReachable(int sx, int sy, int ex, int ey, char tmpMap[ROW][COL]);
void CopyMap(char src[ROW][COL], char dst[ROW][COL]);
void GenerateMap();
bool IsReachable(int sx, int sy, int ex, int ey, char tmpMap[ROW][COL])
{
bool vis[ROW][COL] = {false};
queue<pair<int, int>> q;
q.push(make_pair(sx, sy));
vis[sy][sx] = true;
while(!q.empty())
{
pair<int,int> cur = q.front();
q.pop();
int x = cur.first;
int y = cur.second;
if(x == ex && y == ey)
return true;
for(int d = 0; d < 4; d++)
{
int nx = x + dir4[d][0];
int ny = y + dir4[d][1];
if(nx > 0 && nx < COL - 1 && ny > 0 && ny < ROW - 1)
{
if(!vis[ny][nx] && tmpMap[ny][nx] != '#')
{
vis[ny][nx] = true;
q.push(make_pair(nx, ny));
}
}
}
}
return false;
}
void CopyMap(char src[ROW][COL], char dst[ROW][COL])
{
for(int i = 0; i < ROW; i++)
for(int j = 0; j < COL; j++)
dst[i][j] = src[i][j];
}
void FindPlayer()
{
for(int i = 0; i < ROW; i++)
for(int j = 0; j < COL; j++)
if(map[i][j] == '@')
{
py = i;
px = j;
return;
}
}
void DrawMap()
{
GotoXY(0, 0);
for(int i = 0; i < ROW; i++)
{
for(int j = 0; j < COL; j++)
cout << map[i][j];
cout << endl;
}
cout << "WASD移动 | R重新生成 | Q退出";
}
bool CheckWin()
{
for(int i = 0; i < ROW; i++)
for(int j = 0; j < COL; j++)
if(map[i][j] == '$')
return false;
return true;
}
void Move(int dx, int dy)
{
int nx = px + dx;
int ny = py + dy;
if(map[ny][nx] == '#')
return;
if(map[ny][nx] == ' ' || map[ny][nx] == '.')
{
if(map[py][px] == '+')
map[py][px] = '.';
else
map[py][px] = ' ';
if(map[ny][nx] == '.')
map[ny][nx] = '+';
else
map[ny][nx] = '@';
px = nx;
py = ny;
return;
}
if(map[ny][nx] == '$' || map[ny][nx] == '*')
{
int boxNextX = nx + dx;
int boxNextY = ny + dy;
if(map[boxNextY][boxNextX] == '#' ||
map[boxNextY][boxNextX] == '$' ||
map[boxNextY][boxNextX] == '*')
return;
if(map[boxNextY][boxNextX] == '.')
map[boxNextY][boxNextX] = '*';
else
map[boxNextY][boxNextX] = '$';
if(map[py][px] == '+')
map[py][px] = '.';
else
map[py][px] = ' ';
if(map[ny][nx] == '*')
map[ny][nx] = '+';
else
map[ny][nx] = '@';
px = nx;
py = ny;
}
}
// 关键:生成一个中心连通的大房间,不再乱撒墙
void GenerateMap()
{
while(true)
{
char temp[ROW][COL];
for(int i = 0; i < ROW; i++)
for(int j = 0; j < COL; j++)
temp[i][j] = ' ';
for(int i = 0; i < ROW; i++)
{
temp[i][0] = '#';
temp[i][COL - 1] = '#';
}
for(int j = 0; j < COL; j++)
{
temp[0][j] = '#';
temp[ROW - 1][j] = '#';
}
// 只在边缘放少量内墙,中心保持可推空间
for(int i = 1; i < ROW - 1; i++)
{
for(int j = 1; j < COL - 1; j++)
{
if(abs(i - ROW / 2) <= 2 && abs(j - COL / 2) <= 2)
continue;
int r = rand() % 100;
if(r < 12)
temp[i][j] = '#';
}
}
int pX = COL / 2;
int pY = ROW / 2;
temp[pY][pX] = '@';
vector<pair<int,int>> boxes;
vector<pair<int,int>> targets;
int cnt = 0;
while(cnt < BOX_NUM)
{
int x = rand() % (COL - 4) + 2;
int y = rand() % (ROW - 4) + 2;
if(temp[y][x] == ' ' && IsReachable(pX, pY, x, y, temp))
{
temp[y][x] = '$';
boxes.push_back(make_pair(x, y));
cnt++;
}
}
cnt = 0;
while(cnt < BOX_NUM)
{
int x = rand() % (COL - 4) + 2;
int y = rand() % (ROW - 4) + 2;
if(temp[y][x] == ' ')
{
temp[y][x] = '.';
targets.push_back(make_pair(x, y));
cnt++;
}
}
bool allOk = true;
for(int b = 0; b < boxes.size(); b++)
{
int bx = boxes[b].first;
int by = boxes[b].second;
bool canPushToTarget = false;
for(int t = 0; t < targets.size(); t++)
{
int tx = targets[t].first;
int ty = targets[t].second;
if(IsReachable(bx, by, tx, ty, temp))
{
canPushToTarget = true;
break;
}
}
if(!canPushToTarget)
{
allOk = false;
break;
}
}
if(allOk)
{
CopyMap(temp, map);
break;
}
}
FindPlayer();
}
int main()
{
HideCursor();
srand((unsigned)time(NULL));
GenerateMap();
char key;
while(true)
{
DrawMap();
if(CheckWin())
{
GotoXY(0, ROW + 2);
cout << "==== 恭喜通关!按R刷新 ====" << endl;
}
if(_kbhit())
{
key = _getch();
switch(key)
{
case 'w': Move(0, -1); break;
case 's': Move(0, 1); break;
case 'a': Move(-1, 0); break;
case 'd': Move(1, 0); break;
case 'r': GenerateMap(); break;
case 'q': return 0;
}
}
Sleep(40);
}
system("pause");
return 0;
}
```.cpp
#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 = 4; roleCfg[2].cnt = 4; roleCfg[3].cnt = 1; roleCfg[4].cnt = 1; roleCfg[5].cnt = 1; 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 << "请输入游玩人数(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;
}