Tournament
- request 7 ok when tournament is finish
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/01 13:42:29 by edbernar #+# #+# */
|
/* Created: 2024/10/01 13:42:29 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/20 17:58:40 by edbernar ### ########.fr */
|
/* Updated: 2024/10/27 23:40:49 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ const playerList = {
|
|||||||
let divTopInfo = null;
|
let divTopInfo = null;
|
||||||
let divInfo = null;
|
let divInfo = null;
|
||||||
let divChat = null;
|
let divChat = null;
|
||||||
|
let timeout = null;
|
||||||
|
|
||||||
class TournamentPage
|
class TournamentPage
|
||||||
{
|
{
|
||||||
@ -66,6 +67,9 @@ class TournamentPage
|
|||||||
info.username = null;
|
info.username = null;
|
||||||
info.pfp = null;
|
info.pfp = null;
|
||||||
});
|
});
|
||||||
|
if (timeout)
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static newOpponent(content)
|
static newOpponent(content)
|
||||||
@ -178,6 +182,15 @@ class TournamentPage
|
|||||||
document.getElementById('pfp-' + loserPos).style.backgroundImage = `linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('${playerList['player' + (content.p1Win ? player2Nb : player1Nb)].pfp}')`;
|
document.getElementById('pfp-' + loserPos).style.backgroundImage = `linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('${playerList['player' + (content.p1Win ? player2Nb : player1Nb)].pfp}')`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end(content)
|
||||||
|
{
|
||||||
|
console.log("Tournament is over. The winner is : ", playerList['player' + playerNb[content.winnerId]]);
|
||||||
|
newInfo(`The winner is : ${playerList['player' + playerNb[content.winnerId]].username}`);
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
pageRenderer.changePage("lobbyPage", false);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newInfo(message)
|
function newInfo(message)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
|
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/20 18:07:15 by edbernar ### ########.fr */
|
/* Updated: 2024/10/27 23:30:11 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -43,6 +43,8 @@ function typeTournament(content)
|
|||||||
TournamentPage.fetchAllData(content);
|
TournamentPage.fetchAllData(content);
|
||||||
else if (content.action == 6)
|
else if (content.action == 6)
|
||||||
TournamentPage.newEndGame(content);
|
TournamentPage.newEndGame(content);
|
||||||
|
else if (content.action == 7)
|
||||||
|
TournamentPage.end(content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
console.warn("Request tournament not for this page...");
|
console.warn("Request tournament not for this page...");
|
||||||
|
Reference in New Issue
Block a user