Skip to content

Commit

Permalink
Grayscale dead players (#49)
Browse files Browse the repository at this point in the history
* grayscale dead players

* better color
  • Loading branch information
lounsbrough authored Oct 1, 2024
1 parent 17812b8 commit 85ecf9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions client/src/components/game/Players.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,29 @@ function Players() {
<Grid2 container justifyContent="center" spacing={2}>
{gameState.players
.map(({ name, color, coins, influenceCount, deadInfluences }, index) => {
const playerColor = influenceCount
? color
: colord(color).grayscale().toHex()

return (
<Box
key={index}
sx={{
color: 'white',
alignContent: 'center',
background: color,
background: playerColor,
borderRadius: 3,
p: 1,
width: '6rem'
}}>
<Typography variant="h6" sx={{
fontWeight: 'bold',
color: colord(color).darken(colorModeFactor * 0.4).toHex()
color: colord(playerColor).darken(colorModeFactor * 0.4).toHex()
}}
>
<OverflowTooltip sx={{
textDecoration: influenceCount ? undefined : 'line-through',
}}>{name}</OverflowTooltip>
<OverflowTooltip>{name}</OverflowTooltip>
</Typography>
<Typography variant="h6" sx={{ color: colord(color).darken(colorModeFactor * 0.4).toHex() }}>
<Typography variant="h6" sx={{ color: colord(playerColor).darken(colorModeFactor * 0.4).toHex() }}>
<MonetizationOn sx={{ verticalAlign: 'text-bottom' }} />{` ${coins}`}
</Typography>
<Grid2
Expand All @@ -61,11 +63,11 @@ function Players() {
alignContent: 'center',
height: '44px',
width: '44px',
background: colord(color).darken(colorModeFactor * 0.25).toHex(),
background: colord(playerColor).darken(colorModeFactor * 0.25).toHex(),
padding: 0.5,
borderRadius: 2
}}>
<InfluenceIcon sx={{ fontSize: '32px', color: colord(color).lighten(colorModeFactor * 0.2).toHex() }} influence={influence} />
<InfluenceIcon sx={{ fontSize: '32px', color: colord(playerColor).lighten(colorModeFactor * 0.2).toHex() }} influence={influence} />
</Grid2>
)
})}
Expand Down
2 changes: 1 addition & 1 deletion server/src/game/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const addPlayerToGame = (state: GameState, playerId: string, playerName:
coins: 2,
influences: Array.from({ length: 2 }, () => drawCardFromDeck(state)),
deadInfluences: [],
color: ['#13CC63', '#0068FF', '#FD6C33', '#00CCDD', '#FFC303', '#FA0088'][state.players.length]
color: ['#13CC63', '#3399dd', '#FD6C33', '#00CCDD', '#FFC303', '#FA0088'][state.players.length]
})
}

Expand Down

0 comments on commit 85ecf9a

Please sign in to comment.