ecattez / shahmat

A Chess implementation with the Domain Driven Design
https://ecattez.github.io/shahmat/
GNU General Public License v3.0
3 stars 0 forks source link

Feature: Pawn #1

Closed ecattez closed 4 years ago

ecattez commented 4 years ago

Feature: Pawn

Scenario: Pawn can only move directly forward one square

GIVEN a <color> pawn in <from>
AND <to> is vacant
WHEN the pawn is moved forward
THEN the pawn is in <to>

Example:
    | color | from | to |
    | WHITE | A2 | A3 |
    | BLACK | A7 | A6

Scenario: Pawn is stuck when the square is not vacant

GIVEN a <color> pawn in <from>
AND <to> is not vacant
WHEN the pawn is moved forward
THEN the pawn stays in <from>

Example:
    | color | from | to |
    | WHITE | A2 | A3 |
    | BLACK | A7 | A6

Scenario: Pawn can move directly forward two squares on their first move only

GIVEN a <color> pawn in <from>
AND <forward> is vacant
AND <to> is vacant
WHEN the pawn is moved forward two squares
THEN the pawn is in <to>

Example:
    | color | from | forward | to |
    | WHITE | A2 | A3 | A4 |
    | WHITE | B2 | B3 | B4 |
    | WHITE | C2 | C3 | C4 |
    | WHITE | D2 | D3 | D4 |
    | WHITE | E2 | E3 | E4 |
    | WHITE | F2 | F3 | F4 |
    | WHITE | G2 | G3 | G4 |
    | WHITE | H2 | H3 | H4 |
    | BLACK | A7 | A6 | A5 |
    | BLACK | B7 | B6 | B5 |
    | BLACK | C7 | C6 | C5 |
    | BLACK | D7 | D6 | D5 |
    | BLACK | E7 | E6 | E5 |
    | BLACK | F7 | F6 | F5 |
    | BLACK | G7 | G6 | G5 |
    | BLACK | H7 | H6 | H5 |

Scenario: Pawn can move diagonally forward when capturing an opposing piece

GIVEN a <color> pawn in <from>
AND an opposing piece in <opponent-location>
WHEN the pawn is moved to <opponent-location>
THEN the pawn captures the opposing piece

Example:
    | color | from | opponent-location |
    | WHITE | B3 | A4 |
    | WHITE | B3 | C4 |
    | BLACK | B5 | C4 |
    | BLACK | B5 | A4 |
ThomasFerro commented 4 years ago

One gherkin is missing, the en passant rules are not described: https://en.wikipedia.org/wiki/En_passant

ecattez commented 4 years ago

"En passant" is an other feature. I add it in the board.