|
|
@ -49,11 +49,11 @@ export class BoardGameComponent extends HTMLElement { |
|
|
|
for (const tbodyUntyped of this.querySelectorAll("tbody.game-board")) { |
|
|
|
for (const tbodyUntyped of this.querySelectorAll("tbody.game-board")) { |
|
|
|
const tbody = tbodyUntyped as HTMLTableSectionElement; |
|
|
|
const tbody = tbodyUntyped as HTMLTableSectionElement; |
|
|
|
|
|
|
|
|
|
|
|
for (let rowNumberToRemove = gameState.rows; rowNumberToRemove < tbody.rows.length; rowNumberToRemove++) { |
|
|
|
while (gameState.rows < tbody.rows.length) { |
|
|
|
tbody.rows[rowNumberToRemove]?.remove(); |
|
|
|
tbody.rows[0]?.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (let rowNumberToAdd = tbody.rows.length; rowNumberToAdd < gameState.rows; rowNumberToAdd++) { |
|
|
|
while (gameState.rows > tbody.rows.length) { |
|
|
|
tbody.insertRow(); |
|
|
|
tbody.insertRow(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -63,15 +63,11 @@ export class BoardGameComponent extends HTMLElement { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for ( |
|
|
|
while (gameState.columns < row.cells.length) { |
|
|
|
let columnNumberToRemove = gameState.columns; |
|
|
|
row.cells[0]?.remove(); |
|
|
|
columnNumberToRemove < row.cells.length; |
|
|
|
|
|
|
|
columnNumberToRemove++ |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
row.cells[columnNumberToRemove]?.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (let columnNumberToAdd = row.cells.length; columnNumberToAdd < gameState.columns; columnNumberToAdd++) { |
|
|
|
while (gameState.columns > row.cells.length) { |
|
|
|
row.insertCell(); |
|
|
|
row.insertCell(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|