Bug 742 - Wrong pawn movement, pawn can move up two boxes after it has already moved
Summary: Wrong pawn movement, pawn can move up two boxes after it has already moved
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 14:04 HKT by gsalter2-c
Modified: 2022-11-28 15:43 HKT (History)
1 user (show)

See Also:


Attachments
Wrong pawn movement, pawn can move up two boxes after it has already moved (47.74 KB, image/png)
2022-11-28 14:04 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:04:20 HKT
Created attachment 137 [details]
Wrong pawn movement, pawn can move up two boxes after it has already moved

Steps to reproduce:
1. Run App.java
2. Make the following moves: 1. d3 kf6 2. d5

Expected result:
The last move d5 should be invalid because pawn has already moved, so it is not allowed to move 2 boxes up.

Actual result:
The move is allowed and the pawn moves to d5.
Comment 1 jtoromano2-c 2022-11-28 15:42:31 HKT
Reason:
function hasMoved didn't work. When pawn moves by 1 square up, hasMoved function doesn't update.

Resolution:
Changing part of the code where pawn is moving by one square. I have updated the function hasMoved inside the pawn movement logic so it correctly updates if pawn has moved.

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