chessai

college code for ai playing chess in java

git clone https://9o.is/git/chessai.git

StatusResponse.java

(2263B)


      1 package chess.server;
      2 
      3 import chess.ChessCoordinate;
      4 import chess.utils.ChessType;
      5 
      6 /**
      7  *
      8  */
      9 public class StatusResponse {
     10 
     11     private boolean ready;
     12     private String lastMove;
     13     private int secondsLeft;
     14     private boolean gameover;
     15     private int winner;
     16 
     17     private long lastMoveNumber;
     18 
     19     public boolean isReady() {
     20         return ready;
     21     }
     22 
     23     public void setReady(boolean ready) {
     24         this.ready = ready;
     25     }
     26 
     27     public long getLastMoveNumber() {
     28         return lastMoveNumber;
     29     }
     30 
     31     public void setLastMoveNumber(long lastMoveNumber) {
     32         this.lastMoveNumber = lastMoveNumber;
     33     }
     34 
     35     public int getSecondsLeft() {
     36         return secondsLeft;
     37     }
     38 
     39     public void setSecondsLeft(int secondsLeft) {
     40         this.secondsLeft = secondsLeft;
     41     }
     42 
     43     public String getLastMove() {
     44         return lastMove;
     45     }
     46 
     47     public void setLastMove(String lastMove) {
     48         this.lastMove = lastMove;
     49     }
     50 
     51     public boolean isGameover() {
     52         return gameover;
     53     }
     54 
     55     public void setGameover(boolean gameover) {
     56         this.gameover = gameover;
     57     }
     58 
     59     public int getWinner() {
     60         return winner;
     61     }
     62 
     63     public void setWinner(int winner) {
     64         this.winner = winner;
     65     }
     66 
     67     public ChessCoordinate srcLastMove() {
     68         if(ready && lastMove != null && lastMove.length() >= 5) {
     69             char file = lastMove.charAt(1);
     70             int rank = Integer.parseInt(lastMove.substring(2, 3));
     71             return new ChessCoordinate(file,rank);
     72         }
     73         return null;
     74     }
     75 
     76     public ChessCoordinate destLastMove() {
     77         if(ready && lastMove != null && lastMove.length() >= 5) {
     78             char file = lastMove.charAt(3);
     79             int rank = Integer.parseInt(lastMove.substring(4, 5));
     80             return new ChessCoordinate(file,rank);
     81         }
     82         return null;
     83     }
     84 
     85     public ChessType typeLastMove() {
     86         if(ready && lastMove != null && lastMove.length() >= 5) {
     87             return ChessType.find(lastMove.substring(0,1));
     88         }
     89         return null;
     90     }
     91 
     92     public ChessType promotionLastMove() {
     93         if(ready && lastMove != null && lastMove.length() == 6) {
     94             return ChessType.find(lastMove.substring(5,6));
     95         }
     96         return null;
     97     }
     98 }