Bug 746

Summary: Pawn can move past another piece
Product: Chess Game - Group 24 Reporter: gsalter2-c
Component: PiecesAssignee: jtoromano2-c
Status: RESOLVED FIXED    
Severity: major CC: gsalter2-c
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Mac OS   
Attachments: Pawn can move past another piece

Description gsalter2-c 2022-11-28 15:21:56 HKT
Created attachment 141 [details]
Pawn can move past another piece

Steps to reproduce:
1. Run App.java
2. Make the following moves:
   1. e4 e6 2. d4 e5 3. f4 e3

On the last move, e3, pawn is attempting to move up 2 pieces, and jump over another piece.

Expected result:
Move is invalid and therefore not executed.

Actual result:
Move is recognized as valid and executed.
Comment 1 jtoromano2-c 2022-11-28 16:12:56 HKT
Reason:
This bug was happening in one special case. Namely, pawn wants to go 2 squares up, but there is a piece which is one square up. Reason was that we forgot to test that there is no piece on one position up from the pawn. 

Resolution:

In case when pawn tries to move two squares up, I added condition that there is no piece one square above the pawn. 

Line 38 of the fix.

https://github.com/glennsalter/cs3343-chess/commit/861dd141580fa489c0ff3f64b749e1ebc0653a36