8,305
社区成员
发帖
与我相关
我的任务
分享
static void IfWin(int x,int y,int color)
{
TCHAR win[]=TEXT("Win!");
int a,b;
/*if(stone[x][y]==1)
strcpy(win, "黑棋赢!");
else
strcpy(win, "白棋赢!");*/
if(x>=4&&x<=14&&y>=4&&y<=14)
{
for(a=x-4;a<=x+4;a++)//判断横
if(stone[a][y]==color&&stone[a+1][y]==color&&stone[a+2][y]==color&&stone[a+3][y]==color&&stone[a+4][y]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(b=y-4;b<=y+4;b++)//判断竖
if(stone[x][b]==color&&stone[x][b+1]==color&&stone[x][b+2]==color&&stone[x][b+3]==color&&stone[x][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-4,b=y-4;a<=x+4;a++,b++)//判断右斜
if(stone[a][b]==color&&stone[a+1][b+1]==color&&stone[a+2][b+2]==color&&stone[a+3][b+3]==color&&stone[a+4][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-4,b=y+4;a<=x+4;a++,b--)//判断左斜
if(stone[a][b]==color&&stone[a+1][b-1]==color&&stone[a+2][b-2]==color&&stone[a+3][b-3]==color&&stone[a+4][b-4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
}
else if(x<4&&y>=4&&y<=14)
{
for(a=0;a<=x+4;a++)//判断横
if(stone[a][y]==color&&stone[a+1][y]==color&&stone[a+2][y]==color&&stone[a+3][y]==color&&stone[a+4][y]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(b=y-4;b<=y+4;b++)//判断竖
if(stone[x][b]==color&&stone[x][b+1]==color&&stone[x][b+2]==color&&stone[x][b+3]==color&&stone[x][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=0,b=y-4;a<=x+4;a++,b++)//判断右斜
if(stone[a][b]==color&&stone[a+1][b+1]==color&&stone[a+2][b+2]==color&&stone[a+3][b+3]==color&&stone[a+4][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=0,b=y+4;a<=x+4;a++,b++)//判断左斜
if(stone[a][b]==color&&stone[a+1][b-1]==color&&stone[a+2][b-2]==color&&stone[a+3][b-3]==color&&stone[a+4][b-4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
}
else if(x>=4&&x<=14&&y<4)
{
for(a=x-4;a<=x+4;a++)//判断横
if(stone[a][y]==color&&stone[a+1][y]==color&&stone[a+2][y]==color&&stone[a+3][y]==color&&stone[a+4][y]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(b=0;b<=y+4;b++)//判断竖
if(stone[x][b]==color&&stone[x][b+1]==color&&stone[x][b+2]==color&&stone[x][b+3]==color&&stone[x][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-y,b=0;a<=x+4;a++,b++)//判断右斜
if(stone[a][b]==color&&stone[a+1][b+1]==color&&stone[a+2][b+2]==color&&stone[a+3][b+3]==color&&stone[a+4][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-4,b=y+4;a<=x+y;a++,b++)//判断左斜
if(stone[a][b]==color&&stone[a+1][b-1]==color&&stone[a+2][b-2]==color&&stone[a+3][b-3]==color&&stone[a+4][b-4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
}
else if(x>14&&y>=4&&y<=14)
{
for(a=x-4;a<=18;a++)//判断横
if(stone[a][y]==color&&stone[a+1][y]==color&&stone[a+2][y]==color&&stone[a+3][y]==color&&stone[a+4][y]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(b=y-4;b<=y+4;b++)//判断竖
if(stone[x][b]==color&&stone[x][b+1]==color&&stone[x][b+2]==color&&stone[x][b+3]==color&&stone[x][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=0,b=y-4;a<=18;a++,b++)//判断右斜
if(stone[a][b]==color&&stone[a+1][b+1]==color&&stone[a+2][b+2]==color&&stone[a+3][b+3]==color&&stone[a+4][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=0,b=y+4;a<=18;a++,b++)//判断左斜
if(stone[a][b]==color&&stone[a+1][b-1]==color&&stone[a+2][b-2]==color&&stone[a+3][b-3]==color&&stone[a+4][b-4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
}
else if(x>=4&&x<=14&&y>14)
{
for(a=x-4;a<=x+4;a++)//判断横
if(stone[a][y]==color&&stone[a+1][y]==color&&stone[a+2][y]==color&&stone[a+3][y]==color&&stone[a+4][y]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(b=x-4;b<=18;b++)//判断竖
if(stone[x][b]==color&&stone[x][b+1]==color&&stone[x][b+2]==color&&stone[x][b+3]==color&&stone[x][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-4,b=y-4;a<=x+y;a++,b++)//判断右斜
if(stone[a][b]==color&&stone[a+1][b+1]==color&&stone[a+2][b+2]==color&&stone[a+3][b+3]==color&&stone[a+4][b+4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
for(a=x-4,b=0;a<=x+4;a++,b++)//判断左斜
if(stone[a][b]==color&&stone[a+1][b-1]==color&&stone[a+2][b-2]==color&&stone[a+3][b-3]==color&&stone[a+4][b-4]==color)
MessageBoxW(Xqwl.hWnd,win,TEXT(""),MB_OK);return;
}
}