75 lines
2.2 KiB
HTML
75 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Game Title</title>
|
|
<style>
|
|
#win-screen {
|
|
display: none;
|
|
font-size: 2em;
|
|
text-align: center;
|
|
margin-top: 20%;
|
|
color: white;
|
|
}
|
|
#losers-podium {
|
|
display: none;
|
|
font-size: 1.5em;
|
|
text-align: center;
|
|
color: white;
|
|
}
|
|
body {
|
|
background-color: #2C3235;
|
|
}
|
|
.flex {
|
|
display: flex;
|
|
justify-content:space-between;
|
|
align-items:center;
|
|
flex-direction: column;
|
|
height: 70vh;
|
|
}
|
|
</style>
|
|
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.3.2"></script>
|
|
</head>
|
|
<body>
|
|
<div class="flex">
|
|
<div id="win-screen"></div>
|
|
<div id="losers-podium"></div>
|
|
</div>
|
|
|
|
<script>
|
|
var gamestate = JSON.parse('{{ gamestate | tojson }}');
|
|
var players = [];
|
|
for (player in gamestate.players) {
|
|
gamestate.players[player]['name'] = player;
|
|
players.push(gamestate.players[player]);
|
|
}
|
|
players.sort((a, b) => b.points - a.points);
|
|
var winner = players.shift();
|
|
var winnerName = winner.name;
|
|
var winnerpoints = winner.points;
|
|
|
|
function showWinScreen() {
|
|
// Display confetti
|
|
confetti({
|
|
particleCount: 200,
|
|
spread: 80,
|
|
origin: { y: 0.6 }
|
|
});
|
|
|
|
// Display winner's name
|
|
var winScreen = document.getElementById('win-screen');
|
|
winScreen.innerHTML = "<strong>" + winnerName + "</strong> wins!" + "<br>" + "with <strong>" + winnerpoints + "</strong> points";
|
|
winScreen.style.display = 'block';
|
|
|
|
// Display losers
|
|
var losersPodium = document.getElementById('losers-podium');
|
|
losersPodium.innerHTML = "<strong>Losers:</strong><br>";
|
|
players.forEach(player => {
|
|
losersPodium.innerHTML += player.name + ": " + player.points + " points<br>";
|
|
});
|
|
losersPodium.style.display = 'block';
|
|
}
|
|
|
|
showWinScreen();
|
|
</script>
|
|
</body>
|
|
</html> |