Modification des paramètres en cours de jeu + UI + corrections

This commit is contained in:
Sébastien Rivière
2025-06-20 00:21:16 +02:00
parent 4fd73a35c8
commit ab81a5351c
12 changed files with 81 additions and 51 deletions

View File

@@ -76,9 +76,11 @@ export function initAdminSocketHandler() {
}
if (!game.changeSettings(settings)) {
socket.emit("error", "Invalid settings");
socket.emit("game_settings", penaltyController.settings)
} else {
secureAdminBroadcast("game_settings", game.settings);
playersBroadcast("game_settings", game.settings);
}
secureAdminBroadcast("game_settings", game.settings);
playersBroadcast("game_settings", game.settings);
})
socket.on("set_zone_settings", (settings) => {

View File

@@ -297,7 +297,7 @@ export default {
}
this.teams = this.teams.filter(t => t.id !== teamId);
this.updateTeamChasing();
timeoutHandler.endSendPositionTimeout(team.id);
timeoutHandler.endSendPositionTimeout(teamId);
return true;
},
@@ -342,17 +342,23 @@ export default {
* @returns false if failed
*/
setZoneSettings(newSettings) {
//cannot change zones while playing
if ('min' in newSettings || 'max' in newSettings) {
const min = newSettings.min ?? zoneManager.zoneSettings.min;
const max = newSettings.max ?? zoneManager.zoneSettings.max;
// The end zone must be included in the start zone
if (!isInCircle(min.center, max.center, max.radius-min.radius)) {
return false;
}
}
zoneManager.udpateSettings(newSettings);
if (this.state == GameState.PLAYING || this.state == GameState.FINISHED) {
return false;
zoneManager.reset()
if (!zoneManager.start()) {
this.setState(GameState.SETUP);
return false;
}
}
var min = newSettings.min;
var max = newSettings.max;
// The end zone must be included in the start zone
if (!isInCircle(min.center, max.center, max.radius-min.radius)) {
return false;
}
return zoneManager.udpateSettings(newSettings);
return true;
},
/**

View File

@@ -59,8 +59,8 @@ export function initPhotoUpload() {
//App handler for serving the photo of a team given its secret ID
app.get("/photo/my", (req, res) => {
let team = game.getTeam(Number(req.query.team));
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.id.toString());
if (team) {
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.id.toString());
res.set("Content-Type", "image/png")
res.set("Access-Control-Allow-Origin", "*");
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));
@@ -71,8 +71,8 @@ export function initPhotoUpload() {
//App handler for serving the photo of the team chased by the team given by its secret ID
app.get("/photo/enemy", (req, res) => {
let team = game.getTeam(Number(req.query.team));
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.chasing.toString());
if (team) {
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.chasing.toString());
res.set("Content-Type", "image/png")
res.set("Access-Control-Allow-Origin", "*");
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));