yes
This commit is contained in:
parent
48c33b3568
commit
4cb0104124
2 changed files with 34 additions and 8 deletions
|
|
@ -107,7 +107,9 @@ function tourinfoButtons(tourInfo : HTMLButtonElement, tourScoreScreen : HTMLDiv
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameJoinButtons(socket : CSocket, inTournament : boolean, currentGame : currentGameInfo | null,
|
let inTournament: boolean = false;
|
||||||
|
|
||||||
|
function gameJoinButtons(socket : CSocket, currentGame : currentGameInfo | null,
|
||||||
tournament : HTMLButtonElement, queue : HTMLButtonElement, localGame : HTMLButtonElement, ready : HTMLButtonElement)
|
tournament : HTMLButtonElement, queue : HTMLButtonElement, localGame : HTMLButtonElement, ready : HTMLButtonElement)
|
||||||
{
|
{
|
||||||
tournament.addEventListener("click", () => {
|
tournament.addEventListener("click", () => {
|
||||||
|
|
@ -150,6 +152,10 @@ function gameJoinButtons(socket : CSocket, inTournament : boolean, currentGame :
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
localGame.addEventListener("click", () => {
|
localGame.addEventListener("click", () => {
|
||||||
|
if (inTournament) {
|
||||||
|
showError("You can't queue up currently !");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
queue.innerText !== QueueState.Iddle ||
|
queue.innerText !== QueueState.Iddle ||
|
||||||
currentGame !== null ||
|
currentGame !== null ||
|
||||||
|
|
@ -274,7 +280,7 @@ function pongClient(
|
||||||
setTitle("Pong Game");
|
setTitle("Pong Game");
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
let game_req_join = urlParams.get("game");
|
let game_req_join = urlParams.get("game");
|
||||||
let inTournament = false;
|
inTournament = false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
html: authHtml,
|
html: authHtml,
|
||||||
|
|
@ -548,7 +554,7 @@ function pongClient(
|
||||||
|
|
||||||
setInterval(() => {keys_listen_setup(currentGame, socket, keys, playHow, playHow_b, tourScoreScreen, queue)}, 1000 / 60);
|
setInterval(() => {keys_listen_setup(currentGame, socket, keys, playHow, playHow_b, tourScoreScreen, queue)}, 1000 / 60);
|
||||||
|
|
||||||
gameJoinButtons(socket, inTournament, currentGame, tournament, queue, localGame, ready);
|
gameJoinButtons(socket, currentGame, tournament, queue, localGame, ready);
|
||||||
playhowButtons(playHow_b, playHow);
|
playhowButtons(playHow_b, playHow);
|
||||||
tourinfoButtons(tourInfo, tourScoreScreen);
|
tourinfoButtons(tourInfo, tourScoreScreen);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,20 @@ class StateI {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (user.currentGame !== null) {
|
||||||
this.dequeueUser(user.socket);
|
sock.emit('tournamentRegister', {
|
||||||
|
kind: 'failure',
|
||||||
|
msg: 'You are in game',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.queue.has(user.id)) {
|
||||||
|
sock.emit('tournamentRegister', {
|
||||||
|
kind: 'failure',
|
||||||
|
msg: 'You are in queue',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.tournament.addUser(user.id, name ?? udb.name);
|
this.tournament.addUser(user.id, name ?? udb.name);
|
||||||
sock.emit('tournamentRegister', {
|
sock.emit('tournamentRegister', {
|
||||||
kind: 'success',
|
kind: 'success',
|
||||||
|
|
@ -281,7 +293,9 @@ class StateI {
|
||||||
this.games.set(gameId, g);
|
this.games.set(gameId, g);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (!g.ready_checks[0] && !g.ready_checks[1]) {
|
if (!g.ready_checks[0] && !g.ready_checks[1]) {
|
||||||
this.fastify.log.info(`paused game ${gameId} has been canceled`);
|
this.fastify.log.info(
|
||||||
|
`paused game ${gameId} has been canceled`,
|
||||||
|
);
|
||||||
this.cleanupGame(gameId, g);
|
this.cleanupGame(gameId, g);
|
||||||
}
|
}
|
||||||
}, 1000 * 60);
|
}, 1000 * 60);
|
||||||
|
|
@ -444,13 +458,19 @@ class StateI {
|
||||||
) {
|
) {
|
||||||
this.fastify.log.warn(
|
this.fastify.log.warn(
|
||||||
'user trying to connect to a game he\'s not part of: gameId:' +
|
'user trying to connect to a game he\'s not part of: gameId:' +
|
||||||
g_id + ' userId:' + sock.authUser.id);
|
g_id +
|
||||||
|
' userId:' +
|
||||||
|
sock.authUser.id,
|
||||||
|
);
|
||||||
return JoinRes.no;
|
return JoinRes.no;
|
||||||
}
|
}
|
||||||
if (game.userOnPage[0] === true && game.userOnPage[1] === true) {
|
if (game.userOnPage[0] === true && game.userOnPage[1] === true) {
|
||||||
this.fastify.log.warn(
|
this.fastify.log.warn(
|
||||||
'user trying to connect to a game he\'s already joined: gameId:' +
|
'user trying to connect to a game he\'s already joined: gameId:' +
|
||||||
g_id + ' userId:' + sock.authUser.id);
|
g_id +
|
||||||
|
' userId:' +
|
||||||
|
sock.authUser.id,
|
||||||
|
);
|
||||||
return JoinRes.no;
|
return JoinRes.no;
|
||||||
}
|
}
|
||||||
game.userOnPage[game.userLeft === sock.authUser.id ? 0 : 1] = true;
|
game.userOnPage[game.userLeft === sock.authUser.id ? 0 : 1] = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue