- add new request for start game in tournament
    - fix some bug with style
This commit is contained in:
Kum1ta
2024-10-02 13:50:54 +02:00
parent eb6b2c8ada
commit aab0b9397c
7 changed files with 33 additions and 9 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/19 23:08:31 by edbernar #+# #+# */
/* Updated: 2024/10/01 00:21:50 by edbernar ### ########.fr */
/* Updated: 2024/10/02 13:34:58 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -111,7 +111,7 @@ class ProfilPage
CN.new("Invitation", `Can't invite ${userInfo.username} (offline)`)
else
{
pageRenderer.changePage("waitingGamePage", false, {username: userInfo.username, id: userInfo.id});
pageRenderer.changePage("waitingGamePage", false, {username: userInfo.username, id: userInfo.id, isTournament: false});
}
});
}

View File

@ -6,10 +6,12 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/01 13:42:29 by edbernar #+# #+# */
/* Updated: 2024/10/02 04:55:51 by edbernar ### ########.fr */
/* Updated: 2024/10/02 13:39:23 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { pageRenderer } from '/static/javascript/main.js';
const playerNb = [1, 2, 4, 5, 13, 14, 15, 16];
const playerList = {
player1: {id: 0, username: null, pfp: null},
@ -116,6 +118,11 @@ class TournamentPage
newText.innerText = `${content.username} : ${content.message}`;
divChat.appendChild(newText);
}
static startGame(content)
{
pageRenderer.changePage("waitingGamePage", false, {username: content.username, id: content.id, isTournament: true})
}
}
function newInfo(message)

View File

@ -16,3 +16,6 @@ typeTournament({action: 1, id: 8, username: "GlitchPhantom", pfp: "https://image
typeTournament({action: 1, id: 9, username: "FrostBiteX", pfp: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQJWyvMlk1053PLnD3PRrz2g_LdQtW2H-M-GQ&s"});
typeTournament({action: 1, id: 10, username: "LunarEcho", pfp: "https://hypixel.net/attachments/1928357/"});
typeTournament({action: 2,id: 3});
typeTournament({action: 3, username: "Eddy", message: "Bonsoir"});
typeTournament({action: 4, username: "Eddy", message: "Bonsoir"});

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
/* Updated: 2024/10/02 04:51:32 by edbernar ### ########.fr */
/* Updated: 2024/10/02 13:29:36 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,6 +30,8 @@ function typeTournament(content)
TournamentPage.leaveOpponent(content);
else if (content.action == 3)
TournamentPage.newMessage(content);
else if (content.action == 4)
TournamentPage.startGame(content);
}
else
console.warn("Request tournament not for this page...");

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/14 21:20:45 by edbernar #+# #+# */
/* Updated: 2024/10/01 01:08:24 by edbernar ### ########.fr */
/* Updated: 2024/10/02 13:43:43 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,14 +41,16 @@ class WaitingGamePage
sentence.innerText = text + points;
}, 500);
timeout = setTimeout(() => {
console.log("dsadsadas");
if (opponentInfo && typeof(opponentInfo) != 'boolean')
sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, opponent: opponentInfo.id});
else
sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, isRanked: opponentInfo ? true : false});
timeout = null;
}, 1500);
returnButton.addEventListener('click', returnToLobby);
}, (opponentInfo && typeof(opponentInfo) != 'boolean' && !opponentInfo.isTournament) ? 1500 : 500);
if (!opponentInfo || typeof(opponentInfo) == 'boolean' || (typeof(opponentInfo) != 'boolean' && !opponentInfo.isTournament))
returnButton.addEventListener('click', returnToLobby);
else
returnButton.remove();
}
static dispose()