diff --git a/src/TypesGameOutput.hs b/src/TypesGameOutput.hs index 096594c..e894a91 100644 --- a/src/TypesGameOutput.hs +++ b/src/TypesGameOutput.hs @@ -12,10 +12,10 @@ import qualified TypesGame as TG data Message = Connected Data | Disconnected Data - | Win Data | SetSession Data | SetHistory Data | Move Data + | Win Data | Clean deriving (Generic, Show) instance ToJSON Message where diff --git a/web/index.js b/web/index.js index fa60283..4c7c755 100644 --- a/web/index.js +++ b/web/index.js @@ -32,21 +32,11 @@ class Game { removeFromPlayerList(player); } selectCell(row, col) { - let move = { - coord: { - row: row, - col: col - }, - value: this.selectedToken - }; - if (this.history.some( v => v.coord.row == row && v.coord.col == col)) { console.log('Cell is occupied'); } else { console.log('Clicked on:', row, col); - unfocusCell(this.lastMove); - this.history.push(move); sendMessage( this.socket, this.session(), @@ -98,6 +88,8 @@ class Game { game.forgetPlayer(data.Player); break; case 'Move': + unfocusCell(game.lastMove); + game.history.push(data.Cell); fillCell(data.Cell); focusCell(data.Cell); break; @@ -124,7 +116,6 @@ class Game { }; }; - //-------------------------------------------------- // NETWORK FUNCTIONS