Skip to content

Commit

Permalink
show who didnt mark ready
Browse files Browse the repository at this point in the history
  • Loading branch information
k2xl committed May 31, 2024
1 parent b278403 commit 43b5940
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion models/db/multiplayerMatch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface MultiplayerMatch {
};
levels: Level[] | Types.ObjectId[];
levelsPopulated: Level[]; // virtual
markedReady: Types.ObjectId[] | User[];
markedReady: Types.ObjectId[] | User[] | string[];
matchId: string;
matchLog?: MatchLog[];
players: UserWithMultiplayerProfile[];
Expand Down
26 changes: 19 additions & 7 deletions pages/[subdomain]/match/[matchId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,15 @@ export default function Match() {
return <span>Loading...</span>;
}

const playersNotMarkedReady = match.players.filter(player => !(match.markedReady as string[]).includes(player._id.toString()));
const prettyMatchState = ({
[MultiplayerMatchState.OPEN]: 'Match Open',
[MultiplayerMatchState.FINISHED]: 'Match Finished',
[MultiplayerMatchState.ACTIVE]: 'Match about to begin',
[MultiplayerMatchState.ABORTED]: 'Match Aborted',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)[match.state];

return (
<Page
isFullScreen={match.state === MultiplayerMatchState.ACTIVE && iAmPlaying}
Expand All @@ -419,13 +428,7 @@ export default function Match() {
<>
<h1 className={classNames('text-3xl font-bold text-center p-3', { 'hidden': matchInProgress })}>
{
({
[MultiplayerMatchState.OPEN]: 'Match Open',
[MultiplayerMatchState.FINISHED]: 'Match Finished',
[MultiplayerMatchState.ACTIVE]: 'Match about to begin',
[MultiplayerMatchState.ABORTED]: 'Match Aborted',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)[match.state]
prettyMatchState
}
</h1>
{/* if you are in the game and the game is about to start then say Your Record */}
Expand All @@ -434,6 +437,15 @@ export default function Match() {
Your record against {otherPlayer?.name} is {headToHead?.totalWins} - {headToHead?.totalLosses} - {headToHead?.totalTies}
</h2>
}
{ match.state === MultiplayerMatchState.ABORTED &&
<h2>
{playersNotMarkedReady.map(player => (
<div key={player._id.toString()} className='text-center text-xs italic'>
{player.name} did not mark ready
</div>
))}
</h2>
}
{connectedPlayersInRoom && connectedPlayersInRoom.count > 2 &&
<div className='absolute py-1 px-1.5 text-xs text-red-500'>
{connectedPlayersInRoom.count - 2} spectating
Expand Down

0 comments on commit 43b5940

Please sign in to comment.