Bug 746 - Pawn can move past another piece
Summary: Pawn can move past another piece
Status: RESOLVED FIXED
Alias: None
Product: Chess Game - Group 24
Classification: Unclassified
Component: Pieces (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- major
Assignee: jtoromano2-c
URL:
Depends on:
Blocks:
 
Reported: 2022-11-28 15:21 HKT by gsalter2-c
Modified: 2022-11-28 16:12 HKT (History)
1 user (show)

See Also:


Attachments
Pawn can move past another piece (51.04 KB, image/png)
2022-11-28 15:21 HKT, gsalter2-c
Details

Note You need to log in before you can comment on or make changes to this bug.
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