コード例 #1
0
 /** Method invoked at the beginning of the first game. Allows for players to select their names */
 private void promptNames() {
   if (gui.getTeamName(WHITE).equals("") || gui.getTeamName(BLACK).equals("")) {
     String whiteName = "";
     // ensure the name is not blank
     while (whiteName.equals("")) {
       whiteName = JOptionPane.showInputDialog("White team name:");
     }
     String blackName = "";
     while (blackName.equals("")) {
       blackName = JOptionPane.showInputDialog("Black team name:");
     }
     gui.setTeamNames(whiteName, blackName);
   }
   gui.updateMessage(currentColor);
 }
コード例 #2
0
 /**
  * Checks the board to see if it is in a check, checkmate, or stalemate configuration. If it is,
  * it handles the situation properly.
  */
 private void evaluateBoard() {
   if (master.isCheckmate(currentColor)) {
     gui.checkmateMessage(currentColor);
     gameOver();
   } else if (master.isStalemate(currentColor)) {
     gui.stalemateMessage();
     gameOver();
   } else if (master.isCheck(currentColor) > 0) {
     // only a check, game not over
     gui.checkMessage(currentColor);
   } else {
     // display new turn
     gui.updateMessage(currentColor);
   }
 }