A bit of reset() cleanup
This commit is contained in:
parent
bd8dec72d5
commit
e59e1a68f5
14
src/index.js
14
src/index.js
|
@ -62,7 +62,7 @@ function isKing(piece) {
|
||||||
|
|
||||||
function imageFromPiece(piece) {
|
function imageFromPiece(piece) {
|
||||||
if (piece) {
|
if (piece) {
|
||||||
let image = piece.color === WHITE ? piece.type : piece.type + 6;
|
const image = piece.color === WHITE ? piece.type : piece.type + 6;
|
||||||
return Images[image];
|
return Images[image];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -88,7 +88,6 @@ class Piece {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Board extends React.Component {
|
class Board extends React.Component {
|
||||||
|
@ -133,11 +132,12 @@ class Board extends React.Component {
|
||||||
new Piece(BLACK, KNIGHT),
|
new Piece(BLACK, KNIGHT),
|
||||||
new Piece(BLACK, ROOK)
|
new Piece(BLACK, ROOK)
|
||||||
];
|
];
|
||||||
let squares = whiteRow;
|
let squares = whiteRow.concat(
|
||||||
squares = squares.concat(Array(8).fill(new Piece(WHITE, PAWN)));
|
Array(8).fill(new Piece(WHITE, PAWN)),
|
||||||
squares = squares.concat(Array(32).fill(null));
|
Array(32).fill(null),
|
||||||
squares = squares.concat(Array(8).fill(new Piece(BLACK, PAWN)));
|
Array(8).fill(new Piece(BLACK, PAWN)),
|
||||||
squares = squares.concat(blackRow);
|
blackRow);
|
||||||
|
|
||||||
return squares;
|
return squares;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue