added live map

This commit is contained in:
2024-06-08 08:10:27 +00:00
parent 9615d4fecd
commit 1f7df64b5f
6 changed files with 127 additions and 251 deletions

View File

@@ -1,5 +1,6 @@
import { secureAdminBroadcast } from "./admin_socket.js";
import { io, game } from "./index.js";
import { currentZone } from "./zone_manager.js";
/**
* Send a socket message to all the players of a team
@@ -8,9 +9,13 @@ import { io, game } from "./index.js";
* @param {*} data The payload
*/
export function teamBroadcast(teamId, event, data) {
if(!game.getTeam(teamId)) {
return false;
}
for (let socketId of game.getTeam(teamId).sockets) {
io.of("player").to(socketId).emit(event, data)
}
return true;
}
/**
@@ -79,11 +84,7 @@ export function initTeamSocket() {
socket.emit("login_response", true);
socket.emit("game_state", game.state)
socket.emit("game_settings", game.settings)
socket.emit("zone", game.zone.currentZone)
socket.emit("new_zone", {
begin: game.zone.currentStartZone,
end: game.zone.nextZone
})
socket.emit("zone", currentZone)
});
socket.on("logout", () => {