Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3648178
  • 博文数量: 365
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2522
  • 用 户 组: 普通用户
  • 注册时间: 2019-10-28 13:40
文章分类

全部博文(365)

文章存档

2023年(8)

2022年(130)

2021年(155)

2020年(50)

2019年(22)

我的朋友

分类: 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;

}

}

}

}

阅读(555) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~