Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Source code recreated from a .class file by IntelliJ IDEA
- // (powered by Fernflower decompiler)
- //
- package Rules;
- public class Move {
- public static boolean algebraic = false;
- protected Chessboard board;
- protected int from_x;
- protected int from_y;
- protected int to_x;
- protected int to_y;
- protected int checkmate;
- protected int promotion;
- protected double score;
- protected boolean reverseMoved;
- protected int castle;
- protected int piece;
- public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, int piece) {
- this.castle = 0;
- this.from_x = from_x;
- this.from_y = from_y;
- this.to_x = to_x;
- this.to_y = to_y;
- this.checkmate = checkmate;
- this.promotion = promotion;
- this.board = Chessboard.getInitialBoard();
- this.piece = piece;
- }
- public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, Chessboard board, int piece) {
- this.castle = 0;
- this.from_x = from_x;
- this.from_y = from_y;
- this.to_x = to_x;
- this.to_y = to_y;
- this.checkmate = checkmate;
- this.promotion = promotion;
- this.board = board;
- this.piece = piece;
- if (board == null) {
- this.board = Chessboard.getInitialBoard();
- }
- }
- public Move(int from_x, int from_y, int to_x, int to_y, int checkmate, int promotion, int castle, Chessboard board, int piece) {
- this(from_x, from_y, to_x, to_y, checkmate, promotion, board, piece);
- this.castle = castle;
- }
- public int getPromotion() {
- return this.promotion;
- }
- public int[] getCoordinates() {
- return new int[]{this.from_x, this.from_y, this.to_x, this.to_y};
- }
- public void setAlgebraicNotaion(boolean algebraic) {
- algebraic = algebraic;
- }
- public String toString() {
- String note = "";
- String[] letters;
- if (algebraic) {
- switch(this.board.board[this.from_x][this.from_y]) {
- case -6:
- note = note + "K";
- break;
- case -5:
- note = note + "Q";
- break;
- case -4:
- note = note + "R";
- break;
- case -3:
- note = note + "N";
- break;
- case -2:
- note = note + "B";
- break;
- case -1:
- note = note.makeConcatWithConstants<invokedynamic>(note);
- case 0:
- default:
- break;
- case 1:
- note = note.makeConcatWithConstants<invokedynamic>(note);
- break;
- case 2:
- note = note + "B";
- break;
- case 3:
- note = note + "N";
- break;
- case 4:
- note = note + "R";
- break;
- case 5:
- note = note + "Q";
- break;
- case 6:
- note = note + "K";
- }
- letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h"};
- if (this.board.board[this.to_x][this.to_y] != 0) {
- if (this.board.board[this.from_x][this.from_y] == 1 || this.board.board[this.from_x][this.from_y] == -1) {
- note = note + letters[this.from_y];
- }
- note = note + "x";
- }
- note = note + letters[this.to_y] + (this.to_x + 1);
- if (this.promotion == 5) {
- note = note + "Q";
- }
- if (this.promotion == 4) {
- note = note + "R";
- }
- if (this.promotion == 2) {
- note = note + "B";
- }
- if (this.promotion == 3) {
- note = note + "N";
- }
- if (this.castle == 1) {
- note = "O-O";
- }
- if (this.castle == 2) {
- note = "O-O-O";
- }
- if (this.checkmate == 1) {
- note = note + "+";
- }
- if (this.checkmate == 2) {
- note = note + "#";
- }
- } else {
- letters = new String[]{"a", "b", "c", "d", "e", "f", "g", "h"};
- note = note + letters[this.from_y] + (this.from_x + 1);
- note = note + "-";
- note = note + letters[this.to_y] + (this.to_x + 1);
- if (this.promotion == 5) {
- note = note + "Q";
- }
- if (this.promotion == 4) {
- note = note + "R";
- }
- if (this.promotion == 2) {
- note = note + "B";
- }
- if (this.promotion == 3) {
- note = note + "N";
- }
- }
- return note;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement