Advertisement
umar_ahmad

pawn1.java

Feb 28th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. package chess;
  2.  
  3. public class Pawn extends Piece{
  4. public Pawn(PieceColour colour){
  5. this.colour = colour;
  6. if (colour == PieceColour.WHITE){
  7. setSymbol("\u2659");
  8. }
  9. else {
  10. setSymbol("\u265F");
  11. }
  12. }
  13.  
  14. @Override
  15. public boolean isLegitMove(int iIn, int jIn, int iOut, int jOut){
  16. if (colour == PieceColour.BLACK){
  17. if (iIn == 1 && jIn == jOut){
  18. if ((iOut - iIn) == 2);
  19. if (!Board.getBoard()[iIn + 1][jIn].hasPiece() && !Board.getBoard()[iIn + 2][jIn].hasPiece()){
  20. return true;
  21. }
  22. else{
  23. return false;
  24. }
  25. }
  26. if (iIn < 7 && jIn == jOut){
  27. if ((iOut - iIn) == 1){
  28. return true;
  29. }
  30. else{
  31. return false;
  32. }
  33. }
  34. if ((jIn - jOut) == 1 && (iOut - iIn) == 1){
  35. if (Board.getBoard()[iOut][jOut].getPiece().getColour() != this.colour){
  36. return true;
  37. }
  38. else {
  39. return false;
  40. }
  41. }
  42.  
  43. if ((jOut - jIn) == 1 && (iOut - iIn) == 1){
  44. if (Board.getBoard()[iOut][jOut].getPiece().getColour() != this.colour){
  45. return true;
  46. }
  47. else {
  48. return false;
  49. }
  50. }
  51. }
  52. else {
  53. if (iIn == 6 && jIn == jOut){
  54. if ((iIn - iOut) == 2);
  55. if (!Board.getBoard()[iIn - 1][jIn].hasPiece() && !Board.getBoard()[iIn - 2][jIn].hasPiece()){
  56. return true;
  57. }
  58. else{
  59. return false;
  60. }
  61. }
  62. if (iIn > 1 && jIn == jOut){
  63. if ((iIn - iOut) == 1){
  64. return true;
  65. }
  66. else{
  67. return false;
  68. }
  69. }
  70. if ((jIn - jOut) == 1 && (iIn - iOut) == 1){
  71. if (Board.getBoard()[iOut][jOut].getPiece().getColour() != this.colour){
  72. return true;
  73. }
  74. else {
  75. return false;
  76. }
  77. }
  78.  
  79. if ((jOut - jIn) == 1 && (iIn - iOut) == 1){
  80. if (Board.getBoard()[iOut][jOut].getPiece().getColour() != this.colour){
  81. return true;
  82. }
  83. else {
  84. return false;
  85. }
  86. }
  87. }
  88. return false;
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement