diff --git a/frontend/src/domain/GameModel.tsx b/frontend/src/domain/GameModel.tsx
index 096ad9f..fffd683 100644
--- a/frontend/src/domain/GameModel.tsx
+++ b/frontend/src/domain/GameModel.tsx
@@ -91,13 +91,15 @@ export class Game {
public onGameCanceled(event: GameCanceledEvent): Game {
return this.copyWith({
- status: GameStatus.CANCELED
+ status: GameStatus.CANCELED,
+ currentQuestion: undefined
})
}
public onGameEnded(event: GameEndedEvent): Game {
return this.copyWith({
- status: GameStatus.ENDED
+ status: GameStatus.ENDED,
+ currentQuestion: undefined
})
}
diff --git a/frontend/src/pages/game/GameFinished.tsx b/frontend/src/pages/game/GameFinished.tsx
index 27ceb0e..8893e99 100644
--- a/frontend/src/pages/game/GameFinished.tsx
+++ b/frontend/src/pages/game/GameFinished.tsx
@@ -1,9 +1,8 @@
import {Game} from "../../domain/GameModel";
import React from "react";
-import {AppBar, Box, Button, Stack, Table, TableBody, TableCell, TableHead, TableRow, Toolbar, Typography} from "@mui/material";
+import {AppBar, Box, Button, Stack, Toolbar, Typography} from "@mui/material";
import Logout from "@mui/icons-material/Logout";
-import EmojiEvents from "@mui/icons-material/EmojiEvents";
-import {amber, brown, grey} from "@mui/material/colors";
+import {Scoreboard} from "./gameroom/Scoreboard.tsx";
export type GameFinishedPageProps = {
game: Game,
@@ -36,48 +35,7 @@ export const GameFinishedPage = (props: GameFinishedPageProps) => {
-
-
-
-
- Name
- Points
-
-
-
- {[...props.game.players].sort((u1, u2) => u2.points - u1.points).map((row, index) => {
- let cup;
- switch (index) {
- case 0:
- cup = ;
- break;
- case 1:
- cup = ;
- break;
- case 2:
- cup = ;
- break;
- }
- return (
-
- {cup}
-
-
- {row.name}
-
-
- {row.points}
-
- )
- })}
-
-
+
diff --git a/frontend/src/pages/game/gameroom/ModeratorGameRoomPanel.tsx b/frontend/src/pages/game/gameroom/ModeratorGameRoomPanel.tsx
index 9a742c3..700c48f 100644
--- a/frontend/src/pages/game/gameroom/ModeratorGameRoomPanel.tsx
+++ b/frontend/src/pages/game/gameroom/ModeratorGameRoomPanel.tsx
@@ -165,7 +165,7 @@ export const ModeratorGameRoomPanel = ({game}: ModeratorGameRoomPanelProps) => {
)
} else if (question.status === QuestionStatus.SCORED) {
return (
-
+
diff --git a/frontend/src/pages/game/gameroom/PlayerGameRoomPanel.tsx b/frontend/src/pages/game/gameroom/PlayerGameRoomPanel.tsx
index d65164b..c4cc58c 100644
--- a/frontend/src/pages/game/gameroom/PlayerGameRoomPanel.tsx
+++ b/frontend/src/pages/game/gameroom/PlayerGameRoomPanel.tsx
@@ -28,7 +28,7 @@ export const PlayerGameRoomPanel = ({game, player}: PlayerGameRoomPanelProps) =>
container =
Waiting for first question
} else if (question.status === QuestionStatus.OPEN) {
if (question.hasPlayerAlreadyAnswered(player.id)) {
- container =
+ return
@@ -57,7 +57,7 @@ export const PlayerGameRoomPanel = ({game, player}: PlayerGameRoomPanelProps) =>
}
}
- container =
+ return
} else if (question.questionMode === GameQuestionMode.BUZZER) {
const onBuzzQuestion = async () => {
try {
@@ -71,14 +71,13 @@ export const PlayerGameRoomPanel = ({game, player}: PlayerGameRoomPanelProps) =>
}
}
}
- container =
+ return
} else {
- container = Unknown gameQuestionMode {question.questionMode}
+ return Unknown gameQuestionMode {question.questionMode}
}
}
} else if (question.status === QuestionStatus.CLOSED) {
- container =
-
+ return
@@ -128,8 +127,7 @@ export const PlayerGameRoomPanel = ({game, player}: PlayerGameRoomPanelProps) =>
onClick={onNextQuestion}>Next question
}
- container =
-
+ return
{nextButton}
@@ -137,10 +135,10 @@ export const PlayerGameRoomPanel = ({game, player}: PlayerGameRoomPanelProps) =>
} else {
- container = Unknown state
+ return Unknown state
}
- return
+ return
{container}
}
diff --git a/frontend/src/pages/game/gameroom/Scoreboard.tsx b/frontend/src/pages/game/gameroom/Scoreboard.tsx
index 0938698..5b96b4d 100644
--- a/frontend/src/pages/game/gameroom/Scoreboard.tsx
+++ b/frontend/src/pages/game/gameroom/Scoreboard.tsx
@@ -5,6 +5,7 @@ import Cancel from "@mui/icons-material/Cancel";
import React, {useState} from "react";
import {ArrowBack, ArrowForward} from "@mui/icons-material";
import useWindowDimensions from "../../../hooks/useWindowDimensions.tsx";
+import Cookies from "js-cookie";
const comparePlayersByPointsAndName = function (p1: Player, p2: Player): number {
@@ -28,56 +29,89 @@ export type ScoreboardPageProps = {
const ScoreboardPage = ({game, page, pageSize}: ScoreboardPageProps) => {
const lastQuestion = game.currentQuestion
+ const username = Cookies.get("username")
const first = page * pageSize
const last = (page + 1) * pageSize
- return
-
-
-
- Username
- Answer
- Points
-
-
-
- {[...game.players].sort(comparePlayersByPointsAndName)
- .slice(first, last)
- .map((player, index) => {
- let icon
- let questionPoints
- const playerAnswer = lastQuestion?.answers.find(p => p.gamePlayerId === player.id)
-
- if (playerAnswer !== undefined) {
- icon = playerAnswer.points > 0 ? :
-
- questionPoints = "+" + playerAnswer.points
- } else {
- icon =
- questionPoints = "+0"
- }
-
- return (
-
- #{index + 1 + page * pageSize}
-
-
- {player.name}
-
-
-
-
- {icon} {playerAnswer?.answer}
-
-
- {questionPoints}
- {player.points}
-
- )
- })}
-
-
+ if (lastQuestion !== undefined) {
+ return
+
+
+
+ Username
+ Answer
+ Points
+
+
+
+ {[...game.players].sort(comparePlayersByPointsAndName)
+ .slice(first, last)
+ .map((player, index) => {
+ let icon
+ let questionPoints
+ const playerAnswer = lastQuestion?.answers.find(p => p.gamePlayerId === player.id)
+
+ if (playerAnswer !== undefined) {
+ icon = playerAnswer.points > 0 ? :
+
+ questionPoints = "+" + playerAnswer.points
+ } else {
+ icon =
+ questionPoints = "+0"
+ }
+
+ const fontWeight = player.name === username ? 'bold' : 'normal'
+
+ return (
+
+ #{index + 1 + page * pageSize}
+
+
+ {player.name}
+
+
+
+
+ {icon} {playerAnswer?.answer}
+
+
+ {questionPoints}
+ {player.points}
+
+ )
+ })}
+
+
+ } else {
+ return
+
+
+
+ Username
+ Points
+
+
+
+ {[...game.players].sort(comparePlayersByPointsAndName)
+ .slice(first, last)
+ .map((player, index) => {
+ const fontWeight = player.name === username ? 'bold' : 'normal'
+ return (
+
+ #{index + 1 + page * pageSize}
+
+
+ {player.name}
+
+
+ {player.points}
+
+ )
+ })}
+
+
+ }
}