Updated the server.js
This commit is contained in:
parent
b6c72a2a68
commit
33199439ab
@ -116,6 +116,11 @@ io.on("connection", (socket) => {
|
|||||||
socket.on("UPDATE_CAPITAL", (data, callback = () => {}) => {
|
socket.on("UPDATE_CAPITAL", (data, callback = () => {}) => {
|
||||||
const {id, capital} = data;
|
const {id, capital} = data;
|
||||||
|
|
||||||
|
if (rooms[getRoomCodeBySocketId(socket.id)].host !== socket.id) {
|
||||||
|
callback(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!id || capital === undefined) {
|
if (!id || capital === undefined) {
|
||||||
callback(false);
|
callback(false);
|
||||||
return;
|
return;
|
||||||
@ -125,7 +130,11 @@ io.on("connection", (socket) => {
|
|||||||
|
|
||||||
if (capital < 5000) {
|
if (capital < 5000) {
|
||||||
socket.emit("LEFT", {id: socket.id});
|
socket.emit("LEFT", {id: socket.id});
|
||||||
io.sockets.sockets.get(id).disconnect();
|
|
||||||
|
rooms[getRoomCodeBySocketId(socket.id)].players = rooms[getRoomCodeBySocketId(socket.id)].players
|
||||||
|
.filter((player) => player.id !== socket.id);
|
||||||
|
|
||||||
|
io.to(id).emit("GAME_OVER");
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(true);
|
callback(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user