matchmaking rework for multiples game modes

This commit is contained in:
LuckyLaszlo
2022-12-01 05:50:31 +01:00
parent e3fd130729
commit 6e572f2fb5
7 changed files with 67 additions and 49 deletions

View File

@@ -13,20 +13,20 @@ import { random } from "../utils.js";
*/
class GameSession {
id: string; // url ?
playersMap: Map<string, ClientPlayer>;
unreadyPlayersMap: Map<string, ClientPlayer>;
gameLoopInterval: NodeJS.Timer | number;
clientsUpdateInterval: NodeJS.Timer | number;
playersMap: Map<string, ClientPlayer> = new Map();
unreadyPlayersMap: Map<string, ClientPlayer> = new Map();
gameLoopInterval: NodeJS.Timer | number = 0;
clientsUpdateInterval: NodeJS.Timer | number = 0;
components: GameComponentsServer;
matchOptions: en.MatchOptions;
actual_time: number;
last_time: number;
delta_time: number;
constructor(id: string) {
constructor(id: string, matchOptions: en.MatchOptions) {
this.id = id;
this.playersMap = new Map();
this.unreadyPlayersMap = new Map();
this.matchOptions = matchOptions;
this.components = new GameComponentsServer();
}
start() {