Adapt preview size to shape size

This commit is contained in:
Arnaud Vergnet 2020-07-19 10:43:46 +02:00
parent 4bff6e15a8
commit 1780ab886e
3 changed files with 7 additions and 4 deletions

View file

@ -53,8 +53,6 @@ export default class BaseShape {
/** /**
* Gets this object's current shape. * Gets this object's current shape.
*
* Used by tests to read private fields
*/ */
getCurrentShape(): Shape { getCurrentShape(): Shape {
return this.#currentShape; return this.#currentShape;

View file

@ -166,7 +166,8 @@ export default class GameLogic {
getNextPiecesPreviews() { getNextPiecesPreviews() {
let finalArray = []; let finalArray = [];
for (let i = 0; i < this.#nextPieces.length; i++) { for (let i = 0; i < this.#nextPieces.length; i++) {
finalArray.push(this.#gridManager.getEmptyGrid(4, 4)); const gridSize = this.#nextPieces[i].getCurrentShape().getCurrentShape()[0].length;
finalArray.push(this.#gridManager.getEmptyGrid(gridSize, gridSize));
this.#nextPieces[i].toGrid(finalArray[i], true); this.#nextPieces[i].toGrid(finalArray[i], true);
} }

View file

@ -165,4 +165,8 @@ export default class Piece {
getCoordinates(): Array<Coordinates> { getCoordinates(): Array<Coordinates> {
return this.#currentShape.getCellsCoordinates(true); return this.#currentShape.getCellsCoordinates(true);
} }
getCurrentShape() {
return this.#currentShape;
}
} }