Merge pull request #8 from sorrelbri/patch_game_end_bug
patch game end bug
This commit is contained in:
commit
ccbeddfa40
3 changed files with 13 additions and 12 deletions
|
@ -42,8 +42,8 @@ const Board = (props) => {
|
|||
const posY = (i % boardSize) + 1;
|
||||
const pointData = board[`${posX}-${posY}`];
|
||||
const dotData =
|
||||
meta && meta.turn === 0 && !meta.winner
|
||||
? meta?.territory[`${posX}-${posY}`]
|
||||
meta && meta.turn === 0 && !meta.winner && meta.territory
|
||||
? meta.territory[`${posX}-${posY}`]
|
||||
: game.turn || meta?.turn;
|
||||
boardPoints.push(
|
||||
<Point
|
||||
|
|
|
@ -80,14 +80,9 @@ function joinRequest(state, action) {
|
|||
}
|
||||
|
||||
function updateBoard(state, action) {
|
||||
const {
|
||||
gameRecord,
|
||||
pass,
|
||||
turn,
|
||||
winner,
|
||||
playerState,
|
||||
territory,
|
||||
} = action.body.meta;
|
||||
console.log(action.body);
|
||||
const { gameRecord, pass, turn, winner, playerState } = action.body.meta;
|
||||
const territory = action.body.territory;
|
||||
return {
|
||||
...state,
|
||||
board: action.body.board,
|
||||
|
|
|
@ -103,12 +103,18 @@ io.on("connection", async (socket) => {
|
|||
const { id, room } = game;
|
||||
const gameNsp = `game${id}`;
|
||||
try {
|
||||
const { board, ...meta } = await gameServices.toggleTerritory({
|
||||
const {
|
||||
board,
|
||||
territory,
|
||||
...meta
|
||||
} = await gameServices.toggleTerritory({
|
||||
id,
|
||||
point,
|
||||
});
|
||||
socket.join(gameNsp, () => {
|
||||
io.of(room).to(gameNsp).emit("update_board", { board, meta });
|
||||
io.of(room)
|
||||
.to(gameNsp)
|
||||
.emit("update_board", { board, territory, meta });
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
|
Loading…
Reference in a new issue