Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Stack getWhitePawnSquares(int x, int y, String piece){
- Stack moves = new Stack();
- Square startingSquare = new Square(x, y, piece);
- Move validM, validM2, validM3, validM4;
- // For moving 2 squares when a pawn is in it's starting position
- for(int i=1; i < 3; i++){
- int tmpx = x;
- int tmpy = y + i;
- if(!(tmpy > 7)) {
- if (y == 1) {
- Square tmp = new Square(tmpx, tmpy, piece);
- validM = new Move(startingSquare, tmp);
- if (!piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- moves.push(validM);
- }
- }
- }
- }
- //For moving one square
- for(int i=1; i < 2; i++){
- int tmpx = x;
- int tmpy = y + i;
- if(!(tmpy > 7)) {
- Square tmp = new Square(tmpx, tmpy, piece);
- validM2 = new Move(startingSquare, tmp);
- if (!piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- moves.push(validM2);
- }
- }
- }
- //For eating pieces on X axis
- for(int i=1; i < 2; i++){
- int tmpx = x - i;
- int tmpy = y + i;
- if(!(tmpy > 7 || tmpx < 0 || tmpy > 7 || tmpy < 0)) {
- Square tmp = new Square(tmpx, tmpy, piece);
- validM3 = new Move(startingSquare, tmp);
- if (piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- if (checkWhiteOponent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- moves.push(validM3);
- }
- }
- }
- }
- //For eating on X + Y axis diagonally
- for(int i=1; i < 2; i++){
- int tmpx = x + i;
- int tmpy = y + i;
- if(!(tmpy > 7 || tmpx < 0 || tmpy > 7 || tmpy < 0)) {
- Square tmp = new Square(tmpx, tmpy, piece);
- validM4 = new Move(startingSquare, tmp);
- if (piecePresent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- if (checkWhiteOponent(((tmp.getXC() * 75) + 20), (((tmp.getYC() * 75) + 20)))) {
- moves.push(validM4);
- }
- }
- }
- }
- return moves;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement