Integrate match score into each player card

Changed score display approach to show score directly on each player's card:
- Removed separate ScoreDisplay overlay component
- Added matchScore prop to LifeCounter component
- Created MatchScoreBadge: circular badge in corner of each player card
- Score only displays for 2-player games when score > 0
- Badge positioned in safe corner (adapts to rotation)
- Styled as 12vmin circle with 6vmin text, black/70 background

Score is now part of each player's area rather than a separate overlay.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Viktor Rådberg
2025-11-16 18:27:28 +01:00
parent 873d85ca18
commit c71dbc2769
3 changed files with 27 additions and 5 deletions

View File

@@ -24,6 +24,21 @@ const SettingsButtonTwc = twc.button<RotationButtonProps>((props) => [
: 'top-1/4 right-[1vmax]',
]);
const MatchScoreBadge = twc.div<RotationDivProps>((props) => [
'absolute flex items-center justify-center',
'bg-black/70 backdrop-blur-sm',
'rounded-full',
'w-[12vmin] h-[12vmin]',
'text-white font-bold',
'text-[6vmin]',
'z-[1]',
'pointer-events-none',
'select-none webkit-user-select-none',
props.$rotation === Rotation.Side || props.$rotation === Rotation.SideFlipped
? `left-[1vmax] top-1/4`
: 'left-1/4 top-[1vmax]',
]);
type SettingsButtonProps = {
onClick: () => void;
rotation: Rotation;
@@ -98,11 +113,12 @@ type LifeCounterProps = {
player: Player;
opponents: Player[];
isStartingPlayer?: boolean;
matchScore?: number;
};
const RECENT_DIFFERENCE_TTL = 3_000;
const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
const LifeCounter = ({ player, opponents, matchScore }: LifeCounterProps) => {
const { updatePlayer, updateLifeTotal } = usePlayers();
const { settings, playing } = useGlobalSettings();
const recentDifferenceTimerRef = useRef<NodeJS.Timeout | undefined>(
@@ -209,6 +225,14 @@ const LifeCounter = ({ player, opponents }: LifeCounterProps) => {
{player.hasLost && (
<PlayerLostWrapper $rotation={player.settings.rotation} />
)}
{matchScore !== undefined && matchScore > 0 && (
<MatchScoreBadge
$rotation={player.settings.rotation}
style={{ rotate: `${calcRotation}deg` }}
>
{matchScore}
</MatchScoreBadge>
)}
<CommanderDamageBar
opponents={opponents}
player={player}