mirror of
https://github.com/HexCardGames/HexDeck.git
synced 2025-09-05 03:08:39 +02:00
feat(frontend): add basic end screen
This commit is contained in:
@ -71,6 +71,13 @@
|
|||||||
"host": "Host",
|
"host": "Host",
|
||||||
"you": "Du"
|
"you": "Du"
|
||||||
},
|
},
|
||||||
|
"end_screen": {
|
||||||
|
"game_has_ended": "Das Spiel ist vorbei",
|
||||||
|
"player_won_the_game": "{player_name} hat das Spiel gewonnen!",
|
||||||
|
"you_won_the_game": "Du hast das Spiel gewonnen!",
|
||||||
|
"go_back": "Zurück",
|
||||||
|
"play_again": "Erneut spielen"
|
||||||
|
},
|
||||||
"player_status": {
|
"player_status": {
|
||||||
"connected": "Verbunden",
|
"connected": "Verbunden",
|
||||||
"disconnected": "Getrennt"
|
"disconnected": "Getrennt"
|
||||||
|
@ -73,6 +73,13 @@
|
|||||||
"player": "Player",
|
"player": "Player",
|
||||||
"return_to_game": "Return to game"
|
"return_to_game": "Return to game"
|
||||||
},
|
},
|
||||||
|
"end_screen": {
|
||||||
|
"game_has_ended": "The game has ended",
|
||||||
|
"player_won_the_game": "{player_name} has won the game!",
|
||||||
|
"you_won_the_game": "You have won the game!",
|
||||||
|
"go_back": "Go back",
|
||||||
|
"play_again": "Play again"
|
||||||
|
},
|
||||||
"player_status": {
|
"player_status": {
|
||||||
"connected": "Connected",
|
"connected": "Connected",
|
||||||
"disconnected": "Disconnected"
|
"disconnected": "Disconnected"
|
||||||
|
@ -66,8 +66,6 @@
|
|||||||
<Main />
|
<Main />
|
||||||
</div>
|
</div>
|
||||||
{:else if $sessionStore.gameState == GameState.Ended}
|
{:else if $sessionStore.gameState == GameState.Ended}
|
||||||
<div>
|
<EndScreen />
|
||||||
<EndScreen />
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -36,6 +36,7 @@ interface SessionData {
|
|||||||
playedCards: CardPlayedObj[];
|
playedCards: CardPlayedObj[];
|
||||||
ownCards: CardInfoObj[];
|
ownCards: CardInfoObj[];
|
||||||
playerStates: { [key: string]: PlayerStateObj };
|
playerStates: { [key: string]: PlayerStateObj };
|
||||||
|
winner: string | undefined;
|
||||||
}
|
}
|
||||||
interface RoomInfoObj {
|
interface RoomInfoObj {
|
||||||
RoomId: string;
|
RoomId: string;
|
||||||
@ -106,6 +107,7 @@ class SessionManager {
|
|||||||
playedCards: [],
|
playedCards: [],
|
||||||
ownCards: [],
|
ownCards: [],
|
||||||
playerStates: {},
|
playerStates: {},
|
||||||
|
winner: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
private socket: Socket | null = null;
|
private socket: Socket | null = null;
|
||||||
@ -297,6 +299,7 @@ class SessionManager {
|
|||||||
gameState: message.GameState,
|
gameState: message.GameState,
|
||||||
cardDeckId: message.CardDeckId,
|
cardDeckId: message.CardDeckId,
|
||||||
players: message.Players,
|
players: message.Players,
|
||||||
|
winner: message.Winner,
|
||||||
}));
|
}));
|
||||||
if (message.TopCard && get(this.store).playedCards.length == 0) {
|
if (message.TopCard && get(this.store).playedCards.length == 0) {
|
||||||
this.store.update((state) => ({
|
this.store.update((state) => ({
|
||||||
@ -416,6 +419,7 @@ class SessionManager {
|
|||||||
playedCards: [],
|
playedCards: [],
|
||||||
ownCards: [],
|
ownCards: [],
|
||||||
playerStates: {},
|
playerStates: {},
|
||||||
|
winner: undefined,
|
||||||
});
|
});
|
||||||
window.history.replaceState({}, "", "/");
|
window.history.replaceState({}, "", "/");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
<script>
|
||||||
|
import { CrownIcon, TimerIcon } from "lucide-svelte";
|
||||||
|
import { _ } from "svelte-i18n";
|
||||||
|
import { sessionStore } from "../../stores/sessionStore";
|
||||||
|
import { Button } from "flowbite-svelte";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex size-full justify-center items-center">
|
||||||
|
<div class="flex flex-col items-center gap-2">
|
||||||
|
{#if $sessionStore.winner == undefined}
|
||||||
|
<TimerIcon size={64} />
|
||||||
|
<span>{$_("end_screen.game_has_ended")}</span>
|
||||||
|
{:else}
|
||||||
|
<CrownIcon size={64} />
|
||||||
|
{#if $sessionStore.winner == sessionStore.getUserId()}
|
||||||
|
<span>{$_("end_screen.you_won_the_game")}</span>
|
||||||
|
{:else}
|
||||||
|
<span
|
||||||
|
>{$_("end_screen.player_won_the_game", {
|
||||||
|
values: { player_name: sessionStore.getUser($sessionStore.winner)?.Username },
|
||||||
|
})}</span
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
<div class="flex flex-row gap-3 mt-5">
|
||||||
|
<Button
|
||||||
|
color="alternative"
|
||||||
|
on:click={() => {
|
||||||
|
sessionStore.leaveRoom();
|
||||||
|
window.history.replaceState({}, "/Game", "/");
|
||||||
|
}}>{$_("end_screen.go_back")}</Button
|
||||||
|
>
|
||||||
|
<!-- TODO: implement rematch with the same players -->
|
||||||
|
<Button>{$_("end_screen.play_again")}</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
Reference in New Issue
Block a user