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