limit piece matrix to their minimum size
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2023-05-10 22:49:29 +02:00
parent 8ec5a622d8
commit 90d6d47cc8
5 changed files with 85 additions and 7 deletions

View File

@ -55,6 +55,8 @@ public class Piece extends Shape{
*/
public void RotateRight(int times){
while(times > 0) {
height = matrix.length;
width = matrix[0].length;
boolean[][] temp_matrix = new boolean[width][height];
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
@ -70,9 +72,10 @@ public class Piece extends Shape{
public boolean equals(Object obj) {
if(obj instanceof Piece){
Piece pieceObj = (Piece) obj;
if( pieceObj.getPosition().equals(this.getPosition()) && pieceObj.getShape().equals(getShape())) {
return true;
if (pieceObj.getPosition() != null && this.getPosition() != null){
return pieceObj.getPosition().equals(this.getPosition()) && pieceObj.getShape().equals(getShape());
}
return pieceObj.getShape().equals(getShape());
}
return false;
}