Skip to content

Commit

Permalink
refactor: remove useless uses of cell availability
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperwyczawski committed Aug 7, 2024
1 parent de38418 commit 2d6f799
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
14 changes: 0 additions & 14 deletions src/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export class Cell {
#owner: PlayerColor | null = null;
#piece: Piece | null = null;
#HTMLCell: HTMLTableCellElement;
#available = true;
#isHighlighted = false;

onClick: () => void = () => {};
Expand All @@ -32,9 +31,6 @@ export class Cell {
this.#HTMLCell = HTMLCell;
this.#HTMLCell.classList.add("cell");
this.#HTMLCell.addEventListener("click", () => {
if (!this.#available) {
return;
}
this.onClick();
});
this.#HTMLCell.addEventListener("contextmenu", (event) => {
Expand All @@ -56,11 +52,6 @@ export class Cell {
}
}

makeNotAvailable() {
this.#HTMLCell.classList.add("not-available");
this.#available = false;
}

handleCapture() {
if (!this.#piece) {
throw new Error("Cannot capture empty cell");
Expand All @@ -72,11 +63,6 @@ export class Cell {
this.#owner = this.#piece.color;
}

makeAvailable() {
this.#HTMLCell.classList.remove("not-available");
this.#available = true;
}

removePiece() {
this.#HTMLCell.style.setProperty("--background-image-url", "");
this.#piece = null;
Expand Down
6 changes: 0 additions & 6 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class Game {
}
this.#currentPlayer.handlePieceBuy(piece);
clickedCell.placePiece(piece);
clickedCell.makeNotAvailable();
this.#endTurn();
},
(building) => {
Expand Down Expand Up @@ -126,11 +125,6 @@ export class Game {
)) {
cell.handleCapture();
}

for (const cell of this.#board.cellsFlat) {
// TODO: this is useless, since there is only 1 action per turn
cell.makeAvailable();
}
}

get #currentPlayer() {
Expand Down

0 comments on commit 2d6f799

Please sign in to comment.