From 93da99d55958a88773678adeeedda63331c13e58 Mon Sep 17 00:00:00 2001 From: Kum1ta Date: Mon, 14 Oct 2024 22:16:00 +0200 Subject: [PATCH] Game - remove video when user is on mobile Site - add skin in tournament request - fix bug with goal/bar selector --- .../file/server/server/TournamentGame.py | 13 +++-- .../server/typeRequests/tournamentRequest.py | 4 +- .../nginx/static/javascript/lobbyPage/3d.js | 52 ++++++++++++------- .../nginx/static/javascript/lobbyPage/main.js | 7 +-- .../javascript/multiOnlineGame/Player.js | 7 ++- .../multiOnlineGame/multiOnlineGamePage.js | 6 ++- .../tournamentPage/TournamentPage.js | 16 +++--- .../static/javascript/waitingGame/main.js | 23 +++++--- 8 files changed, 82 insertions(+), 46 deletions(-) diff --git a/docker-compose/requirements/djangoserver/file/server/server/TournamentGame.py b/docker-compose/requirements/djangoserver/file/server/server/TournamentGame.py index 94ca7f8..4f5c06c 100644 --- a/docker-compose/requirements/djangoserver/file/server/server/TournamentGame.py +++ b/docker-compose/requirements/djangoserver/file/server/server/TournamentGame.py @@ -3,14 +3,15 @@ # ::: :::::::: # # TournamentGame.py :+: :+: :+: # # +:+ +:+ +:+ # -# By: tomoron +#+ +:+ +#+ # +# By: edbernar { - const pos = div.getBoundingClientRect(); - this.renderer.setSize(pos.width - 10, pos.height - 10); - this.camera.aspect = (pos.width - 10) / (pos.height - 10); - this.camera.updateProjectionMatrix(); - }); + window.addEventListener('resize', this.boundSkinSelector); + } + + resizeSelector() + { + const pos = this.div.getBoundingClientRect(); + this.renderer.setSize(pos.width - 10, pos.height - 10); + this.camera.aspect = (pos.width - 10) / (pos.height - 10); + this.camera.updateProjectionMatrix(); } hideSkinSelector(event) @@ -181,6 +187,7 @@ class barSelecter } this.scene = null; actualBarSelecor = null; + window.removeEventListener('resize', this.boundSkinSelector); } } @@ -199,6 +206,7 @@ class goalSelecter boundChangeGoal = this.changeGoal.bind(this); boundhideGoalSelector = this.hideGoalSelector.bind(this); boundshowGoals = this.showGoals.bind(this); + boundresizeSelector = this.resizeSelector.bind(this); constructor(div) { @@ -220,12 +228,15 @@ class goalSelecter this.renderer.setAnimationLoop(this.#loop.bind(this)); div.removeEventListener('click', this.boundshowGoals); div.addEventListener('click', this.boundshowGoals); - window.addEventListener('resize', () => { - const pos = div.getBoundingClientRect(); - this.renderer.setSize(pos.width - 10, pos.height - 10); - this.camera.aspect = (pos.width - 10) / (pos.height - 10); - this.camera.updateProjectionMatrix(); - }); + window.addEventListener('resize', this.boundresizeSelector); + } + + resizeSelector() + { + const pos = this.div.getBoundingClientRect(); + this.renderer.setSize(pos.width - 10, pos.height - 10); + this.camera.aspect = (pos.width - 10) / (pos.height - 10); + this.camera.updateProjectionMatrix(); } showGoals() @@ -379,6 +390,7 @@ class goalSelecter this.scene = null; actualGoalSelecter = null; this.div.removeEventListener('click', this.boundshowGoals); + window.removeEventListener('resize', this.boundresizeSelector); } } diff --git a/docker-compose/requirements/nginx/static/javascript/lobbyPage/main.js b/docker-compose/requirements/nginx/static/javascript/lobbyPage/main.js index c7efe52..e0f0bdd 100644 --- a/docker-compose/requirements/nginx/static/javascript/lobbyPage/main.js +++ b/docker-compose/requirements/nginx/static/javascript/lobbyPage/main.js @@ -6,7 +6,7 @@ /* By: edbernar = 0 && parseInt(nbBot) <= 7) - sendRequest("tournament", {action: 0, code: '', nbBot: parseInt(nbBot)}); + sendRequest("tournament", {action: 0, code: '', nbBot: parseInt(nbBot), skin: lastSelected ? lastSelected.id : 0, goal: goalSelector ? goalSelector.selected : 0}); else CN.new("Error", "You must enter a valid number of bot"); } diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js index c8ac837..c2aa99a 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/Player.js @@ -6,7 +6,7 @@ /* By: edbernar { this.mapVar.putVideoOnCanvas(0, null); - this.mapVar.putVideoOnCanvas(2, 3); + if (!isMobile) + this.mapVar.putVideoOnCanvas(2, 3); }, 4000); ball.setVisibility(false); @@ -551,6 +553,7 @@ function showGamePad() goFullscreen(); }); gamePad.style.display = 'flex'; + console.warn("change listener for touchstart and touchend because can't be removed"); document.addEventListener('touchstart', (event) => { const key = event.target.getAttribute("id"); diff --git a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js index c37f0fe..568443f 100644 --- a/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js +++ b/docker-compose/requirements/nginx/static/javascript/multiOnlineGame/multiOnlineGamePage.js @@ -6,7 +6,7 @@ /* By: edbernar { diff --git a/docker-compose/requirements/nginx/static/javascript/tournamentPage/TournamentPage.js b/docker-compose/requirements/nginx/static/javascript/tournamentPage/TournamentPage.js index b725f2b..748f607 100644 --- a/docker-compose/requirements/nginx/static/javascript/tournamentPage/TournamentPage.js +++ b/docker-compose/requirements/nginx/static/javascript/tournamentPage/TournamentPage.js @@ -6,7 +6,7 @@ /* By: edbernar { - if (opponentInfo && typeof(opponentInfo) != 'boolean') - sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, goalId: goalId, opponent: opponentInfo.id}); + if (!isTournament) + { + if (opponentInfo && typeof(opponentInfo) != 'boolean') + sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, goalId: goalId, opponent: opponentInfo.id}); + else + sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, goalId: goalId, isRanked: opponentInfo ? true : false, with_bot: withBot}); + } else - sendRequest("game", {action: 0, skinId: lastSelected ? lastSelected.id : 0, goalId: goalId, isRanked: opponentInfo ? true : false, with_bot: withBot}); + { + this.showOpponent(opponentInfo); + } timeout = null; }, isTournament ? 1500 : 500); if (!opponentInfo || !isTournament) @@ -91,10 +98,14 @@ class WaitingGamePage timeout = setTimeout(() => { document.body.style.animation = 'anim3 0.5s'; document.body.style.opacity = 0; - pageRenderer.changePage("multiOnlineGamePage", false, {player: lastSelected ? lastSelected.id : 0, opponent: content.skin, opponentGoaldId: content.goal, pfp: content.pfpSelf, pfpOpponent: content.pfpOpponent}); + if (content.isTournament) + pageRenderer.changePage("multiOnlineGamePage", false, {player: lastSelected ? lastSelected.id : 0, opponent: content.id, opponentGoaldId: content.content.goal, pfp: content.content.selfPfp, pfpOpponent: content.content.pfp}); + else + pageRenderer.changePage("multiOnlineGamePage", false, {player: lastSelected ? lastSelected.id : 0, opponent: content.skin, opponentGoaldId: content.goal, pfp: content.pfpSelf, pfpOpponent: content.pfpOpponent}); }, 1000); }, 500); - document.body.removeChild(returnButton); + if (returnButton) + document.body.removeChild(returnButton); } static opponentHasQuit(opponentId)