Correct pawn movement
This commit is contained in:
parent
63dba59d25
commit
7041543bd0
19
src/index.js
19
src/index.js
|
@ -188,16 +188,17 @@ class Board extends React.Component {
|
||||||
let shift = pieceIsBlack ? -1 : 1;
|
let shift = pieceIsBlack ? -1 : 1;
|
||||||
let startLine = pieceIsBlack ? 6 : 1;
|
let startLine = pieceIsBlack ? 6 : 1;
|
||||||
|
|
||||||
if (y === startLine) {
|
if (this.squareAt(x, y + shift) == null) {
|
||||||
return [
|
moves.push([x, y + shift]);
|
||||||
[x, y + shift],
|
if (y === startLine && this.squareAt(x, y + (shift * 2)) == null) {
|
||||||
[x, y + (shift * 2)],
|
moves.push([x, y + (shift * 2)]);
|
||||||
];
|
|
||||||
} else {
|
|
||||||
return [
|
|
||||||
[x, y + shift],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
[x + 1, x - 1].forEach((x) => {
|
||||||
|
if (this.isEnemyOf(piece, x, y + shift)) {
|
||||||
|
moves.push([x, y + shift]);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (isRook(piece)) {
|
} else if (isRook(piece)) {
|
||||||
// Down
|
// Down
|
||||||
for (i = y + 1; i < 8; i++) {
|
for (i = y + 1; i < 8; i++) {
|
||||||
|
|
Loading…
Reference in New Issue