//地盘战争 by Crazyouth
//version:1.4.4
//更新日志:高版本可兼容
#include <bits/stdc++.h>
#include <pthread.h>
#include <windows.h>
#include <conio.h>
using namespace std;
int board[21][21],time_left,pboard[21][21],end_turn=0,player_main_x,player_main_y,bot_main_x,printing=0;
int bot_main_y,player_energy,bot_energy,dx[4]={0,0,-1,1},dy[4]={-1,1,0,0},board_size,esc,player2_energy;
int player2_main_x,player2_main_y,mode,m_time_left;
pthread_t count_down_id,control_id,bot_id,end_id,control2_id,both_id;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
char c;
bool if_get;
void* end_round(void*);
void* lch(void*);
void* control(void*);
void print_board();
void start();
void* lch(void*);
void say(string s)
{
for(int i=0;i<s.size();i++)
{
cout<<s[i];
Sleep(5);
}
}
void* count_down(void* args)
{
while(time_left>0)
{
Sleep(1000);
time_left--;
for(int i=1;i<=board_size;i++)
for(int j=1;j<=board_size;j++)
if(pboard[i][j])
{
if(pboard[i][j]<=2) player_energy+=2;
else bot_energy+=2;
board[i][j]+=2;
board[i][j]%=100;
}
if(!printing)
print_board();
}
system("cls");
end_turn=1;
system("cls");
Sleep(10);
if(!esc)
end_round(args);
else
lch(args);
pthread_exit(&count_down_id);
}
void init_board()
{
srand(time(0));
int r;
for(int i=1;i<=board_size;i++)
for(int j=1;j<=board_size;j++)
{
r=rand()%99+1;
board[i][j]=r;
if(i==1&&j==1) pboard[i][j]=1;
else if(i==board_size&&j==board_size) pboard[i][j]=3;
else pboard[i][j]=0;
}
player_energy=board[1][1];
bot_energy=board[board_size][board_size];
player2_energy=board[board_size][board_size];
player_main_x=1;
player_main_y=1;
bot_main_x=board_size;
bot_main_y=board_size;
player2_main_x=board_size;
player2_main_y=board_size;
}
void print_board()
{
printing=1;
system("cls");
for(int i=1;i<=board_size;i++)
{
for(int j=1;j<=board_size;j++)
{
if(pboard[i][j]==0) SetConsoleTextAttribute(handle,15);//无主
else if(pboard[i][j]==1) SetConsoleTextAttribute(handle,215);//玩家主格
else if(pboard[i][j]==2) SetConsoleTextAttribute(handle,193);//己方格子
else if(pboard[i][j]==3) SetConsoleTextAttribute(handle,30);//电脑主格
else if(pboard[i][j]==4) SetConsoleTextAttribute(handle,176);//敌方格子
if(board[i][j]<10) cout<<0;
cout<<board[i][j]<<' ';
}
SetConsoleTextAttribute(handle,15);
if(i==1) cout<<" Counting down:"<<time_left;
cout<<endl;
}
cout<<endl;
cout<<"Player energy:"<<player_energy<<" ";
if(mode==1) cout<<"Bot energy:";
else cout<<"Player 2 energy:";
cout<<bot_energy;
printing=0;
}
void* bot(void* args)
{
int r=-1,minn=100,xx,yy;
while(!end_turn)
{
Sleep(rand()%901+500);
//r=rand()%4;
//while(bot_main_x+dx[r]<=0||bot_main_x+dx[r]>board_size||bot_main_y+dy[r]<=0||bot_main_y+dy[r]>board_size||bot_energy<board[bot_main_y+dy[r]][bot_main_x+dx[r]]||pboard[bot_main_y+dy[r]][bot_main_x+dx[r]]==1) r=rand()%4;
r=-1;
while(1)
{
r=-1;
minn=100;
for(int i=0;i<4;i++)
{
xx=bot_main_x+dx[i];
yy=bot_main_y+dy[i];
if(xx>0&&xx<=board_size&&yy>0&&yy<=board_size&&bot_energy>=board[yy][xx]&&pboard[yy][xx]==2&&board[yy][xx]<minn)
{
minn=board[yy][xx];
r=i;
}
}
if(r!=-1) break;
minn=100;
for(int i=0;i<4;i++)
{
xx=bot_main_x+dx[i];
yy=bot_main_y+dy[i];
if(r==-1&&xx>0&&xx<=board_size&&yy>0&&yy<=board_size&&bot_energy>=board[yy][xx]&&board[yy][xx]<minn&&pboard[yy][xx]!=4)
{
minn=board[yy][xx];
r=i;
}
}
if(r!=-1) break;
minn=100;
for(int i=0;i<4;i++)
{
xx=bot_main_x+dx[i];
yy=bot_main_y+dy[i];
if(r==-1&&xx>0&&xx<=board_size&&yy>0&&yy<=board_size&&bot_energy>=board[yy][xx]&&board[yy][xx]<minn&&pboard[yy][xx]!=1)
{
minn=board[yy][xx];
r=i;
}
}
if(r!=-1) break;
}
pboard[bot_main_y][bot_main_x]=4;
bot_main_y+=dy[r];
bot_main_x+=dx[r];
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]&&pboard[bot_main_y][bot_main_x]<3)
player_energy-=board[bot_main_y][bot_main_x];
bot_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
pthread_exit(&bot_id);
}
void* end_round(void* args)
{
Sleep(500);
for(int i=1;i<=board_size;i++)
for(int j=1;j<=board_size;j++)
{
pboard[i][j]=0;
board[i][j]=0;
}
esc=0;
system("cls");
if(player_energy>bot_energy) say("Player wins!\n");
else if(player_energy==bot_energy) say("Tie!\n");
else
{
if(mode==1) say("Bot wins!\n");
else say("Player 2 wins!\n");
}
say("Player energy=");
cout<<player_energy;
if(mode==1)
say(" , Bot energy=");
else
say(" , Player 2 energy=");
cout<<bot_energy<<endl;
cout<<endl;
say("1.新的游戏\n2.返回");
char c=' ';
while(c<'1'||c>'2') c=_getch();
if(c=='1') start();
else
{
void* args;
lch(args);
}
}
void single_player()
{
mode=1;
system("cls");
say("输入棋盘大小n:(5<=n<=20)\n");
cin>>board_size;
while(board_size<5||board_size>20)
{
system("cls");
say("输入不合法,请重新输入棋盘大小n:(5<=n<=20)\n");
cin>>board_size;
}
init_board();
time_left=m_time_left;
end_turn=0;
pthread_create(&count_down_id,NULL,count_down,NULL);
pthread_create(&control_id,NULL,control,NULL);
pthread_create(&bot_id,NULL,bot,NULL);
pthread_exit(NULL);
}
void* control(void* args)
{
while(!end_turn)
{
c=_getch();
if_get=true;
if(c=='W'||c=='w')
{
if(player_main_y>1&&(player_energy>=board[player_main_y-1][player_main_x]||pboard[player_main_y-1][player_main_x]==1||pboard[player_main_y-1][player_main_x]==2)&&pboard[player_main_y-1][player_main_x]!=3)
{
if(pboard[player_main_y-1][player_main_x]<1||pboard[player_main_y-1][player_main_x]>2)
player_energy-=board[player_main_y-1][player_main_x];
pboard[player_main_y][player_main_x]=2;
player_main_y--;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='A'||c=='a')
{
if(player_main_x>1&&(player_energy>=board[player_main_y][player_main_x-1]||pboard[player_main_y][player_main_x-1]==1||pboard[player_main_y][player_main_x-1]==2)&&pboard[player_main_y][player_main_x-1]!=3)
{
if(pboard[player_main_y][player_main_x-1]<1||pboard[player_main_y][player_main_x-1]>2)
player_energy-=board[player_main_y][player_main_x-1];
pboard[player_main_y][player_main_x]=2;
player_main_x--;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='S'||c=='s')
{
if(player_main_y<board_size&&(player_energy>=board[player_main_y+1][player_main_x]||pboard[player_main_y+1][player_main_x]==1||pboard[player_main_y+1][player_main_x]==2)&&pboard[player_main_y+1][player_main_x]!=3)
{
if(pboard[player_main_y+1][player_main_x]<1||pboard[player_main_y+1][player_main_x]>2)
player_energy-=board[player_main_y+1][player_main_x];
pboard[player_main_y][player_main_x]=2;
player_main_y++;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='D'||c=='d')
{
if(player_main_x<board_size&&(player_energy>=board[player_main_y][player_main_x+1]||pboard[player_main_y][player_main_x+1]==1||pboard[player_main_y][player_main_x+1]==2)&&pboard[player_main_y][player_main_x+1]!=3)
{
if(pboard[player_main_y][player_main_x+1]<1||pboard[player_main_y][player_main_x+1]>2)
player_energy-=board[player_main_y][player_main_x+1];
pboard[player_main_y][player_main_x]=2;
player_main_x++;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c==27)
{
esc=1;
time_left=0;
}
}
pthread_exit(&control_id);
}
void* control2(void* args)
{
while(!end_turn)
{
if(!if_get){
if(c=='I'||c=='i'&&!if_get)
{
if(bot_main_y>1&&(bot_energy>board[bot_main_y-1][bot_main_x]||pboard[bot_main_y-1][bot_main_x]==3||pboard[bot_main_y-1][bot_main_x]==4)&&pboard[bot_main_y-1][bot_main_x]!=1)
{
if(pboard[bot_main_y-1][bot_main_x]<3||pboard[bot_main_y-1][bot_main_x]>4)
bot_energy-=board[bot_main_y-1][bot_main_x];
pboard[bot_main_y][bot_main_x]=4;
bot_main_y--;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='J'||c=='j'&&!if_get)
{
if(bot_main_x>1&&(bot_energy>board[bot_main_y][bot_main_x-1]||pboard[bot_main_y][bot_main_x-1]==3||pboard[bot_main_y][bot_main_x-1]==4)&&pboard[bot_main_y][bot_main_x-1]!=1)
{
if(pboard[bot_main_y][bot_main_x-1]<3||pboard[bot_main_y][bot_main_x-1]>4)
bot_energy-=board[bot_main_y][bot_main_x-1];
pboard[bot_main_y][bot_main_x]=4;
bot_main_x--;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='K'||c=='k'&&!if_get)
{
if(bot_main_y<board_size&&(bot_energy>board[bot_main_y+1][bot_main_x]||pboard[bot_main_y+1][bot_main_x]==3||pboard[bot_main_y+1][bot_main_x]==4)&&pboard[bot_main_y+1][bot_main_x]!=1)
{
if(pboard[bot_main_y+1][bot_main_x]<3||pboard[bot_main_y+1][bot_main_x]>4)
bot_energy-=board[bot_main_y+1][bot_main_x];
pboard[bot_main_y][bot_main_x]=4;
bot_main_y++;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='L'||c=='l'&&!if_get)
{
if(bot_main_x<board_size&&(bot_energy>board[bot_main_y][bot_main_x+1]||pboard[bot_main_y][bot_main_x+1]==3||pboard[bot_main_y][bot_main_x+1]==4)&&pboard[bot_main_y][bot_main_x+1]!=1)
{
if(pboard[bot_main_y][bot_main_x+1]<3||pboard[bot_main_y][bot_main_x+1]>4)
bot_energy-=board[bot_main_y][bot_main_x+1];
pboard[bot_main_y][bot_main_x]=4;
bot_main_x++;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c==27)
{
esc=1;
time_left=0;
}
else if_get=false;
}
}
pthread_exit(&control2_id);
}
void ctn()
{
say("请按任意键继续...\n");
_getch();
}
void* both(void* args)
{
while(!end_turn)
{
c=_getch();
if(c=='W'||c=='w')
{
if(player_main_y>1&&(player_energy>=board[player_main_y-1][player_main_x]||pboard[player_main_y-1][player_main_x]==1||pboard[player_main_y-1][player_main_x]==2)&&pboard[player_main_y-1][player_main_x]!=3)
{
if(pboard[player_main_y-1][player_main_x]<1||pboard[player_main_y-1][player_main_x]>2)
player_energy-=board[player_main_y-1][player_main_x];
pboard[player_main_y][player_main_x]=2;
player_main_y--;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='A'||c=='a')
{
if(player_main_x>1&&(player_energy>=board[player_main_y][player_main_x-1]||pboard[player_main_y][player_main_x-1]==1||pboard[player_main_y][player_main_x-1]==2)&&pboard[player_main_y][player_main_x-1]!=3)
{
if(pboard[player_main_y][player_main_x-1]<1||pboard[player_main_y][player_main_x-1]>2)
player_energy-=board[player_main_y][player_main_x-1];
pboard[player_main_y][player_main_x]=2;
player_main_x--;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='S'||c=='s')
{
if(player_main_y<board_size&&(player_energy>=board[player_main_y+1][player_main_x]||pboard[player_main_y+1][player_main_x]==1||pboard[player_main_y+1][player_main_x]==2)&&pboard[player_main_y+1][player_main_x]!=3)
{
if(pboard[player_main_y+1][player_main_x]<1||pboard[player_main_y+1][player_main_x]>2)
player_energy-=board[player_main_y+1][player_main_x];
pboard[player_main_y][player_main_x]=2;
player_main_y++;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c=='D'||c=='d')
{
if(player_main_x<board_size&&(player_energy>=board[player_main_y][player_main_x+1]||pboard[player_main_y][player_main_x+1]==1||pboard[player_main_y][player_main_x+1]==2)&&pboard[player_main_y][player_main_x+1]!=3)
{
if(pboard[player_main_y][player_main_x+1]<1||pboard[player_main_y][player_main_x+1]>2)
player_energy-=board[player_main_y][player_main_x+1];
pboard[player_main_y][player_main_x]=2;
player_main_x++;
if(pboard[player_main_y][player_main_x]!=2)
{
if(pboard[player_main_y][player_main_x]<5&&pboard[player_main_y][player_main_x]>2)
bot_energy-=board[player_main_y][player_main_x];
board[player_main_y][player_main_x]=0;
}
pboard[player_main_y][player_main_x]=1;
if(!printing)
print_board();
}
if_get=false;
}
if(c==27)
{
esc=1;
time_left=0;
}
if(c=='I'||c=='i')
{
if(bot_main_y>1&&(bot_energy>=board[bot_main_y-1][bot_main_x]||pboard[bot_main_y-1][bot_main_x]==3||pboard[bot_main_y-1][bot_main_x]==4)&&pboard[bot_main_y-1][bot_main_x]!=1)
{
if(pboard[bot_main_y-1][bot_main_x]<3||pboard[bot_main_y-1][bot_main_x]>4)
bot_energy-=board[bot_main_y-1][bot_main_x];
pboard[bot_main_y][bot_main_x]=4;
bot_main_y--;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='J'||c=='j')
{
if(bot_main_x>1&&(bot_energy>=board[bot_main_y][bot_main_x-1]||pboard[bot_main_y][bot_main_x-1]==3||pboard[bot_main_y][bot_main_x-1]==4)&&pboard[bot_main_y][bot_main_x-1]!=1)
{
if(pboard[bot_main_y][bot_main_x-1]<3||pboard[bot_main_y][bot_main_x-1]>4)
bot_energy-=board[bot_main_y][bot_main_x-1];
pboard[bot_main_y][bot_main_x]=4;
bot_main_x--;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='K'||c=='k')
{
if(bot_main_y<board_size&&(bot_energy>=board[bot_main_y+1][bot_main_x]||pboard[bot_main_y+1][bot_main_x]==3||pboard[bot_main_y+1][bot_main_x]==4)&&pboard[bot_main_y+1][bot_main_x]!=1)
{
if(pboard[bot_main_y+1][bot_main_x]<3||pboard[bot_main_y+1][bot_main_x]>4)
bot_energy-=board[bot_main_y+1][bot_main_x];
pboard[bot_main_y][bot_main_x]=4;
bot_main_y++;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
else if(c=='L'||c=='l')
{
if(bot_main_x<board_size&&(bot_energy>=board[bot_main_y][bot_main_x+1]||pboard[bot_main_y][bot_main_x+1]==3||pboard[bot_main_y][bot_main_x+1]==4)&&pboard[bot_main_y][bot_main_x+1]!=1)
{
if(pboard[bot_main_y][bot_main_x+1]<3||pboard[bot_main_y][bot_main_x+1]>4)
bot_energy-=board[bot_main_y][bot_main_x+1];
pboard[bot_main_y][bot_main_x]=4;
bot_main_x++;
if(pboard[bot_main_y][bot_main_x]!=4)
{
if(pboard[bot_main_y][bot_main_x]<3&&pboard[bot_main_y][bot_main_x]>0)
player_energy-=board[bot_main_y][bot_main_x];
board[bot_main_y][bot_main_x]=0;
}
pboard[bot_main_y][bot_main_x]=3;
if(!printing)
print_board();
}
if_get=false;
}
}
pthread_exit(&both_id);
}
void setting()
{
void* args;
system("cls");
char c;
int tp=0;
say("1.设置时间\n");
while(c<'1'||c>'1') c=_getch();
if(c=='1')
{
system("cls");
say("输入时间t:(10<=t<=1e9)\n");
cin>>tp;
while(tp<10||tp>1e9)
{
system("cls");
say("输入不合法,请重新输入时间t:(10<=t<=1e9)\n");
cin>>tp;
}
m_time_left=tp;
ctn();
lch(args);
}
}
void double_player()
{
mode=2;
system("cls");
say("输入棋盘大小n:(5<=n<=20)\n");
cin>>board_size;
while(board_size<5||board_size>20)
{
system("cls");
say("输入不合法,请重新输入棋盘大小n:(5<=n<=20)\n");
cin>>board_size;
}
init_board();
time_left=m_time_left;
end_turn=0;
pthread_create(&count_down_id,NULL,count_down,NULL);
pthread_create(&both_id,NULL,both,NULL);
pthread_exit(NULL);
}
void start()
{
esc=0;
system("cls");
say("1.单人游戏\n");
say("2.双人游戏\n");
say("3.退出\n");
char c=' ';
while(c<'1'||c>'3') c=_getch();
if(c=='1') single_player();
else if(c=='2') double_player();
else
{
void* args;
lch(args);
}
pthread_exit(NULL);
}
void help()
{
system("cls");
say("游戏玩法:\n");
say("1.「n*n」的游戏场地上将出现400个1~99的随机数字\n");
say("tips: n为玩家输入的棋盘大小\n");
say("2. 单人游戏中,你需要用[w][s][a][d]操控主格上下左右移动;\n");
say("多人游戏中,player 1 的操作与单人游戏一致,player 2 需要用[i][k][j][l]操控主格上下左右移动\n");
say("tips: 主格为颜色较深的那一个,红蓝两方各有一个主格,且主格不能被变成「敌方格子」\n");
say("tips: 玩家/玩家1主格开始时位于(1,1),电脑/玩家2主格开始时位于(n,n)\n");
say("3. 每方玩家开始会有与自己开始格能量一致的能量,踩上一个「非我方格子」可以花费该格子的数字的能量将其变为「己方格子」,并且该格子数字清零\n");
say("tips: 若被占领的格子为地方格子,敌方与我方共同减少该格的能量,该格变为我方格子\n");
say("tips: 如果能量不够将不能踩上该格子\n");
say("4. 每个「己方格子」或「敌方格子」每过1秒会将该格数字加二\n");
say("tips: 如果一个格子能量大于x,下一秒将变成(x+2) mod 100,但是玩家能量不变\n");
say("5. 每方的总能量为该方所有格子的数字总和\n");
say("6. 开始后,将有1分钟倒计时,倒计时结束后能量多者获胜\n");
say("7. 不想玩了按Esc退出\n");
say("8. 请注意,每次您结束游戏(手动或自动)都需要按任意键来进入结束画面\n");
say("规则中若有解释不详尽处,自己到游戏里看(作者不想写了)");
_getch();
void* args;
lch(args);
}
void* lch(void* args)
{
system("cls");
char c=' ';
SetConsoleTextAttribute(handle,193);//粉底蓝字
SetConsoleTextAttribute(handle,215);//紫底白字
SetConsoleTextAttribute(handle,176);//蓝底黑字
SetConsoleTextAttribute(handle,30);//深蓝白字
SetConsoleTextAttribute(handle,15);//白字
say("地盘战争\n作者:Crazyouth\n");
say("1.开始游戏\n");
say("2.帮助\n");
say("3.设置\n");
say("4.退出\n");
while(c<'1'||c>'4') c=_getch();
if(c=='1') start();
if(c=='2') help();
if(c=='3') setting();
if(c=='4')
{
system("cls");
return args;
}
}
int main()
{
m_time_left=60;
pthread_t start_id;
void* args;
lch(args);
system("cls");
return 0;
}