fixed problems for depployment

This commit is contained in:
2024-04-24 15:50:43 +00:00
parent e592aa33cb
commit 31eb15f006
20 changed files with 254 additions and 124 deletions

View File

@@ -1,8 +1,6 @@
uploads/*
#https dev certificates
csr.pem
key.pem
server.crt
*.pem
# Logs
logs
*.log

View File

@@ -122,6 +122,7 @@ export function initAdminSocketHandler() {
}
if (game.reorderTeams(newOrder)) {
secureAdminBroadcast("teams", game.teams);
game.teams.forEach(t => sendUpdatedTeamInformations(t.id))
} else {
socket.emit("error", "Error reordering teams");
}

View File

@@ -24,6 +24,7 @@ export default class Game {
}
//The game has started
if (newState == GameState.PLAYING) {
penaltyController.start();
if (!this.zone.ready()) {
return false;
}

View File

@@ -49,7 +49,6 @@ function onUpdateZone(zone) {
export const game = new Game(onUpdateZone, onUpdateNewZone);
export const penaltyController = new PenaltyController();
penaltyController.init()
initAdminSocketHandler();

View File

@@ -14,7 +14,7 @@ export class PenaltyController {
this.checkIntervalId = null;
}
init() {
start() {
this.outOfBoundsSince = {};
if(this.checkIntervalId) {
clearInterval(this.checkIntervalId)
@@ -62,6 +62,7 @@ export class PenaltyController {
}
watchZone() {
console.log("watching zone")
this.game.teams.forEach((team) => {
if (team.captured) { return }
//All the informations are not ready yet
@@ -69,9 +70,11 @@ export class PenaltyController {
return;
}
if (!isInCircle({lat: team.currentLocation[0], lng: team.currentLocation[1]}, this.game.zone.currentZone.center, this.game.zone.currentZone.radius)) {
console.log("tema " + team.name + " out of zone")
//The team was not previously out of the zone
if (!this.outOfBoundsSince[team.id]) {
this.outOfBoundsSince[team.id] = new Date();
console.log("tema " + team.name + " warned")
teamBroadcast(team.id, "warning", `You left the zone, you have ${process.env.ALLOWED_TIME_OUT_OF_ZONE_IN_MINUTES} minutes to get back in the marked area.`)
} else {
if (new Date() - this.outOfBoundsSince[team.id] > process.env.ALLOWED_TIME_OUT_OF_ZONE_IN_MINUTES * 60 * 1000) {