Keep last round's summary visible until all bids are placed
The round summary used to disappear after a fixed 5 seconds. It is now derived from the game state: the previous round's result is shown while the new round is in bidding and hides once card play starts. This also survives a page reload. - Drop the client-side round timer from useWizard - On narrow screens show the summary in the page flow so it does not cover the bid buttons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import type { GameView, Lobby, RoundResult, TrickResult } from '../../api/types'
|
||||
import type { GameView, Lobby, TrickResult } from '../../api/types'
|
||||
import type { WizardActions } from '../../api/useWizard'
|
||||
import { Button } from '../../components/Button/Button'
|
||||
import { Modal } from '../../components/Modal/Modal'
|
||||
@@ -19,11 +19,10 @@ interface GameScreenProps {
|
||||
game: GameView
|
||||
playerId: string
|
||||
completedTrick: TrickResult | null
|
||||
completedRound: RoundResult | null
|
||||
actions: WizardActions
|
||||
}
|
||||
|
||||
export function GameScreen({ lobby, game, playerId, completedTrick, completedRound, actions }: GameScreenProps) {
|
||||
export function GameScreen({ lobby, game, playerId, completedTrick, actions }: GameScreenProps) {
|
||||
const [showScores, setShowScores] = useState(false)
|
||||
const [confirmLeave, setConfirmLeave] = useState(false)
|
||||
|
||||
@@ -62,6 +61,12 @@ export function GameScreen({ lobby, game, playerId, completedTrick, completedRou
|
||||
else if (trumpCard?.kind === 'wizard') trumpText = 'Wizard turned up — no trump'
|
||||
else if (trumpCard?.kind === 'jester') trumpText = 'Jester turned up — no trump'
|
||||
|
||||
// The result of the previous round stays visible until everyone has bid in
|
||||
// the new round (i.e. until the round moves on to playing cards).
|
||||
const previousRound = obs.round_history.at(-1)
|
||||
const showPreviousRound =
|
||||
obs.phase === 'bidding' && previousRound !== undefined && previousRound.round_number === obs.round_number - 1
|
||||
|
||||
return (
|
||||
<main className={styles.page}>
|
||||
<header className={styles.topBar}>
|
||||
@@ -82,6 +87,8 @@ export function GameScreen({ lobby, game, playerId, completedTrick, completedRou
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{showPreviousRound && <RoundSummary result={previousRound} players={players} />}
|
||||
|
||||
<section className={styles.opponents}>
|
||||
{opponents.map((seat) => (
|
||||
<PlayerSeat key={seat} observation={obs} seat={seat} player={players[seat]} />
|
||||
@@ -112,7 +119,6 @@ export function GameScreen({ lobby, game, playerId, completedTrick, completedRou
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{completedRound && obs.phase !== 'finished' && <RoundSummary result={completedRound} players={players} />}
|
||||
|
||||
{showScores && (
|
||||
<Modal title="Scoreboard" wide onClose={() => setShowScores(false)}>
|
||||
|
||||
@@ -66,12 +66,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* On small screens it would cover the bid buttons; show it in the page flow instead. */
|
||||
@media (max-width: 720px) {
|
||||
.summary {
|
||||
top: auto;
|
||||
right: 50%;
|
||||
bottom: 16px;
|
||||
transform: translateX(50%);
|
||||
animation: none;
|
||||
position: static;
|
||||
width: 100%;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user