Site
- can send message in tournament - request 3 server tournamment Game - change buttons position on multi online
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/05 01:06:19 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/05 02:41:30 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -539,7 +539,6 @@ function showGamePad()
|
||||
gamePad.style.display = 'flex';
|
||||
document.addEventListener('touchstart', (event) => {
|
||||
const key = event.target.getAttribute("id");
|
||||
|
||||
|
||||
for (let i = 0; i < keyList.length; i++)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:42:29 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/03 02:27:58 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/05 03:48:19 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,7 +38,9 @@ class TournamentPage
|
||||
divInfo = document.getElementsByClassName('infoo')[0];
|
||||
divChat = document.getElementsByClassName('chat')[0];
|
||||
document.getElementById('code-tournament').innerText = "Code : " + code;
|
||||
sendRequest("tournament", {action: 3});
|
||||
divTopInfo.innerText = 'Tournament';
|
||||
initTournamentChat();
|
||||
}
|
||||
|
||||
static dispose()
|
||||
@ -103,7 +105,6 @@ class TournamentPage
|
||||
while (i < playerNb.length - 1)
|
||||
{
|
||||
playerList['player' + playerNb[i]] = playerList['player' + playerNb[i + 1]];
|
||||
console.log(playerList['player' + playerNb[i]]);
|
||||
document.getElementById('user-' + playerNb[i]).innerText = playerList['player' + playerNb[i]].username;
|
||||
document.getElementById('pfp-' + playerNb[i]).style.backgroundImage = `url(${playerList['player' + playerNb[i]].pfp})`;
|
||||
i++;
|
||||
@ -121,6 +122,14 @@ class TournamentPage
|
||||
divChat.appendChild(newText);
|
||||
}
|
||||
|
||||
static fetchAllData(content)
|
||||
{
|
||||
for (let i = 0; i < content.messages.length; i++)
|
||||
this.newMessage(content.messages[i]);
|
||||
for (let i = 0; i < content.players.length; i++)
|
||||
this.newOpponent(content.players[i]);
|
||||
}
|
||||
|
||||
static startGame(content)
|
||||
{
|
||||
pageRenderer.changePage("waitingGamePage", false, {username: content.username, id: content.id, isTournament: true})
|
||||
@ -136,4 +145,30 @@ function newInfo(message)
|
||||
divInfo.appendChild(newDiv);
|
||||
}
|
||||
|
||||
function initTournamentChat()
|
||||
{
|
||||
const inputMessage = document.getElementById('inputMessage');
|
||||
const sendButton = document.getElementById("sendButton");
|
||||
|
||||
sendButton.style.cursor = "pointer";
|
||||
sendButton.addEventListener("click", () => {
|
||||
sendRequest("tournament", {action: 2, message: inputMessage.value});
|
||||
inputMessage.value = "";
|
||||
inputMessage.focus();
|
||||
});
|
||||
inputMessage.addEventListener("keyup", (event) => {
|
||||
if (event.key === "Enter" && inputMessage.value.trim() !== "")
|
||||
{
|
||||
event.preventDefault();
|
||||
sendRequest("tournament", {action: 2, message: inputMessage.value});
|
||||
inputMessage.value = "";
|
||||
inputMessage.focus();
|
||||
}
|
||||
});
|
||||
inputMessage.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter")
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
export { TournamentPage }
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/03 01:17:26 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/10/05 03:02:38 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,6 +38,8 @@ function typeTournament(content)
|
||||
TournamentPage.newMessage(content);
|
||||
else if (content.action == 4)
|
||||
TournamentPage.startGame(content);
|
||||
else if (content.action == 5)
|
||||
TournamentPage.fetchAllData(content);
|
||||
}
|
||||
else
|
||||
console.warn("Request tournament not for this page...");
|
||||
|
Reference in New Issue
Block a user