Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package chess;
- public class Bishop extends Piece{
- public Bishop(PieceColour colour){
- this.colour = colour;
- if (colour == PieceColour.WHITE){
- setSymbol("\u2657");
- }
- else {
- setSymbol("\u265D");
- }
- }
- @Override
- public boolean isLegitMove(int iIn, int jIn, int iOut, int jOut){
- if (iIn==iOut || jIn==jOut){
- return false;
- }
- if (jOut-jIn == iOut-iIn){
- for(int x = jOut-jIn-1; x>0; x--){
- if (Board.getBoard()[iIn+x][jIn+x].hasPiece()){
- return false;
- }
- else{
- return true;
- }
- }
- }
- if (jIn-jOut == iOut-iIn){
- for(int x = jIn-jOut-1; x>0; x--){
- if (Board.getBoard()[iIn+x][jIn-x].hasPiece()){
- return false;
- }
- else{
- return true;
- }
- }
- }
- if (jOut-jIn == iIn-iOut){
- for(int x = jOut-jIn-1; x>0; x--){
- if (Board.getBoard()[iIn-x][jIn+x].hasPiece()){
- return false;
- }
- else{
- return true;
- }
- }
- }
- if (jIn-jOut == iIn-iOut){
- for(int x =jIn-jOut-1; x>0; x--){
- if (Board.getBoard()[iIn-x][jIn-x].hasPiece()){
- return false;
- }
- else{
- return true;
- }
- }
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment