corrected code
This commit is contained in:
parent
9b93fe4081
commit
955fa918db
|
|
@ -111,3 +111,5 @@ public class Game extends Thread {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +1,31 @@
|
|||
// src/backend/Move.java
|
||||
// Move.java
|
||||
package backend;
|
||||
|
||||
public class Move {
|
||||
private final int fromX, fromY, toX, toY;
|
||||
private final boolean white;
|
||||
private final PieceType type;
|
||||
private final PieceType promotion; // null if none
|
||||
private int fromX, fromY, toX, toY;
|
||||
private boolean isWhite;
|
||||
private PieceType type;
|
||||
private Piece capturedPiece;
|
||||
|
||||
public Move(int fromX, int fromY, int toX, int toY,
|
||||
boolean white, PieceType type, PieceType promotion) {
|
||||
this.fromX = fromX;
|
||||
this.fromY = fromY;
|
||||
this.toX = toX;
|
||||
this.toY = toY;
|
||||
this.white = white;
|
||||
this.type = type;
|
||||
this.promotion= promotion;
|
||||
boolean isWhite, PieceType type, Piece captured) {
|
||||
this.fromX = fromX;
|
||||
this.fromY = fromY;
|
||||
this.toX = toX;
|
||||
this.toY = toY;
|
||||
this.isWhite = isWhite;
|
||||
this.type = type;
|
||||
this.capturedPiece = captured;
|
||||
}
|
||||
|
||||
public int getFromX() { return fromX; }
|
||||
public int getFromY() { return fromY; }
|
||||
public int getToX() { return toX; }
|
||||
public int getToY() { return toY; }
|
||||
public boolean isWhite() { return white; }
|
||||
public PieceType getType() { return type; }
|
||||
public PieceType getPromotion() { return promotion; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Move)) return false;
|
||||
Move m = (Move)o;
|
||||
return fromX==m.fromX && fromY==m.fromY
|
||||
&& toX==m.toX && toY==m.toY
|
||||
&& white==m.white && type==m.type;
|
||||
}
|
||||
@Override public int hashCode() { return fromX*31+fromY*7+toX*13+toY; }
|
||||
public int getFromX() { return fromX; }
|
||||
public int getFromY() { return fromY; }
|
||||
public int getToX() { return toX; }
|
||||
public int getToY() { return toY; }
|
||||
public boolean isWhite() { return isWhite; }
|
||||
public PieceType getType() { return type; }
|
||||
public Piece getCapturedPiece() { return capturedPiece; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,5 +29,4 @@ public class Piece {
|
|||
public boolean isWhite() {
|
||||
return isWhite;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue