diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.json index 92a7e50..ed3d1f2 100644 --- a/frontend/src/i18n/de.json +++ b/frontend/src/i18n/de.json @@ -71,6 +71,13 @@ "host": "Host", "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": { "connected": "Verbunden", "disconnected": "Getrennt" diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 08bdc0f..8b896d7 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -73,6 +73,13 @@ "player": "Player", "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": { "connected": "Connected", "disconnected": "Disconnected" diff --git a/frontend/src/routes/Game.svelte b/frontend/src/routes/Game.svelte index ef0cb65..5a18df4 100644 --- a/frontend/src/routes/Game.svelte +++ b/frontend/src/routes/Game.svelte @@ -66,8 +66,6 @@
{:else if $sessionStore.gameState == GameState.Ended} -
- -
+ {/if} {/if} diff --git a/frontend/src/stores/sessionStore.ts b/frontend/src/stores/sessionStore.ts index 9924407..1176b28 100644 --- a/frontend/src/stores/sessionStore.ts +++ b/frontend/src/stores/sessionStore.ts @@ -36,6 +36,7 @@ interface SessionData { playedCards: CardPlayedObj[]; ownCards: CardInfoObj[]; playerStates: { [key: string]: PlayerStateObj }; + winner: string | undefined; } interface RoomInfoObj { RoomId: string; @@ -106,6 +107,7 @@ class SessionManager { playedCards: [], ownCards: [], playerStates: {}, + winner: undefined, }); private socket: Socket | null = null; @@ -297,6 +299,7 @@ class SessionManager { gameState: message.GameState, cardDeckId: message.CardDeckId, players: message.Players, + winner: message.Winner, })); if (message.TopCard && get(this.store).playedCards.length == 0) { this.store.update((state) => ({ @@ -416,6 +419,7 @@ class SessionManager { playedCards: [], ownCards: [], playerStates: {}, + winner: undefined, }); window.history.replaceState({}, "", "/"); } diff --git a/frontend/src/views/Game/EndScreen.svelte b/frontend/src/views/Game/EndScreen.svelte index e69de29..8b16e15 100644 --- a/frontend/src/views/Game/EndScreen.svelte +++ b/frontend/src/views/Game/EndScreen.svelte @@ -0,0 +1,37 @@ + + +
+
+ {#if $sessionStore.winner == undefined} + + {$_("end_screen.game_has_ended")} + {:else} + + {#if $sessionStore.winner == sessionStore.getUserId()} + {$_("end_screen.you_won_the_game")} + {:else} + {$_("end_screen.player_won_the_game", { + values: { player_name: sessionStore.getUser($sessionStore.winner)?.Username }, + })} + {/if} + {/if} +
+ + + +
+
+