@@ -3,12 +3,16 @@ import { useAppContext } from '../../../app-context'
3
3
import { TournamentGameElement } from './tournament-game'
4
4
import Tournament , { TournamentGame , TournamentState } from '../../../playback/Tournament'
5
5
import { Space } from 'react-zoomable-ui'
6
+ import { useSearchParamNumber } from '../../../app-search-params'
6
7
7
8
export const TournamentRenderer : React . FC = ( ) => {
8
9
const appContext = useAppContext ( )
9
10
10
11
const spaceRef = useRef < Space | null > ( null )
11
12
13
+ const [ tournamentWinnerStart ] = useSearchParamNumber ( 'tournamentWinnerStart' , 0 )
14
+ const [ tournamentLoserStart ] = useSearchParamNumber ( 'tournamentLoserStart' , 0 )
15
+
12
16
const tournament = appContext . state . tournament
13
17
const tournamentState = appContext . state . tournamentState
14
18
@@ -20,6 +24,8 @@ export const TournamentRenderer: React.FC = () => {
20
24
tournament = { tournament }
21
25
tournamentState = { tournamentState }
22
26
spaceRef = { spaceRef . current }
27
+ winnerStart = { tournamentWinnerStart }
28
+ loserStart = { tournamentLoserStart }
23
29
/>
24
30
) : (
25
31
< > Missing Tournament</ >
@@ -33,6 +39,8 @@ interface TournamentTreeProps {
33
39
tournament : Tournament
34
40
tournamentState : TournamentState
35
41
spaceRef : Space
42
+ winnerStart : number
43
+ loserStart : number
36
44
}
37
45
38
46
const TournamentTree : React . FC < TournamentTreeProps > = ( props ) => {
@@ -62,6 +70,8 @@ const TournamentTree: React.FC<TournamentTreeProps> = (props) => {
62
70
game = { rootGame }
63
71
tournamentState = { props . tournamentState }
64
72
spaceRef = { props . spaceRef }
73
+ winnerStart = { props . winnerStart }
74
+ loserStart = { props . loserStart }
65
75
/>
66
76
{ bracketTitle && (
67
77
< div className = "text-white pt-2 text-center border-t border-white" > { bracketTitle } </ div >
@@ -76,6 +86,8 @@ interface TournamentGameWrapperProps {
76
86
game : TournamentGame
77
87
tournamentState : TournamentState
78
88
spaceRef : Space
89
+ winnerStart : number
90
+ loserStart : number
79
91
}
80
92
81
93
const TournamentGameWrapper : React . FC < TournamentGameWrapperProps > = ( props ) => {
@@ -128,11 +140,13 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
128
140
let round = Math . abs ( props . game . round )
129
141
let minRound = props . tournamentState . minRoundWinners
130
142
let maxRound = props . tournamentState . maxRoundWinners
143
+ let startRound = props . winnerStart
131
144
if ( Math . sign ( props . game . round ) < 0 ) {
132
145
minRound = props . tournamentState . minRoundLosers
133
146
maxRound = props . tournamentState . maxRoundLosers
147
+ startRound = props . loserStart
134
148
}
135
- if ( round < minRound ) {
149
+ if ( round < minRound || round < startRound ) {
136
150
props . game . viewed = true
137
151
}
138
152
@@ -155,6 +169,8 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
155
169
game = { dependA }
156
170
tournamentState = { props . tournamentState }
157
171
spaceRef = { props . spaceRef }
172
+ winnerStart = { props . winnerStart }
173
+ loserStart = { props . loserStart }
158
174
/>
159
175
</ div >
160
176
) }
@@ -164,6 +180,8 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
164
180
game = { dependB }
165
181
tournamentState = { props . tournamentState }
166
182
spaceRef = { props . spaceRef }
183
+ winnerStart = { props . winnerStart }
184
+ loserStart = { props . loserStart }
167
185
/>
168
186
</ div >
169
187
) }
0 commit comments