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

@@ -25,7 +25,7 @@ class ClientInfo {
export const clientInfo = new ClientInfo();
socket.addEventListener("open", (event) => {
socket.send(JSON.stringify( new ev.ClientAnnounce(en.ClientRole.player, clientInfo.id) ));
socket.send(JSON.stringify( new ev.ClientAnnounce(en.ClientRole.player, c.optionsPLACEHOLDER, clientInfo.id) ));
});
// socket.addEventListener("message", logListener); // for testing purpose
@@ -58,7 +58,7 @@ function preMatchListener(this: WebSocket, event: MessageEvent) {
}
clientInfo.opponentNextPos = new VectorInteger(clientInfo.opponent.pos.x, clientInfo.opponent.pos.y);
clientInfo.racket.color = "darkgreen"; // for testing purpose
socket.send(JSON.stringify( new ev.ClientEvent(en.EventTypes.clientPlayerReady) ));
socket.send(JSON.stringify( new ev.ClientEvent(en.EventTypes.clientPlayerReady) )); // TODO: set an interval/timeout to resend until matchStart response (in case of network problem)
matchmakingComplete();
break;
case en.EventTypes.matchStart: