Bug 744 - Pawn can eat pieces in front of it
Summary: Pawn can eat pieces in front of it
Status: RESOLVED FIXED
Alias: None
Product: Chess Game - Group 24
Classification: Unclassified
Component: Chess (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- major
Assignee: jtoromano2-c
URL:
Depends on:
Blocks:
 
Reported: 2022-11-28 14:54 HKT by gsalter2-c
Modified: 2022-11-28 16:09 HKT (History)
1 user (show)

See Also:


Attachments
Pawn can eat pieces in front of it (45.09 KB, image/png)
2022-11-28 14:54 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 14:54:12 HKT
Created attachment 139 [details]
Pawn can eat pieces in front of it

Steps to reproduce:
1. Run App.java
2. Execute the following moves: 1. d4 d5 2. dxd5

In the last move, dxd5, white pawn attempts to eat black pawn 1 box in front of it, which is invalid.

Expected results:
Move is invalid, therefore not executed.

Actual resutls:
Move is counted as valid and executed.
Comment 1 jtoromano2-c 2022-11-28 16:09:20 HKT
Reason:

Square where pawn wants to move shouldn't have piece, otherwise, move is not valid. We forgot to test that condition initially. 


Resolution:

Adding condition to check if final point where pawn wants to move already has piece. If that is true, move is invalid.

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