Vive le rouge !
This commit is contained in:
@@ -82,7 +82,7 @@ export class GameSession {
|
||||
else if (input === en.InputEnum.down) {
|
||||
client.racket.dir.y = 1;
|
||||
}
|
||||
|
||||
|
||||
if (input !== en.InputEnum.noInput) {
|
||||
client.racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ export class GameSession {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private async _matchEnd(winner: en.PlayerSide, forfeit_flag: boolean = false)
|
||||
private async _matchEnd(winner: en.PlayerSide, forfeit_flag: boolean = false)
|
||||
{
|
||||
this.matchEnded = true;
|
||||
let eventEnd: ev.EventMatchEnd;
|
||||
@@ -232,7 +232,6 @@ export class GameSession {
|
||||
client.socket.send(JSON.stringify(eventEnd));
|
||||
});
|
||||
|
||||
/* // WIP nest , send match result
|
||||
const gc = this.components;
|
||||
await fetch(c.addressBackEnd + "/game/matchEnd",
|
||||
{
|
||||
@@ -245,7 +244,7 @@ export class GameSession {
|
||||
scoreLeft: gc.scoreLeft,
|
||||
scoreRight: gc.scoreRight,
|
||||
})
|
||||
}); */
|
||||
});
|
||||
|
||||
// logs
|
||||
if (winner === en.PlayerSide.left) {
|
||||
|
||||
@@ -9,4 +9,4 @@ export const fixedDeltaTime = serverGameLoopIntervalMS/1000; // second
|
||||
export const playersUpdateIntervalMS = 1000/30; // millisecond
|
||||
export const spectatorsUpdateIntervalMS = 1000/30; // millisecond
|
||||
|
||||
export const addressBackEnd = "http://backend_dev:3000";
|
||||
export const addressBackEnd = "http://backend_dev:3000/api/v2";
|
||||
|
||||
@@ -66,7 +66,7 @@ async function clientAnnounceListener(this: WebSocket, data: string)
|
||||
if (msg.role === en.ClientRole.player)
|
||||
{
|
||||
const announce: ev.ClientAnnouncePlayer = <ev.ClientAnnouncePlayer>msg;
|
||||
|
||||
|
||||
// WIP nest, fetch token validation
|
||||
const body = {
|
||||
playerOneUsername: announce.username,
|
||||
@@ -78,7 +78,7 @@ async function clientAnnounceListener(this: WebSocket, data: string)
|
||||
if (announce.privateMatch) {
|
||||
body.playerTwoUsername = announce.playerTwoUsername;
|
||||
}
|
||||
const response = await fetch(c.addressBackEnd + "/game/validateToken",
|
||||
const response = await fetch(c.addressBackEnd + "/game/gameserver/validate",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -163,12 +163,12 @@ function publicMatchmaking(player: ClientPlayer)
|
||||
|
||||
|
||||
function privateMatchmaking(player: ClientPlayer)
|
||||
{
|
||||
{
|
||||
const minPlayersNumber = 2;
|
||||
const maxPlayersNumber = 2;
|
||||
privateMatchmakingMap.set(player.id, player);
|
||||
const matchOptions = player.matchOptions;
|
||||
|
||||
|
||||
const token = player.token;
|
||||
const compatiblePlayers: ClientPlayer[] = [];
|
||||
for (const [id, client] of privateMatchmakingMap)
|
||||
@@ -243,17 +243,18 @@ async function playerReadyConfirmationListener(this: WebSocket, data: string)
|
||||
{
|
||||
// WIP nest , send gameSession.id
|
||||
const gameSessionPlayersIterator = gameSession.playersMap.values();
|
||||
const response = await fetch(c.addressBackEnd + "/game/newGameSession",
|
||||
const response = await fetch(c.addressBackEnd + "/game/gameserver/creategame",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
id: gameSession.id,
|
||||
gameServerIdOfTheMatch : gameSession.id,
|
||||
gameOptions: gameSession.matchOptions,
|
||||
playerOneUsername: (<ClientPlayer>gameSessionPlayersIterator.next().value).username,
|
||||
playerTwoUsername: (<ClientPlayer>gameSessionPlayersIterator.next().value).username,
|
||||
|
||||
})
|
||||
});
|
||||
if (!response.ok)
|
||||
|
||||
Reference in New Issue
Block a user