Example #1
0
 /** 实现对悔棋的处理 */
 public void regretAnswer() {
   if (answer == 0) {
     for (int i = 0; i < 8; i++) {
       for (int j = 0; j < 8; j++) {
         if (cb.regChess[i][j] == 2) {
           cb.allChess[i][j] = 0;
         }
         if (cb.regChess[i][j] == 1) {
           if (cb.allChess[i][j] == BLACK) {
             cb.allChess[i][j] = WHITE;
           } else {
             cb.allChess[i][j] = BLACK;
           }
         }
       }
     }
     if (cb.isBlack == true) {
       cb.isBlack = false;
       cb.message = "轮到白方";
     } else {
       cb.isBlack = true;
       cb.message = "轮到黑方";
     }
     cb.isOpposite = false;
     cb.ch.countBlack = cb.ch.lastCountBlack;
     cb.ch.countWhite = cb.ch.lastCountWhite;
     cb.repaint();
     JOptionPane.showMessageDialog(cb, "对方同意了你的悔棋!");
   }
   if (answer != 0) {
     JOptionPane.showMessageDialog(cb, "对方不同意悔棋!");
   }
   answer = 3; // 初始化answer
 }