分类: Java
2022-11-23 17:04:22
public void judge() {
for(t = newchessX,s = newchessY,count = 0; t >=0 && s >= 0 && count <= 4; t--,s--,count++) {
comeX = t;
comeY = s;
}
for(t = newchessX, s = newchessY, count = 0; t <=14 && s >= 0 && count <= 4; t++, s--, count++) {
toX = t;
toY = s;
}
if(winFLAG == 0) {
for(int ch = 1; ch <=2; ch++) {
CHESSCOLOR = ch;
//判断横向棋子
for(s = (newchessX - 4) >=0 ? (newchessX - 4) : 0 ; s <= newchessX; s++) {//表示玩家获胜
t = newchessY;
if(map[s][t] == CHESSCOLOR && s < 11) {//行棋子数量计算
if(map[s + 1][t] == CHESSCOLOR) {
if(map[s + 2][t] == CHESSCOLOR) {
if(map[s + 3][t] == CHESSCOLOR) {
if(map[s + 4][t] == CHESSCOLOR) {
winX = s;
winY = t;
winWay = 1;
if(CHESSCOLOR == 1) {//白棋
winFLAG = 1;
}else {//黑棋
winFLAG = 2;
}
break;
}
}
}
}
}
}
if(winFLAG != 0) {//如果某一方赢了就直接退出
break;
}
//判断列项棋子
for(t = (newchessY - 4) >=0 ? (newchessY - 4) : 0 ; t <= newchessY; t ++) {
s = newchessX;
if(map[s][t] == CHESSCOLOR && t < 11) {//列棋子数量计算
if(map[s][t + 1] == CHESSCOLOR) {
if(map[s][t + 2] == CHESSCOLOR) {
if(map[s][t + 3] == CHESSCOLOR) {
if(map[s][t + 4] == CHESSCOLOR) {
winX = s;
winY = t;
winWay = 2;
if(CHESSCOLOR == 1) {//白棋
winFLAG = 1;
}else {//黑棋
winFLAG = 2;
}
break;
}
}
}
}
}
}
if(winFLAG != 0) {//如果某一方赢了就直接退出
break;
}
//判断左上到右下棋子
for(s = comeX, t = comeY; s <= newchessX && t <= newchessY; s ++, t++) {
if(map[s][t] == CHESSCOLOR && s < 11 && t < 11) {//斜下棋子数量计算
if(map[s + 1][t + 1] == CHESSCOLOR) {
if(map[s + 2][t + 2] == CHESSCOLOR) {
if(map[s + 3][t + 3] == CHESSCOLOR) {
if(map[s + 4][t + 4] == CHESSCOLOR) {
winX = s;
winY = t;
winWay = 3;
if(CHESSCOLOR == 1) {//白棋
winFLAG = 1;
}else {//黑棋
winFLAG = 2;
}
break;
}
}
}
}
}
}
if(winFLAG != 0) {//如果某一方赢了就直接退出
break;
}
//判断右上到左下棋子
for(s = toX, t = toY; s >= newchessX && t <= newchessY; s --, t++) {
if(map[s][t] ==外汇跟单gendan5.com CHESSCOLOR && s >= 4 && t < 11) {//斜上棋子数量计算
if(map[s - 1][t + 1] == CHESSCOLOR) {
if(map[s - 2][t + 2] == CHESSCOLOR) {
if(map[s - 3][t + 3] == CHESSCOLOR) {
if(map[s - 4][t + 4] == CHESSCOLOR) {
winX = s;
winY = t;
winWay = 4;
if(CHESSCOLOR == 1) {//白棋
winFLAG = 1;
}else {//黑棋
winFLAG = 2;
}
break;
}
}
}
}
}
}
if(winFLAG != 0) {//如果某一方赢了就直接退出
break;
}
}
}
}