Skip to content

Commit 8a6329c

Browse files
VitalyVitaly
authored andcommitted
Make swiss tournaments better
1 parent e8e1c9a commit 8a6329c

File tree

33 files changed

+437
-1455
lines changed

33 files changed

+437
-1455
lines changed

services/app/apps/codebattle/assets/js/widgets/pages/game/Notifications.jsx

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ import BackToTournamentButton from './BackToTournamentButton';
1818
import GameResult from './GameResult';
1919
import GoToNextGame from './GoToNextGame';
2020
import ReplayerControlButton from './ReplayerControlButton';
21-
import VideoConferenceButton from './VideoConferenceButton';
2221

2322
function Notifications() {
2423
const { mainService } = useContext(RoomContext);
25-
const roomMachineState = useMachineStateSelector(mainService, roomStateSelector);
24+
const roomMachineState = useMachineStateSelector(
25+
mainService,
26+
roomStateSelector,
27+
);
2628

2729
const { tournamentId } = useSelector(selectors.gameStatusSelector);
2830
const currentUserId = useSelector(selectors.currentUserIdSelector);
2931
const players = useSelector(selectors.gamePlayersSelector);
30-
const playbookSolutionType = useSelector(state => state.playbook.solutionType);
32+
const playbookSolutionType = useSelector(
33+
state => state.playbook.solutionType,
34+
);
3135
const tournamentsInfo = useSelector(state => state.game.tournamentsInfo);
3236
const tournament = useSelector(selectors.tournamentSelector);
3337
const isAdmin = useSelector(selectors.currentUserIsAdminSelector);
@@ -38,30 +42,39 @@ function Notifications() {
3842

3943
return (
4044
<>
41-
{roomMachineState.matches({ room: roomMachineStates.testing }) && <BackToTaskBuilderButton />}
42-
{(isAdmin
43-
&& !roomMachineState.matches({ replayer: replayerMachineStates.off })
44-
&& !roomMachineState.matches({ room: roomMachineStates.testing })
45-
) && <VideoConferenceButton />}
45+
{roomMachineState.matches({ room: roomMachineStates.testing }) && (
46+
<BackToTaskBuilderButton />
47+
)}
4648
<ReplayerControlButton />
47-
{(isCurrentUserPlayer && roomMachineState.matches({ room: roomMachineStates.gameOver }))
48-
&& (
49+
{isCurrentUserPlayer
50+
&& roomMachineState.matches({ room: roomMachineStates.gameOver }) && (
4951
<>
5052
<GameResult />
5153
<ActionsAfterGame />
5254
</>
5355
)}
54-
{(isAdmin && !roomMachineState.matches({ replayer: replayerMachineStates.off })) && (
55-
<>
56-
<ApprovePlaybookButtons playbookSolutionType={playbookSolutionType} />
57-
</>
56+
{isAdmin
57+
&& !roomMachineState.matches({ replayer: replayerMachineStates.off }) && (
58+
<>
59+
<ApprovePlaybookButtons
60+
playbookSolutionType={playbookSolutionType}
61+
/>
62+
</>
63+
)}
64+
{isTournamentGame && isActiveTournament && (
65+
<GoToNextGame
66+
tournamentsInfo={tournamentsInfo}
67+
currentUserId={currentUserId}
68+
/>
5869
)}
59-
{isTournamentGame && isActiveTournament
60-
&& <GoToNextGame tournamentsInfo={tournamentsInfo} currentUserId={currentUserId} />}
6170
{isTournamentGame && !isEventTournament && <BackToTournamentButton />}
62-
{isTournamentGame && isEventTournament && <BackToEventButton eventId={tournament?.eventId} />}
63-
{!isTournamentGame && !roomMachineState.matches({ room: roomMachineStates.testing })
64-
&& <BackToHomeButton />}
71+
{isTournamentGame && isEventTournament && (
72+
<BackToEventButton eventId={tournament?.eventId} />
73+
)}
74+
{!isTournamentGame
75+
&& !roomMachineState.matches({ room: roomMachineStates.testing }) && (
76+
<BackToHomeButton />
77+
)}
6578
</>
6679
);
6780
}

services/app/apps/codebattle/assets/js/widgets/pages/game/TournamentRankingTable.jsx

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ import GameStateCodes from '../../config/gameStateCodes';
1414
import { TournamentRemainingTimer } from '../tournament/TournamentHeader';
1515

1616
const getCustomEventTrClassName = (item, selectedId) => cn(
17-
'text-dark font-weight-bold cb-custom-event-tr-border',
18-
{
19-
'cb-gold-place-bg': item?.place === 1,
20-
'cb-silver-place-bg': item?.place === 2,
21-
'cb-bronze-place-bg': item?.place === 3,
22-
'bg-white': !item?.place || item?.place > 3,
23-
},
24-
{
25-
'cb-custom-event-tr-brown-border': item?.clanId === selectedId,
26-
},
27-
);
17+
'text-dark font-weight-bold cb-custom-event-tr-border',
18+
{
19+
'cb-gold-place-bg': item?.place === 1,
20+
'cb-silver-place-bg': item?.place === 2,
21+
'cb-bronze-place-bg': item?.place === 3,
22+
'bg-white': !item?.place || item?.place > 3,
23+
},
24+
{
25+
'cb-custom-event-tr-brown-border': item?.clanId === selectedId,
26+
},
27+
);
2828

2929
const tableDataCellClassName = cn(
3030
'p-1 pl-4 my-2 align-middle text-nowrap position-relative cb-custom-event-td border-0',
@@ -41,7 +41,7 @@ const TournamentRankingTable = () => {
4141
lastRoundStartedAt,
4242
matchTimeoutSeconds,
4343
ranking,
44-
roundTaskIds,
44+
taskIds,
4545
roundTimeoutSeconds,
4646
} = useSelector(tournamentSelector);
4747

@@ -85,35 +85,51 @@ const TournamentRankingTable = () => {
8585
) : (
8686
<tr className="cb-custom-event-empty-space-tr" />
8787
)}
88-
<tr className={getCustomEventTrClassName(item, currentUserClanId)}>
88+
<tr
89+
className={getCustomEventTrClassName(item, currentUserClanId)}
90+
>
8991
<td
90-
style={{ borderTopLeftRadius: '0.5rem', borderBottomLeftRadius: '0.5rem' }}
92+
style={{
93+
borderTopLeftRadius: '0.5rem',
94+
borderBottomLeftRadius: '0.5rem',
95+
}}
9196
className={tableDataCellClassName}
9297
>
9398
<div
9499
title={item?.name}
95100
className="cb-custom-event-name"
96101
style={{
97-
textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '13ch',
98-
}}
102+
textOverflow: 'ellipsis',
103+
overflow: 'hidden',
104+
whiteSpace: 'nowrap',
105+
maxWidth: '13ch',
106+
}}
99107
>
100-
{item?.name.slice(0, 9) + (item?.name.length > 11 ? '...' : '')}
108+
{item?.name.slice(0, 9)
109+
+ (item?.name.length > 11 ? '...' : '')}
101110
</div>
102111
</td>
103112
<td className={tableDataCellClassName}>
104113
<div
105114
title={item?.clan}
106115
className="cb-custom-event-name"
107116
style={{
108-
textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', maxWidth: '15ch',
109-
}}
117+
textOverflow: 'ellipsis',
118+
overflow: 'hidden',
119+
whiteSpace: 'nowrap',
120+
maxWidth: '15ch',
121+
}}
110122
>
111-
{item?.clan?.slice(0, 9) + (item?.clan?.length > 11 ? '...' : '')}
123+
{item?.clan?.slice(0, 9)
124+
+ (item?.clan?.length > 11 ? '...' : '')}
112125
</div>
113126
</td>
114127
<td className={tableDataCellClassName}>{item.score}</td>
115128
<td
116-
style={{ borderTopRightRadius: '0.5rem', borderBottomRightRadius: '0.5rem' }}
129+
style={{
130+
borderTopRightRadius: '0.5rem',
131+
borderBottomRightRadius: '0.5rem',
132+
}}
117133
className={tableDataCellClassName}
118134
>
119135
{item.place}
@@ -126,22 +142,20 @@ const TournamentRankingTable = () => {
126142
</div>
127143

128144
<div className="d-flex justify-content-around align-items-center mt-1">
129-
{
130-
(currentRoundPosition + 1 !== (roundTaskIds?.length || 0)
131-
&& gameStatus.state !== GameStateCodes.playing
132-
&& breakState === 'off') && (
133-
<span className="font-weight-bold me-3">
134-
{i18next.t('Round ends in ')}
135-
<TournamentRemainingTimer
136-
key={lastRoundStartedAt}
137-
startsAt={lastRoundStartedAt}
138-
duration={roundTimeoutSeconds || matchTimeoutSeconds}
139-
/>
140-
</span>
141-
)
142-
}
145+
{currentRoundPosition + 1 !== (taskIds?.length || 0)
146+
&& gameStatus.state !== GameStateCodes.playing
147+
&& breakState === 'off' && (
148+
<span className="font-weight-bold me-3">
149+
{i18next.t('Round ends in ')}
150+
<TournamentRemainingTimer
151+
key={lastRoundStartedAt}
152+
startsAt={lastRoundStartedAt}
153+
duration={roundTimeoutSeconds || matchTimeoutSeconds}
154+
/>
155+
</span>
156+
)}
143157

144-
{(gameStatus.state !== GameStateCodes.playing && breakState === 'on') && (
158+
{gameStatus.state !== GameStateCodes.playing && breakState === 'on' && (
145159
<span className="font-weight-bold me-3">
146160
{i18next.t('Next round will start in ')}
147161
<TournamentRemainingTimer
@@ -154,13 +168,13 @@ const TournamentRankingTable = () => {
154168
</div>
155169

156170
<div className="d-flex justify-content-around align-items-center mt-1">
157-
{roundTaskIds?.length > 0 && (
171+
{taskIds?.length > 0 && (
158172
<span className="font-weight-bold">
159173
{i18next.t('Task')}
160174
{': '}
161175
{currentRoundPosition + 1}
162176
/
163-
{roundTaskIds.length}
177+
{taskIds.length}
164178
</span>
165179
)}
166180
</div>

0 commit comments

Comments
 (0)