Skip to content

Commit

Permalink
feat: move buttons to current player
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperwyczawski committed Aug 9, 2024
1 parent 242b3d8 commit e3efac1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion play.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ a.button {
#player-buttons {
padding: .6rem;
position: absolute;
top: 2.6rem;
display: flex;
width: 100%;
justify-content: center;
Expand All @@ -240,6 +239,16 @@ a.button {
& button {
background-color: var(--square-light);
}

/* TODO: animate when entering */

&.white {
top: 2.6rem;
}

&.black {
bottom: 2.6rem;
}
}

#castle-menu {
Expand Down
2 changes: 1 addition & 1 deletion play.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Pieces: <span class="pieces">0</span>/<span class="max-pieces">0</span>
Gold: <span class="gold">0</span>/+<span class="gold-per-turn">0</span>
</div>
<div id="player-buttons">
<div id="player-buttons" class="white">
<button id="skip-turn">
Skip turn
</button>
Expand Down
6 changes: 6 additions & 0 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export class Game {
#isTutorial;
#tutorial = new Tutorial();
#HTMLGameOverDialog;
#HTMLPlayerButtons;

constructor(HTMLTable: HTMLTableElement, tutorial: boolean) {
this.#HTMLGameOverDialog = q("#game-over") as HTMLDialogElement;
this.#HTMLPlayerButtons = q("#player-buttons");
this.#isTutorial = tutorial;
this.#board = new Board(
HTMLTable,
Expand Down Expand Up @@ -114,6 +116,10 @@ export class Game {
this.#currentPlayerIndex = (this.#currentPlayerIndex + 1) % 2;
this.#currentPlayer.activate();

for (const player of this.#players) {
this.#HTMLPlayerButtons.classList.toggle(player.color)
}

this.#deselectAndUnhighlightCells();

for (const cell of this.#board.cellsFlat.filter(
Expand Down

0 comments on commit e3efac1

Please sign in to comment.