send zone info on socket connexion

This commit is contained in:
2024-04-20 12:58:53 +00:00
parent 6393ee12dc
commit 64748d26b3
3 changed files with 20 additions and 0 deletions

View File

@@ -46,6 +46,11 @@ export function initAdminSocketHandler() {
socket.emit("game_state", game.state) socket.emit("game_state", game.state)
//Other settings that need initialization //Other settings that need initialization
socket.emit("zone_settings", game.zone.zoneSettings) socket.emit("zone_settings", game.zone.zoneSettings)
socket.emit("zone", game.zone.currentZone)
socket.emit("new_zone", {
begin: game.zone.currentStartZone,
end: game.zone.nextZone
})
} else { } else {
//Attempt unsuccessful //Attempt unsuccessful

View File

@@ -1,3 +1,4 @@
import { secureAdminBroadcast } from "./admin_socket.js";
import { penaltyController } from "./index.js"; import { penaltyController } from "./index.js";
import { isInCircle } from "./map_utils.js"; import { isInCircle } from "./map_utils.js";
import { playersBroadcast, sendUpdatedTeamInformations } from "./team_socket.js"; import { playersBroadcast, sendUpdatedTeamInformations } from "./team_socket.js";
@@ -38,6 +39,14 @@ export default class Game {
this.zone.reset(); this.zone.reset();
penaltyController.stop(); penaltyController.stop();
} }
//Game reset
if(newState == GameState.SETUP) {
for(let team of this.teams) {
team.penalties = 0;
team.captured = false;
}
this.updateTeamChasing();
}
this.state = newState; this.state = newState;
return true; return true;
} }
@@ -111,6 +120,7 @@ export default class Game {
this.getTeam(firstTeam).chased = previousTeam; this.getTeam(firstTeam).chased = previousTeam;
this.getTeam(previousTeam).chasing = firstTeam; this.getTeam(previousTeam).chasing = firstTeam;
this.getTeam(previousTeam).enemyName = this.getTeam(firstTeam).name; this.getTeam(previousTeam).enemyName = this.getTeam(firstTeam).name;
secureAdminBroadcast("teams", this.teams)
return true; return true;
} }

View File

@@ -75,6 +75,11 @@ export function initTeamSocket() {
sendUpdatedTeamInformations(loginTeamId); sendUpdatedTeamInformations(loginTeamId);
socket.emit("login_response", true); socket.emit("login_response", true);
socket.emit("game_state", game.state) socket.emit("game_state", game.state)
socket.emit("zone", game.zone.currentZone)
socket.emit("new_zone", {
begin: game.zone.currentStartZone,
end: game.zone.nextZone
})
}); });
socket.on("logout", () => { socket.on("logout", () => {