added animated move timer

This commit is contained in:
Wenszel
2023-11-21 21:16:07 +01:00
parent e702b912f7
commit 6fef82f36a
14 changed files with 205 additions and 94 deletions
+1
View File
@@ -115,6 +115,7 @@ module.exports = (io, socket) => {
socket.join(room._id.toString());
// Sending data to the user, after which player will be redirected to the game
socket.emit('player:data', JSON.stringify(req.session));
socket.emit('room:data', JSON.stringify(updatedRoom));
});
});
}
+2
View File
@@ -27,6 +27,8 @@ module.exports = (io, socket) => {
room.players[index + 1].nowMoving = true;
}
room.nextMoveTime = Date.now() + 15000;
if (this.timeoutID) clearTimeout(this.timeoutID);
this.timeoutID = null;
RoomModel.findOneAndUpdate({ _id: req.session.roomId }, room, function (err, updatedRoom) {
io.to(req.session.roomId).emit('room:data', JSON.stringify(updatedRoom));
});
+1
View File
@@ -36,6 +36,7 @@ RoomSchema.methods.changeMovingPlayer = function () {
this.nextMoveTime = Date.now() + 15000;
this.rolledNumber = null;
if (this.timeoutID) clearTimeout(this.timeoutID);
this.timeoutID = null;
};
RoomSchema.methods.movePawn = function (pawn) {