Fixed a bug in the server.js
This commit is contained in:
parent
4e542068d2
commit
8f13c5d080
@ -125,6 +125,9 @@ io.on("connection", (socket) => {
|
|||||||
|
|
||||||
socket.on("SUBMIT", (data, callback = () => {}) => {
|
socket.on("SUBMIT", (data, callback = () => {}) => {
|
||||||
const {price, amount} = data;
|
const {price, amount} = data;
|
||||||
|
const roomCode = getRoomCodeBySocketId(socket.id);
|
||||||
|
|
||||||
|
if (!roomCode) return;
|
||||||
|
|
||||||
if (price === undefined || amount === undefined) {
|
if (price === undefined || amount === undefined) {
|
||||||
callback(false);
|
callback(false);
|
||||||
@ -144,13 +147,12 @@ io.on("connection", (socket) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (price < 0 || price > rooms[getRoomCodeBySocketId(socket.id)].settings.maxPrice ||
|
if (price < 0 || price > rooms[roomCode].settings.maxPrice ||
|
||||||
amount < 0 || amount > rooms[getRoomCodeBySocketId(socket.id)].settings.maxProduction) {
|
amount < 0 || amount > rooms[roomCode].settings.maxProduction) {
|
||||||
callback(false);
|
callback(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const roomCode = getRoomCodeBySocketId(socket.id);
|
|
||||||
const playerName = getPlayerName(socket.id, roomCode);
|
const playerName = getPlayerName(socket.id, roomCode);
|
||||||
|
|
||||||
io.to(rooms[roomCode].host).emit("RECEIVED", {id: socket.id, name: playerName, price, amount});
|
io.to(rooms[roomCode].host).emit("RECEIVED", {id: socket.id, name: playerName, price, amount});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user