From 9e9e53c8c30c0eb6ab9b0c4ded0c0c8788a19264 Mon Sep 17 00:00:00 2001 From: hugomanipoud2 Date: Thu, 22 May 2025 16:10:23 +0200 Subject: [PATCH] pawn almost finished need some ore work --- OOP_3B5_Project/src/backend/Move.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OOP_3B5_Project/src/backend/Move.java b/OOP_3B5_Project/src/backend/Move.java index 3d7b51c..b889df5 100644 --- a/OOP_3B5_Project/src/backend/Move.java +++ b/OOP_3B5_Project/src/backend/Move.java @@ -71,12 +71,18 @@ public class Move { if (color == true) { int k = isFirstPawnMove(yCord); // determine if k should be 3 or 2 to begin with for(int i = 1; i < k;i++) { // this loop iterates from 1 to 3 as pawns for their first move can go forward 2 slots. removing 0 let the is selected function do its job - if (board.getPiece(x,y) != null) { - return false; - }else if(selectX == x && selectY == y+i) { // this loop iterates 2 times trough the for loop, giving multiples coordinates to highlight ( here : (x;y+1)&(x;y+2)) + if (board.getPiece(x,y) != null) { // if a piece of whatever color is in front + if(selectX == x+1 && selectY == y+i) { // this loop iterates i times trough the for loop, giving multiples coordinates to highlight ( here : (x;y+2) and / or (x;y+1)) + return checkColor(x, y, color); + } + if(selectX == x-1 && selectY == y+i) { // this loop iterates i times trough the for loop, giving multiples coordinates to highlight ( here : (x;y+2) and / or (x;y+1)) + return checkColor(x, y, color); + } + }else if(selectX == x && selectY == y+i) { // this loop iterates i times trough the for loop, giving multiples coordinates to highlight ( here : (x;y+2) and / or (x;y+1)) return true; } } + } else { //if color == false so for black pieces int k = isFirstPawnMove (yCord); for(int i = 1; i < k;i++) {