last update before merge with Cherif

This commit is contained in:
LuckyLaszlo
2022-12-20 16:49:01 +01:00
parent c29db6d5f3
commit de00a4fdcd
2 changed files with 77 additions and 15 deletions

47
memo.txt Normal file
View File

@@ -0,0 +1,47 @@
DONE :
TODO :
routes gameServer -> Nest :
- validation
- creation de partie
- fin de partie
- mode spectateur
- quelques routes cote serveur
- une interface cote front (liste des matchs en cours)
- etat du client (en ligne, en jeu, ...)
- le chat
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
"Bonus" :
- HTTPS
- mettre le site en ligne
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
BUG :
- Bug de son étonnant dans le front, ça pop une fois de temps en temps :
Uncaught (in promise) DOMException: The element has no supported sources.
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
- Comment fonctionne .env ? Comment faire pour ne pas le push sur le depot ?
- certains status 200 pourrait peut-être être du 204 ?
(exemple dans TwoFactorAuthentication.svelte)
A la place de :
```
if (response.status === 401) {
// Wrong
}
if (response.status === 200) {
// Ok
}
```
On pourrait mettre :
```
if (!response.ok) {
// Wrong
}
else {
// Ok
}
```

View File

@@ -191,7 +191,7 @@ function privateMatchmaking(player: ClientPlayer)
}
async function createGameSession(playersArr: ClientPlayer[], matchOptions: en.MatchOptions)
function createGameSession(playersArr: ClientPlayer[], matchOptions: en.MatchOptions)
{
// const id = gameSessionIdPLACEHOLDER; // Force ID, TESTING SPECTATOR
const id = uuidv4();
@@ -227,22 +227,10 @@ async function createGameSession(playersArr: ClientPlayer[], matchOptions: en.Ma
});
}
}, 5000);
/* // WIP nest , send gameSession.id
await fetch(c.addressBackEnd + "/game/newGameSession",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: id,
})
}); */
}
function playerReadyConfirmationListener(this: WebSocket, data: string)
async function playerReadyConfirmationListener(this: WebSocket, data: string)
{
try {
const msg : ev.ClientEvent = JSON.parse(data);
@@ -251,7 +239,34 @@ function playerReadyConfirmationListener(this: WebSocket, data: string)
const client = clientsMap.get(this.id);
const gameSession = client.gameSession;
gameSession.unreadyPlayersMap.delete(this.id);
if (gameSession.unreadyPlayersMap.size === 0) {
if (gameSession.unreadyPlayersMap.size === 0)
{
// WIP nest , send gameSession.id
const gameSessionPlayersIterator = gameSession.playersMap.values();
const response = await fetch(c.addressBackEnd + "/game/newGameSession",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
id: gameSession.id,
gameOptions: gameSession.matchOptions,
playerOneUsername: (<ClientPlayer>gameSessionPlayersIterator.next().value).username,
playerTwoUsername: (<ClientPlayer>gameSessionPlayersIterator.next().value).username,
})
});
if (!response.ok)
{
gameSessionsMap.delete(gameSession.id);
gameSession.playersMap.forEach((client) => {
client.socket.send(JSON.stringify( new ev.ServerEvent(en.EventTypes.matchAbort) ));
client.gameSession = null;
clientTerminate(client);
});
return;
}
gameSession.playersMap.forEach( (client) => {
client.socket.send(JSON.stringify( new ev.ServerEvent(en.EventTypes.matchStart) ));
});