Tournament
- fix bug with final 1v1 between bot and bot - add time before change page at end of tournament - remove event listener in typeTournament
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/06 16:33:56 by tomoron #+# #+# #
|
||||
# Updated: 2024/10/22 18:40:34 by tomoron ### ########.fr #
|
||||
# Updated: 2024/11/11 10:27:03 by edbernar ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -44,7 +44,7 @@ class GameSettings:
|
||||
wallLength = 1
|
||||
wallWidth = 0.05
|
||||
bounceSpeedIncrease = 0.2
|
||||
maxScore = 3
|
||||
maxScore = 1
|
||||
|
||||
maxPlayerSpeed = 4
|
||||
playerSpeedTolerance = 0.15
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/28 12:23:48 by edbernar #+# #+# */
|
||||
/* Updated: 2024/09/27 23:56:31 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/11/11 10:26:38 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:42:29 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/27 23:40:49 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/11/11 11:41:30 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -177,19 +177,23 @@ class TournamentPage
|
||||
loserPos = player2Nb + (player2Nb % 2 == 0 ? player2Nb - 1 : player2Nb);
|
||||
else
|
||||
loserPos = player1Nb + (player1Nb % 2 == 0 ? player1Nb - 1 : player1Nb);
|
||||
if (playerNb.indexOf(pos) == -1)
|
||||
{
|
||||
pos = playerNb[0] + playerNb[1] + playerNb[2] + playerNb[3];
|
||||
loserPos = playerNb[4] + playerNb[5] + playerNb[6] + playerNb[7];
|
||||
}
|
||||
document.getElementById('pfp-' + pos).style.backgroundImage = `url(${winnerData.pfp})`;
|
||||
console.log("loserPos : ", loserPos);
|
||||
document.getElementById('pfp-' + loserPos).style.backgroundImage = `linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('${playerList['player' + (content.p1Win ? player2Nb : player1Nb)].pfp}')`;
|
||||
}
|
||||
}
|
||||
|
||||
end(content)
|
||||
static end(content)
|
||||
{
|
||||
console.log("Tournament is over. The winner is : ", playerList['player' + playerNb[content.winnerId]]);
|
||||
newInfo(`The winner is : ${playerList['player' + playerNb[content.winnerId]].username}`);
|
||||
timeout = setTimeout(() => {
|
||||
pageRenderer.changePage("lobbyPage", false);
|
||||
});
|
||||
}, 4000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/01 13:29:50 by edbernar #+# #+# */
|
||||
/* Updated: 2024/10/27 23:30:11 by edbernar ### ########.fr */
|
||||
/* Updated: 2024/11/11 11:41:31 by edbernar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -68,88 +68,4 @@ function joinTournament(content)
|
||||
}
|
||||
}
|
||||
|
||||
export { typeTournament };
|
||||
|
||||
|
||||
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.key === "a")
|
||||
{
|
||||
|
||||
typeTournament(
|
||||
{
|
||||
"action": 5,
|
||||
"players": [
|
||||
// {
|
||||
// "id": 0,
|
||||
// "username": "edbernar",
|
||||
// "pfp": "/static/img/default_pfp.jpg"
|
||||
// },
|
||||
{
|
||||
"id": 1,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"username": "bot",
|
||||
"pfp": "/static/img/robot_pfp.jpg"
|
||||
}
|
||||
],
|
||||
"messages": [],
|
||||
"history": [
|
||||
{
|
||||
"p1": 3,
|
||||
"p2": 2,
|
||||
"p1Win": true
|
||||
},
|
||||
{
|
||||
"p1": 5,
|
||||
"p2": 4,
|
||||
"p1Win": true
|
||||
},
|
||||
{
|
||||
"p1": 7,
|
||||
"p2": 6,
|
||||
"p1Win": true
|
||||
},
|
||||
{
|
||||
"p1": 7,
|
||||
"p2": 5,
|
||||
"p1Win": true
|
||||
},
|
||||
{
|
||||
"p1": 1,
|
||||
"p2": 0,
|
||||
"p1Win": false
|
||||
}
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
export { typeTournament };
|
Reference in New Issue
Block a user