Commit 67380b70 authored by Omid Sayfun's avatar Omid Sayfun

Pawn Cross Bug Fixed

parent cdc2a620
*.iml *.iml
.idea .idea
*.class *.class
out
out/* out/*
out/**
...@@ -476,9 +476,27 @@ public class Board{ ...@@ -476,9 +476,27 @@ public class Board{
}else{ }else{
if( found.canMove(x, y) ){ // Check if move is valid if( found.canMove(x, y) ){ // Check if move is valid
if( found.checkWay(this.allPieces, x, y) ){ if( found.checkWay(this.allPieces, x, y) ){
if( (found instanceof Pawn) && found.crossMove(x, y) && attack == null ){ if( (found instanceof Pawn) && found.crossMove(x, y) ){
return false; if( attack == null ){
return false;
}else{
if( y == attack.getY() && x == attack.getX() ){
if( found.color && y < found.getY() ){
return true;
}else if( !found.color && found.getY() < y ){
return true;
}else{
return false;
}
}else{
return false;
}
}
}else if( (found instanceof Pawn) && attack != null && found.getX() - attack.getX() == 0 ){ }else if( (found instanceof Pawn) && attack != null && found.getX() - attack.getX() == 0 ){
return false; return false;
...@@ -532,9 +550,27 @@ public class Board{ ...@@ -532,9 +550,27 @@ public class Board{
}else{ }else{
if( found.canMove(toArray[1], toArray[0] - '0') ){ // Check if move is valid if( found.canMove(toArray[1], toArray[0] - '0') ){ // Check if move is valid
if( found.checkWay(this.allPieces, toArray[1], toArray[0] - '0') ){ if( found.checkWay(this.allPieces, toArray[1], toArray[0] - '0') ){
if( (found instanceof Pawn) && found.crossMove(toArray[1], toArray[0] - '0') && attack == null ){ if( (found instanceof Pawn) && found.crossMove(toArray[1], toArray[0] - '0') ){
return false; if( attack == null ){
return false;
}else{
if( toArray[0] - '0' == attack.getY() && toArray[1] == attack.getX() ){
if( found.color && toArray[0] < fromArray[0] ){
return true;
}else if( !found.color && fromArray[0] < toArray[0] ){
return true;
}else{
return false;
}
}else{
return false;
}
}
}else if( (found instanceof Pawn) && toArray[1] - fromArray[1] == 0 && attack != null){ }else if( (found instanceof Pawn) && toArray[1] - fromArray[1] == 0 && attack != null){
return false; return false;
......
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