diff --git a/TableturfBattleClient/src/Board.ts b/TableturfBattleClient/src/Board.ts index 4ae425c..b780f6f 100644 --- a/TableturfBattleClient/src/Board.ts +++ b/TableturfBattleClient/src/Board.ts @@ -354,9 +354,6 @@ class Board { resize(grid?: Space[][]) { if (grid) this.grid = grid; - if (this.cells.length == this.grid.length && this.cells[0].length == this.grid[0].length) - return; // Reconnected and board size did not change. - clearChildren(this.table); this.cells.splice(0); this.highlightedCells.splice(0); @@ -387,8 +384,8 @@ class Board { if (e.pointerType != 'touch') { if (this.autoHighlight && this.cardPlaying != null) { const offset = this.rotatedMouseOffset; - const x = parseInt((e.target as HTMLTableCellElement).dataset.x!) - (this.flip ? Math.ceil(offset.x) : Math.floor(offset.x)); - const y = parseInt((e.target as HTMLTableCellElement).dataset.y!) - (this.flip ? Math.ceil(offset.y) : Math.floor(offset.y)); + const x = parseInt((e.currentTarget as HTMLTableCellElement).dataset.x!) - (this.flip ? Math.ceil(offset.x) : Math.floor(offset.x)); + const y = parseInt((e.currentTarget as HTMLTableCellElement).dataset.y!) - (this.flip ? Math.ceil(offset.y) : Math.floor(offset.y)); if (x != this.highlightX || y != this.highlightY) { this.highlightX = x; this.highlightY = y; diff --git a/TableturfBattleClient/src/Pages/GamePage.ts b/TableturfBattleClient/src/Pages/GamePage.ts index bd745eb..1d684e4 100644 --- a/TableturfBattleClient/src/Pages/GamePage.ts +++ b/TableturfBattleClient/src/Pages/GamePage.ts @@ -124,6 +124,7 @@ function initSpectator() { flipButton.hidden = false; gameButtonsContainer.hidden = false; board.autoHighlight = false; + board.flip = false; showPage('game'); } @@ -141,6 +142,7 @@ function initReplay() { flipButton.hidden = false; gameButtonsContainer.hidden = false; gamePage.dataset.myPlayerIndex = '0'; + board.flip = false; updateColours(); gamePage.dataset.uiBaseColourIsSpecialColour = (userConfig.colourLock || (currentGame!.game.players[0].uiBaseColourIsSpecialColour ?? true)).toString(); canPlay = false; @@ -157,6 +159,7 @@ function initTest(stage: Stage) { testMode = true; gamePage.classList.add('deckTest'); currentGame = { id: 'test', game: { state: GameState.Ongoing, maxPlayers: 2, players: [ ], turnNumber: 1, turnTimeLimit: null, turnTimeLeft: null, goalWinCount: null, allowUpcomingCards: true }, me: { playerIndex: 0, move: null, deck: null, hand: null, cardsUsed: [ ], stageSelectionPrompt: null }, isHost: false, webSocket: null }; + board.flip = false; board.resize(stage.copyGrid()); const startSpaces = stage.getStartSpaces(2); board.startSpaces = startSpaces; diff --git a/TableturfBattleClient/src/app.ts b/TableturfBattleClient/src/app.ts index 11c266e..ea92573 100644 --- a/TableturfBattleClient/src/app.ts +++ b/TableturfBattleClient/src/app.ts @@ -128,7 +128,7 @@ function onGameStateChange(game: any, playerData: PlayerData | null) { board.flip = playerData != null && playerData.playerIndex % 2 != 0; if (board.flip) gamePage.classList.add('boardFlipped'); else gamePage.classList.remove('boardFlipped'); - board.resize(game.board); + if (!isSameTurnReconnect) board.resize(game.board); board.startSpaces = game.startSpaces; if (!isSameTurnReconnect) board.refresh(); }