Skip to content

Commit

Permalink
Fix bug with cell selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ezemtsov committed Jul 3, 2019
1 parent e40fd97 commit 4bc2bc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/TypesGameOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand All @@ -124,7 +116,6 @@ class Game {
};
};


//--------------------------------------------------
// NETWORK FUNCTIONS

Expand Down

0 comments on commit 4bc2bc8

Please sign in to comment.