Refactored code to remove useless classes, fix #17

This commit is contained in:
2024-06-10 18:06:00 +00:00
parent 4f9608d25d
commit 21e6f31c15
7 changed files with 137 additions and 146 deletions

View File

@@ -2,12 +2,10 @@ import { createServer } from "https";
import express from "express";
import { Server } from "socket.io";
import Game from "./game.js";
import { config } from "dotenv";
import { readFileSync } from "fs";
import { initAdminSocketHandler, secureAdminBroadcast } from "./admin_socket.js";
import { initTeamSocket, playersBroadcast } from "./team_socket.js";
import { PenaltyController } from "./penalty_controller.js";
import { initAdminSocketHandler } from "./admin_socket.js";
import { initTeamSocket } from "./team_socket.js";
import { initPhotoUpload } from "./photo.js";
//extract admin password from .env file
config();
@@ -35,22 +33,6 @@ export const io = new Server(httpsServer, {
}
});
//Zone update broadcast function, called by the game object
function onUpdateNewZone(newZone) {
playersBroadcast("new_zone", newZone)
secureAdminBroadcast("new_zone", newZone)
}
function onUpdateZone(zone) {
playersBroadcast("zone", zone)
secureAdminBroadcast("zone", zone)
}
export const game = new Game(onUpdateZone, onUpdateNewZone);
export const penaltyController = new PenaltyController();
initAdminSocketHandler();
initTeamSocket();
initPhotoUpload();