- 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. +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/09/13 16:20:58 by tomoron #+# #+# # # Created: 2024/09/13 16:20:58 by tomoron #+# #+# #
# Updated: 2024/09/29 02:03:40 by edbernar ### ########.fr # # Updated: 2024/09/29 13:21:59 by edbernar ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -180,8 +180,8 @@ class Game:
def endGame(self, winner): def endGame(self, winner):
if(self.end): if(self.end):
return return
self.p1.sync_send({"type":"game","content":{"action":10,"won":winner==1}}) self.p1.sync_send({"type":"game","content":{"action":10,"won":winner==1, "opponentLeft":self.left == 2}})
self.p2.sync_send({"type":"game","content":{"action":10,"won":winner==2}}) self.p2.sync_send({"type":"game","content":{"action":10,"won":winner==2, "opponentLeft":self.left == 1}})
self.winner = winner self.winner = winner
self.end = True self.end = True

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/18 00:53:53 by edbernar #+# #+# */ /* 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 bar1 = createBarPlayer(availableSkins[skin.player]);
const bar2 = createBarPlayer(availableSkins[skin.opponent]); const bar2 = createBarPlayer(availableSkins[skin.opponent]);
console.log(document.body.getAttribute('style'));
document.body.setAttribute('style', ''); document.body.setAttribute('style', '');
scene = new THREE.Scene() scene = new THREE.Scene()
map = new Map(scene, 13, false); map = new Map(scene, 13, false);
@ -232,19 +231,23 @@ class MultiOnlineGamePage
lastPingTime = null; lastPingTime = null;
} }
static endGame(win) static endGame(content)
{ {
const endGameDiv = document.getElementById('endGameDiv'); const endGameDiv = document.getElementById('endGameDiv');
const scoreText = document.getElementById('endGameScore'); const scoreText = document.getElementById('endGameText');
const endGameScore = document.getElementById('endGameScore');
const simpleText = document.getElementById('endGameSimpleText'); const simpleText = document.getElementById('endGameSimpleText');
let intervalEnd = null; let intervalEnd = null;
let time = 4; let time = 4;
endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`; endGameScore.innerText = `${map.score.player} - ${map.score.opponent}`;
if (win) if (content.won)
endGameText.innerText = "You win !" scoreText.innerText = "You win !"
endGameDiv.style.display = 'flex'; endGameDiv.style.display = 'flex';
intervalEnd = setInterval(() => { intervalEnd = setInterval(() => {
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` simpleText.innerText = `You will be redirected to the lobby in ${time} seconds`
time--; time--;
if (time == -1) if (time == -1)

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */ /* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/09/15 12:00:01 by edbernar #+# #+# */ /* 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) if (content.action == 3 && content.is_opponent)
opponent.movePlayer(content); opponent.movePlayer(content);
else if (content.action == 4)
MultiOnlineGamePage.opponentDisconnect();
else if (content.action == 5) else if (content.action == 5)
ball.updatePos(content); ball.updatePos(content);
else if (content.action == 6) else if (content.action == 6)
@ -38,7 +36,7 @@ function typeGame(content)
else if (content.action == 9) else if (content.action == 9)
MultiOnlineGamePage.ping(); MultiOnlineGamePage.ping();
else if (content.action == 10) else if (content.action == 10)
MultiOnlineGamePage.endGame(content.won) MultiOnlineGamePage.endGame(content)
} }
} }

View File

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

View File

@ -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/09/29 01:11:55 by edbernar ### ########.fr */ /* Updated: 2024/09/29 13:28:28 by edbernar ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -238,15 +238,18 @@ body {
#endGameText { #endGameText {
font-size: 100px; font-size: 100px;
color: white; color: white;
text-align: center;
} }
#endGameScore { #endGameScore {
font-size: 75px; font-size: 75px;
color: white; color: white;
text-align: center;
} }
#endGameSimpleText { #endGameSimpleText {
font-size: 25px; font-size: 25px;
color: white; color: white;
text-align: center;
margin-top: 50px; margin-top: 50px;
} }