Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. private Stack getWhitePawnSquares(int x, int y, String piece){
  2. Stack moves = new Stack();
  3. Square startingSquare = new Square(x, y, piece);
  4. Move validM, validM2, validM3, validM4;
  5.  
  6. // For moving 2 squares when a pawn is in it's starting position
  7. for(int i=1; i < 3; i++){
  8. int tmpx = x;
  9. int tmpy = y + i;
  10. if(!(tmpy > 7)) {
  11. if (y == 1) {
  12. Square tmp = new Square(tmpx, tmpy, piece);
  13. validM = new Move(startingSquare, tmp);
  14. if (!piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  15. moves.push(validM);
  16. }
  17. }
  18. }
  19. }
  20.  
  21. //For moving one square
  22. for(int i=1; i < 2; i++){
  23. int tmpx = x;
  24. int tmpy = y + i;
  25. if(!(tmpy > 7)) {
  26. Square tmp = new Square(tmpx, tmpy, piece);
  27. validM2 = new Move(startingSquare, tmp);
  28. if (!piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  29. moves.push(validM2);
  30. }
  31. }
  32. }
  33.  
  34. //For eating pieces on X axis
  35. for(int i=1; i < 2; i++){
  36. int tmpx = x - i;
  37. int tmpy = y + i;
  38. if(!(tmpy > 7 || tmpx < 0 || tmpy > 7 || tmpy < 0)) {
  39. Square tmp = new Square(tmpx, tmpy, piece);
  40. validM3 = new Move(startingSquare, tmp);
  41. if (piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  42. if (checkWhiteOponent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  43. moves.push(validM3);
  44. }
  45. }
  46. }
  47. }
  48.  
  49. //For eating on X + Y axis diagonally
  50. for(int i=1; i < 2; i++){
  51. int tmpx = x + i;
  52. int tmpy = y + i;
  53. if(!(tmpy > 7 || tmpx < 0 || tmpy > 7 || tmpy < 0)) {
  54. Square tmp = new Square(tmpx, tmpy, piece);
  55. validM4 = new Move(startingSquare, tmp);
  56. if (piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  57. if (checkWhiteOponent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
  58. moves.push(validM4);
  59. }
  60. }
  61. }
  62. }
  63.  
  64. return moves;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement