Closed ecattez closed 4 years ago
Feature: Promotion (rewritten)
Scenario: A pawn must be promoted when it reaches the other side of the chess board
GIVEN a <color> pawn in the penultimate rank (<penultimate-rank>)
WHEN the pawn reaches the other side of the chess board (<last-rank>)
AND the pawn's owner does not promote the pawn
THEN the move is refused because promotion must be done
Example:
| color | penultimate-rank | last-rank |
| WHITE | 7 | 8 |
| BLACK | 2 | 1 |
Scenario: A pawn can not be promoted for pawn nor a king
GIVEN a <color> pawn in the penultimate rank (<penultimate-rank>)
WHEN the pawn reaches the other side of the chess board (<last-rank>)
AND the pawn's owner has chosen to promote it with a <promotion-type>
THEN the promotion is refused because <promotion-type> can not promote
Example:
| color | penultimate-rank | last-rank | promotion-type |
| WHITE | 7 | 8 | KING |
| WHITE | 7 | 8 | PAWN |
| BLACK | 2 | 1 | KING |
| BLACK | 2 | 1 | PAWN |
Scenario: A pawn may be promoted for a queen, a rook, a bishop or a knight
GIVEN a <color> pawn in the penultimate rank (<penultimate-rank>)
WHEN the pawn reaches the other side of the chess board (<last-rank>)
AND the pawn's owner has chosen to promote it with a <promotion-type>
THEN a <promotion-type> of the same color replaces the pawn
Example:
| color | penultimate-rank | last-rank | promotion-type |
| WHITE | 7 | 8 | QUEEN |
| WHITE | 7 | 8 | ROOK |
| WHITE | 7 | 8 | BISHOP |
| WHITE | 7 | 8 | KNIGHT |
| BLACK | 2 | 1 | QUEEN |
| BLACK | 2 | 1 | ROOK |
| BLACK | 2 | 1 | BISHOP |
| BLACK | 2 | 1 | KNIGHT |
Scenario: A pawn is promoted when capturing an opposing piece
GIVEN a <color> pawn in <from>
AND an opposing piece in <opponent-location>
WHEN the pawn moves to <opponent-location>
AND the pawn's owner has chosen a valid promotion type
THEN the pawn captures the opposing piece
AND the promotion piece replaces the pawn
Example:
| color | from | opponent-location |
| WHITE | B7 | A8 |
| BLACK | E2 | F1 |
Scenario: Only a pawn can be promoted
WHEN a <type> is promoted (<from> to <to>)
THEN the promotion is refused
WITH "Piece can not be promoted" as reason
Example:
| type | from | to |
| KING | B2 | A1 |
| QUEEN | A3 | A1 |
| ROOK | A3 | A1 |
| BISHOP | A3 | C1 |
| KNIGHT | D2 | F1 |
Current behavior:
Expected behavior:
Promotion is the move of a pawn from the penultimate rank (2 for black, 7 for white) to the last rank with a promotion type (queen, rook, bishop, knight).
For example, a white pawn can not move from rank 2 to 1 without specifying in witch piece it would be promoted.
So event flow would be as below :
PromotionProposed should be removed. Promotion feature should be reopened with a scenario about moving a pawn to the last rank without promoting it (should raise an error).
Promotion can also happen when capturing.