formatage

This commit is contained in:
Mathieu Oriol
2024-09-09 17:01:26 +02:00
parent d6cf0e8d60
commit f0285e2873
5 changed files with 21 additions and 21 deletions

View File

@@ -73,10 +73,10 @@ export function initAdminSocketHandler() {
socket.emit("error", "Not logged in"); socket.emit("error", "Not logged in");
return; return;
} }
if(!game.changeSettings(settings)) { if (!game.changeSettings(settings)) {
socket.emit("error", "Invalid settings"); socket.emit("error", "Invalid settings");
} }
secureAdminBroadcast("game_settings",game.settings); secureAdminBroadcast("game_settings", game.settings);
playersBroadcast("game_settings", game.settings); playersBroadcast("game_settings", game.settings);
}) })
@@ -99,10 +99,10 @@ export function initAdminSocketHandler() {
socket.emit("error", "Not logged in"); socket.emit("error", "Not logged in");
return; return;
} }
if(!penaltyController.updateSettings(settings)) { if (!penaltyController.updateSettings(settings)) {
socket.emit("error", "Invalid settings"); socket.emit("error", "Invalid settings");
socket.emit("penalty_settings", penaltyController.settings) socket.emit("penalty_settings", penaltyController.settings)
}else { } else {
secureAdminBroadcast("penalty_settings", penaltyController.settings) secureAdminBroadcast("penalty_settings", penaltyController.settings)
} }

View File

@@ -20,11 +20,11 @@ export const GameState = {
export default { export default {
//List of teams, as objects. To see the fields see the addTeam methods //List of teams, as objects. To see the fields see the addTeam methods
teams : [], teams: [],
//Current state of the game //Current state of the game
state : GameState.SETUP, state: GameState.SETUP,
//Settings of the game //Settings of the game
settings : { settings: {
loserEndGameMessage: "", loserEndGameMessage: "",
winnerEndGameMessage: "", winnerEndGameMessage: "",
capturedMessage: "", capturedMessage: "",
@@ -37,7 +37,7 @@ export default {
* @returns true if the settings are applied * @returns true if the settings are applied
*/ */
changeSettings(newSettings) { changeSettings(newSettings) {
this.settings = {...this.settings, ...newSettings}; this.settings = { ...this.settings, ...newSettings };
return true; return true;
}, },
@@ -232,7 +232,7 @@ export default {
} }
//The location sent by the team will be null if the browser call API dooes not succeed //The location sent by the team will be null if the browser call API dooes not succeed
//See issue #19 //See issue #19
if(location == null) { if (location == null) {
return false; return false;
} }
team.currentLocation = location; team.currentLocation = location;
@@ -264,7 +264,7 @@ export default {
if (team == undefined) { if (team == undefined) {
return false; return false;
} }
if(team.currentLocation == null) { if (team.currentLocation == null) {
return false; return false;
} }

View File

@@ -4,7 +4,7 @@ This module manages the verification of the game rules and the penalties.
import { isInCircle } from "./map_utils.js"; import { isInCircle } from "./map_utils.js";
import { sendUpdatedTeamInformations, teamBroadcast } from "./team_socket.js"; import { sendUpdatedTeamInformations, teamBroadcast } from "./team_socket.js";
import { secureAdminBroadcast } from "./admin_socket.js"; import { secureAdminBroadcast } from "./admin_socket.js";
import game, {GameState} from "./game.js"; import game, { GameState } from "./game.js";
import zone from "./zone_manager.js"; import zone from "./zone_manager.js";
export default { export default {

View File

@@ -4,7 +4,7 @@ It receives messages, checks permissions, manages authentication and performs ac
This module also exposes functions to send messages via socket to all teams This module also exposes functions to send messages via socket to all teams
*/ */
import { secureAdminBroadcast } from "./admin_socket.js"; import { secureAdminBroadcast } from "./admin_socket.js";
import { io} from "./index.js"; import { io } from "./index.js";
import game from "./game.js"; import game from "./game.js";
import zone from "./zone_manager.js"; import zone from "./zone_manager.js";
@@ -43,7 +43,7 @@ function logoutPlayer(id) {
export function sendUpdatedTeamInformations(teamId) { export function sendUpdatedTeamInformations(teamId) {
let team = game.getTeam(teamId) let team = game.getTeam(teamId)
if(!team) { if (!team) {
return false; return false;
} }
team.sockets.forEach(socketId => { team.sockets.forEach(socketId => {
@@ -106,7 +106,7 @@ export function initTeamSocket() {
return; return;
} }
let team = game.getTeam(teamId) let team = game.getTeam(teamId)
if(team == undefined) { if (team == undefined) {
logoutPlayer(socket.id); logoutPlayer(socket.id);
return; return;
} }
@@ -125,8 +125,8 @@ export function initTeamSocket() {
return; return;
} }
game.updateTeamChasing(); game.updateTeamChasing();
teamBroadcast(teamId, "update_team", { enemyLocation: team.enemyLocation,locationSendDeadline: team.locationSendDeadline }); teamBroadcast(teamId, "update_team", { enemyLocation: team.enemyLocation, locationSendDeadline: team.locationSendDeadline });
teamBroadcast(teamId,"success", "Position udpated") teamBroadcast(teamId, "success", "Position udpated")
secureAdminBroadcast("teams", game.teams) secureAdminBroadcast("teams", game.teams)
}); });