Site
- can send message in tournament - request 3 server tournamment Game - change buttons position on multi online
This commit is contained in:
@ -3,10 +3,10 @@
|
|||||||
# ::: :::::::: #
|
# ::: :::::::: #
|
||||||
# Tournament.py :+: :+: :+: #
|
# Tournament.py :+: :+: :+: #
|
||||||
# +:+ +:+ +:+ #
|
# +:+ +:+ +:+ #
|
||||||
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ #
|
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/10/04 17:17:07 by tomoron #+# #+# #
|
# Created: 2024/10/04 17:17:07 by tomoron #+# #+# #
|
||||||
# Updated: 2024/10/05 03:30:00 by tomoron ### ########.fr #
|
# Updated: 2024/10/05 03:33:17 by edbernar ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class Tournament:
|
|||||||
self.messages.append({"username":socket.username, "message":message})
|
self.messages.append({"username":socket.username, "message":message})
|
||||||
if(len(self.messages) > 20):
|
if(len(self.messages) > 20):
|
||||||
self.messages.pop(0)
|
self.messages.pop(0)
|
||||||
self.broadcast({"action":3, "username":socket.username, "message":socket.message})
|
self.broadcast({"action":3, "username":socket.username, "message":message})
|
||||||
|
|
||||||
def leave(self, socket):
|
def leave(self, socket):
|
||||||
if(socket not in self.players):
|
if(socket not in self.players):
|
||||||
|
@ -193,7 +193,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="line"></span>
|
<span class="line"></span>
|
||||||
<p style="text-align: center; margin-bottom: 20px;">Tournament code</p>
|
<p style="text-align: center; margin-bottom: 20px;">Tournament code</p>
|
||||||
<input id="tournamentCode" class="search-input" type="text" placeholder="Enter the tournament code (empty for create one)">
|
<input id="tournamentCode" class="search-input" type="text" placeholder="Enter the tournament code (empty to create one)">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="skin-select">
|
<div class="skin-select">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/18 00:30:31 by edbernar #+# #+# */
|
/* 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';
|
gamePad.style.display = 'flex';
|
||||||
document.addEventListener('touchstart', (event) => {
|
document.addEventListener('touchstart', (event) => {
|
||||||
const key = event.target.getAttribute("id");
|
const key = event.target.getAttribute("id");
|
||||||
|
|
||||||
|
|
||||||
for (let i = 0; i < keyList.length; i++)
|
for (let i = 0; i < keyList.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -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/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];
|
divInfo = document.getElementsByClassName('infoo')[0];
|
||||||
divChat = document.getElementsByClassName('chat')[0];
|
divChat = document.getElementsByClassName('chat')[0];
|
||||||
document.getElementById('code-tournament').innerText = "Code : " + code;
|
document.getElementById('code-tournament').innerText = "Code : " + code;
|
||||||
|
sendRequest("tournament", {action: 3});
|
||||||
divTopInfo.innerText = 'Tournament';
|
divTopInfo.innerText = 'Tournament';
|
||||||
|
initTournamentChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
static dispose()
|
static dispose()
|
||||||
@ -103,7 +105,6 @@ class TournamentPage
|
|||||||
while (i < playerNb.length - 1)
|
while (i < playerNb.length - 1)
|
||||||
{
|
{
|
||||||
playerList['player' + playerNb[i]] = playerList['player' + playerNb[i + 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('user-' + playerNb[i]).innerText = playerList['player' + playerNb[i]].username;
|
||||||
document.getElementById('pfp-' + playerNb[i]).style.backgroundImage = `url(${playerList['player' + playerNb[i]].pfp})`;
|
document.getElementById('pfp-' + playerNb[i]).style.backgroundImage = `url(${playerList['player' + playerNb[i]].pfp})`;
|
||||||
i++;
|
i++;
|
||||||
@ -121,6 +122,14 @@ class TournamentPage
|
|||||||
divChat.appendChild(newText);
|
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)
|
static startGame(content)
|
||||||
{
|
{
|
||||||
pageRenderer.changePage("waitingGamePage", false, {username: content.username, id: content.id, isTournament: true})
|
pageRenderer.changePage("waitingGamePage", false, {username: content.username, id: content.id, isTournament: true})
|
||||||
@ -136,4 +145,30 @@ function newInfo(message)
|
|||||||
divInfo.appendChild(newDiv);
|
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 }
|
export { TournamentPage }
|
@ -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/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);
|
TournamentPage.newMessage(content);
|
||||||
else if (content.action == 4)
|
else if (content.action == 4)
|
||||||
TournamentPage.startGame(content);
|
TournamentPage.startGame(content);
|
||||||
|
else if (content.action == 5)
|
||||||
|
TournamentPage.fetchAllData(content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
console.warn("Request tournament not for this page...");
|
console.warn("Request tournament not for this page...");
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/20 11:23:41 by edbernar #+# #+# */
|
/* Created: 2024/08/20 11:23:41 by edbernar #+# #+# */
|
||||||
/* Updated: 2024/10/04 17:35:50 by edbernar ### ########.fr */
|
/* Updated: 2024/10/05 02:14:49 by edbernar ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ body {
|
|||||||
.gamePad .gamePadLeft {
|
.gamePad .gamePadLeft {
|
||||||
display: flex;
|
display: flex;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50px;
|
left: 30px;
|
||||||
bottom: 50px;
|
bottom: 30px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
@ -135,8 +135,8 @@ body {
|
|||||||
display: flex;
|
display: flex;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
right: 50px;
|
right: 30px;
|
||||||
bottom: 50px;
|
bottom: 30px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
@ -159,7 +159,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.gamePadLeft #padRight {
|
.gamePadLeft #padRight {
|
||||||
margin-left: 50px;
|
margin-left: 10px;
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
@ -168,7 +168,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.gamePadRight #padTop {
|
.gamePadRight #padTop {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 10px;
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
|
Reference in New Issue
Block a user