WIP, tout est en chantier, très content :)

This commit is contained in:
LuckyLaszlo
2022-11-20 15:46:45 +01:00
parent 023b5ed485
commit 48665cfe30
22 changed files with 580 additions and 302 deletions

View File

@@ -0,0 +1,30 @@
import { ClientPlayer } from "./Client";
import {gameUpdate} from "../gameUpdate.js"
import { GameComponentsServer } from "./GameComponentsServer";
// Empty object replacement to the web-API (web-API useless on server-side)
class GameSession {
id: string; // url ?
playersMap: Map<string, ClientPlayer>;
unreadyPlayersMap: Map<string, ClientPlayer>;
updateInterval: NodeJS.Timer;
// gc: GameComponentsServer;
// updateInterval: NodeJS.Timer;
constructor(id: string) {
this.id = id;
this.playersMap = new Map();
this.unreadyPlayersMap = new Map();
// this.gc = new GameComponentsServer();
}
start() {
this.updateInterval = setInterval( () => {
const update = gameUpdate();
this.playersMap.forEach( (client) => {
client.socket.send(JSON.stringify(update));
});
}, 500);
}
}
export {GameSession}