- add "opponentLeft" boolean in endGame()
Site
    - update end game screen
    - fix red point on live chat after a game
This commit is contained in:
Kum1ta
2024-09-29 14:31:33 +02:00
parent 24fe748130
commit 76cf5d0585
5 changed files with 42 additions and 22 deletions

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */
/* Updated: 2024/09/29 01:35:50 by edbernar ### ########.fr */
/* Updated: 2024/09/29 14:17:33 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -80,7 +80,6 @@ class MultiOnlineGamePage
const bar1 = createBarPlayer(availableSkins[skin.player]);
const bar2 = createBarPlayer(availableSkins[skin.opponent]);
console.log(document.body.getAttribute('style'));
document.body.setAttribute('style', '');
scene = new THREE.Scene()
map = new Map(scene, 13, false);
@ -232,20 +231,24 @@ class MultiOnlineGamePage
lastPingTime = null;
}
static endGame(win)
static endGame(content)
{
const endGameDiv = document.getElementById('endGameDiv');
const scoreText = document.getElementById('endGameScore');
const simpleText = document.getElementById('endGameSimpleText');
let intervalEnd = null;
let time = 4;
const endGameDiv = document.getElementById('endGameDiv');
const scoreText = document.getElementById('endGameText');
const endGameScore = document.getElementById('endGameScore');
const simpleText = document.getElementById('endGameSimpleText');
let intervalEnd = null;
let time = 4;
endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`;
if (win)
endGameText.innerText = "You win !"
if (content.won)
scoreText.innerText = "You win !"
endGameDiv.style.display = 'flex';
intervalEnd = setInterval(() => {
simpleText.innerText = `You will be redirected to the lobby in ${time} seconds`
if (content.opponentLeft)
simpleText.innerText = `Your opponent has given up...\nYou will be redirected to the lobby in ${time} seconds`
else
simpleText.innerText = `You will be redirected to the lobby in ${time} seconds`
time--;
if (time == -1)
{

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/15 12:00:01 by edbernar #+# #+# */
/* Updated: 2024/09/29 00:22:13 by edbernar ### ########.fr */
/* Updated: 2024/09/29 13:24:06 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,8 +25,6 @@ function typeGame(content)
{
if (content.action == 3 && content.is_opponent)
opponent.movePlayer(content);
else if (content.action == 4)
MultiOnlineGamePage.opponentDisconnect();
else if (content.action == 5)
ball.updatePos(content);
else if (content.action == 6)
@ -38,7 +36,7 @@ function typeGame(content)
else if (content.action == 9)
MultiOnlineGamePage.ping();
else if (content.action == 10)
MultiOnlineGamePage.endGame(content.won)
MultiOnlineGamePage.endGame(content)
}
}

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/04 15:15:49 by edbernar #+# #+# */
/* Updated: 2024/09/29 03:45:24 by edbernar ### ########.fr */
/* Updated: 2024/09/29 14:11:26 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,9 +16,11 @@ import { waitForUserInfo } from '/static/javascript/typeResponse/typeUserInfo.js
import { userMeInfo } from "/static/javascript/typeResponse/typeLogin.js";
import { sendRequest } from "/static/javascript/websocket.js";
let interval = null;
function typeNewPrivateMessage(content)
{
const notifBadgeChat = document.getElementsByClassName('notification-badge')[0];
let notifBadgeChat = document.getElementsByClassName('notification-badge')[0];
if (infoPanel.isOpen && infoPanel.id === content.channel)
{
@ -35,7 +37,21 @@ function typeNewPrivateMessage(content)
}
else if (content.from != userMeInfo.id)
{
notifBadgeChat.style.display = 'flex';
if (notifBadgeChat)
notifBadgeChat.style.display = 'flex';
else
{
if (interval)
clearInterval(interval);
interval = setInterval(() => {
notifBadgeChat = document.getElementsByClassName('notification-badge')[0];
if (notifBadgeChat)
{
notifBadgeChat.style.display = 'flex';
clearInterval(interval);
}
}, 1000);
}
sendRequest("get_user_info", {id: content.from});
waitForUserInfo().then((userInfo) => {
CN.new("Message", "New message from " + userInfo.username);

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/20 11:23:41 by edbernar #+# #+# */
/* Updated: 2024/09/29 01:11:55 by edbernar ### ########.fr */
/* Updated: 2024/09/29 13:28:28 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -238,15 +238,18 @@ body {
#endGameText {
font-size: 100px;
color: white;
text-align: center;
}
#endGameScore {
font-size: 75px;
color: white;
text-align: center;
}
#endGameSimpleText {
font-size: 25px;
color: white;
text-align: center;
margin-top: 50px;
}