|
|
@ -1,6 +1,6 @@ |
|
|
|
import { BoardgameState } from "../../shared/boardgame-state.ts"; |
|
|
|
import { BoardgameState } from "../../shared/boardgame-state.ts"; |
|
|
|
import { getTargetGameState } from "../../shared/boardgame.ts"; |
|
|
|
import { getTargetGameState } from "../../shared/boardgame.ts"; |
|
|
|
import { CurrentOutcome } from "../../shared/datatypes.ts"; |
|
|
|
import { CurrentOutcome, Player } from "../../shared/datatypes.ts"; |
|
|
|
import { getCellDisplayData, getDisplayStates } from "../../shared/display.ts"; |
|
|
|
import { getCellDisplayData, getDisplayStates } from "../../shared/display.ts"; |
|
|
|
import { gamesRules } from "../../shared/rules.ts"; |
|
|
|
import { gamesRules } from "../../shared/rules.ts"; |
|
|
|
import { replaceLocation } from "../lib/navigation-utils.ts"; |
|
|
|
import { replaceLocation } from "../lib/navigation-utils.ts"; |
|
|
@ -33,6 +33,32 @@ export class BoardGameComponent extends HTMLElement { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const playerNameElement of this.querySelectorAll(".current-player-name")) { |
|
|
|
|
|
|
|
if ((playerNameElement as HTMLElement).innerText !== gameState.currentPlayerName) { |
|
|
|
|
|
|
|
(playerNameElement as HTMLElement).innerText = gameState.currentPlayerName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const button of this.querySelectorAll("button.autoplayer-x-enable")) { |
|
|
|
|
|
|
|
(button as HTMLButtonElement).value = gameState.withAutoPlayer(Player.X).serialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const button of this.querySelectorAll("button.autoplayer-x-disable")) { |
|
|
|
|
|
|
|
(button as HTMLButtonElement).value = gameState.withoutAutoPlayer(Player.X).serialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const button of this.querySelectorAll("button.autoplayer-o-enable")) { |
|
|
|
|
|
|
|
(button as HTMLButtonElement).value = gameState.withAutoPlayer(Player.O).serialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const button of this.querySelectorAll("button.autoplayer-o-disable")) { |
|
|
|
|
|
|
|
(button as HTMLButtonElement).value = gameState.withoutAutoPlayer(Player.O).serialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const button of this.querySelectorAll("button.game-start")) { |
|
|
|
|
|
|
|
(button as HTMLButtonElement).value = gameState.withEmptyBoard().serialize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 rowNumber = 0; rowNumber < tbody.rows.length; rowNumber++) { |
|
|
|
for (let rowNumber = 0; rowNumber < tbody.rows.length; rowNumber++) { |
|
|
|