Commit 396290a7 authored by Omid Sayfun's avatar Omid Sayfun

Possible fix for Queen move

parent 59b24e08
...@@ -23,8 +23,16 @@ public class Bishop extends Piece{ ...@@ -23,8 +23,16 @@ public class Bishop extends Piece{
} }
public boolean checkWay(ArrayList<Piece> pieces, char x, int y){ public boolean checkWay(ArrayList<Piece> pieces, char x, int y){
int xShift = (x - this.x) / Math.abs(x - this.x);; int xShift = 0;
int yShift = (y - this.y) / Math.abs(y - this.y); int yShift = 0;
if( this.x - x != 0 ){
xShift = (x - this.x) / Math.abs(x - this.x);
}
if( this.y - y != 0 ){
yShift = (y - this.y) / Math.abs(y - this.y);
}
int i = 1; int i = 1;
while( x != (char)(this.x + i * xShift) && y != this.y + i * yShift ){ while( x != (char)(this.x + i * xShift) && y != this.y + i * yShift ){
if( checkTaken(pieces, (char)(this.x + i * xShift), this.y + i * yShift) ){ if( checkTaken(pieces, (char)(this.x + i * xShift), this.y + i * yShift) ){
......
...@@ -33,10 +33,10 @@ public class Board{ ...@@ -33,10 +33,10 @@ public class Board{
this.whitePieces.add(newBishop); this.whitePieces.add(newBishop);
} }
// Queen // Queen
Queen whiteQueen = new Queen('E', 1, true, "WQ"); Queen whiteQueen = new Queen('D', 1, true,"WQ");
this.whitePieces.add(whiteQueen); this.whitePieces.add(whiteQueen);
// King // King
King whiteKing = new King('D', 1, true, "WK"); King whiteKing = new King('E', 1, true, "WK");
this.whitePieces.add(whiteKing); this.whitePieces.add(whiteKing);
// Black Players // Black Players
// Pawns // Pawns
...@@ -60,10 +60,10 @@ public class Board{ ...@@ -60,10 +60,10 @@ public class Board{
this.blackPieces.add(newBishop); this.blackPieces.add(newBishop);
} }
// Queen // Queen
Queen blackQueen = new Queen('E', 8, false, "BQ"); Queen blackQueen = new Queen('D', 8, false, "BQ");
this.blackPieces.add(blackQueen); this.blackPieces.add(blackQueen);
// King // King
King blackKing = new King('D', 8, false, "BK"); King blackKing = new King('E', 8, false, "BK");
this.blackPieces.add(blackKing); this.blackPieces.add(blackKing);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment