Advertisement
Guest User

Untitled

a guest
Apr 13th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.99 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package Rules;
  7.  
  8. public class Move {
  9.     public static boolean algebraic = false;
  10.     protected Chessboard board;
  11.     protected int from_x;
  12.     protected int from_y;
  13.     protected int to_x;
  14.     protected int to_y;
  15.     protected int checkmate;
  16.     protected int promotion;
  17.     protected double score;
  18.     protected boolean reverseMoved;
  19.     protected int castle;
  20.     protected int piece;
  21.  
  22.     public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, int piece) {
  23.         this.castle = 0;
  24.         this.from_x = from_x;
  25.         this.from_y = from_y;
  26.         this.to_x = to_x;
  27.         this.to_y = to_y;
  28.         this.checkmate = checkmate;
  29.         this.promotion = promotion;
  30.         this.board = Chessboard.getInitialBoard();
  31.         this.piece = piece;
  32.     }
  33.  
  34.     public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, Chessboard board, int piece) {
  35.         this.castle = 0;
  36.         this.from_x = from_x;
  37.         this.from_y = from_y;
  38.         this.to_x = to_x;
  39.         this.to_y = to_y;
  40.         this.checkmate = checkmate;
  41.         this.promotion = promotion;
  42.         this.board = board;
  43.         this.piece = piece;
  44.         if (board == null) {
  45.             this.board = Chessboard.getInitialBoard();
  46.         }
  47.  
  48.     }
  49.  
  50.     public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, int castle, Chessboard board, int piece) {
  51.         this(from_x, from_y, to_x, to_y, checkmate, promotion, board, piece);
  52.         this.castle = castle;
  53.     }
  54.  
  55.     public int getPromotion() {
  56.         return this.promotion;
  57.     }
  58.  
  59.     public int[] getCoordinates() {
  60.         return new int[]{this.from_x, this.from_y, this.to_x, this.to_y};
  61.     }
  62.  
  63.     public void setAlgebraicNotaion(boolean algebraic) {
  64.         algebraic = algebraic;
  65.     }
  66.  
  67.     public String toString() {
  68.         String note = "";
  69.         String[] letters;
  70.         if (algebraic) {
  71.             switch(this.board.board[this.from_x][this.from_y]) {
  72.             case -6:
  73.                 note = note + "K";
  74.                 break;
  75.             case -5:
  76.                 note = note + "Q";
  77.                 break;
  78.             case -4:
  79.                 note = note + "R";
  80.                 break;
  81.             case -3:
  82.                 note = note + "N";
  83.                 break;
  84.             case -2:
  85.                 note = note + "B";
  86.                 break;
  87.             case -1:
  88.                 note = note.makeConcatWithConstants<invokedynamic>(note);
  89.             case 0:
  90.             default:
  91.                 break;
  92.             case 1:
  93.                 note = note.makeConcatWithConstants<invokedynamic>(note);
  94.                 break;
  95.             case 2:
  96.                 note = note + "B";
  97.                 break;
  98.             case 3:
  99.                 note = note + "N";
  100.                 break;
  101.             case 4:
  102.                 note = note + "R";
  103.                 break;
  104.             case 5:
  105.                 note = note + "Q";
  106.                 break;
  107.             case 6:
  108.                 note = note + "K";
  109.             }
  110.  
  111.             letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h"};
  112.             if (this.board.board[this.to_x][this.to_y] != 0) {
  113.                 if (this.board.board[this.from_x][this.from_y] == 1 || this.board.board[this.from_x][this.from_y] == -1) {
  114.                     note = note + letters[this.from_y];
  115.                 }
  116.  
  117.                 note = note + "x";
  118.             }
  119.  
  120.             note = note + letters[this.to_y] + (this.to_x + 1);
  121.             if (this.promotion == 5) {
  122.                 note = note + "Q";
  123.             }
  124.  
  125.             if (this.promotion == 4) {
  126.                 note = note + "R";
  127.             }
  128.  
  129.             if (this.promotion == 2) {
  130.                 note = note + "B";
  131.             }
  132.  
  133.             if (this.promotion == 3) {
  134.                 note = note + "N";
  135.             }
  136.  
  137.             if (this.castle == 1) {
  138.                 note = "O-O";
  139.             }
  140.  
  141.             if (this.castle == 2) {
  142.                 note = "O-O-O";
  143.             }
  144.  
  145.             if (this.checkmate == 1) {
  146.                 note = note + "+";
  147.             }
  148.  
  149.             if (this.checkmate == 2) {
  150.                 note = note + "#";
  151.             }
  152.         } else {
  153.             letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h"};
  154.             note = note + letters[this.from_y] + (this.from_x + 1);
  155.             note = note + "-";
  156.             note = note + letters[this.to_y] + (this.to_x + 1);
  157.             if (this.promotion == 5) {
  158.                 note = note + "Q";
  159.             }
  160.  
  161.             if (this.promotion == 4) {
  162.                 note = note + "R";
  163.             }
  164.  
  165.             if (this.promotion == 2) {
  166.                 note = note + "B";
  167.             }
  168.  
  169.             if (this.promotion == 3) {
  170.                 note = note + "N";
  171.             }
  172.         }
  173.  
  174.         return note;
  175.     }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement