@@ -3,12 +3,16 @@ import { useAppContext } from '../../../app-context'
33import { TournamentGameElement } from './tournament-game'
44import Tournament , { TournamentGame , TournamentState } from '../../../playback/Tournament'
55import { Space } from 'react-zoomable-ui'
6+ import { useSearchParamNumber } from '../../../app-search-params'
67
78export const TournamentRenderer : React . FC = ( ) => {
89 const appContext = useAppContext ( )
910
1011 const spaceRef = useRef < Space | null > ( null )
1112
13+ const [ tournamentWinnerStart ] = useSearchParamNumber ( 'tournamentWinnerStart' , 0 )
14+ const [ tournamentLoserStart ] = useSearchParamNumber ( 'tournamentLoserStart' , 0 )
15+
1216 const tournament = appContext . state . tournament
1317 const tournamentState = appContext . state . tournamentState
1418
@@ -20,6 +24,8 @@ export const TournamentRenderer: React.FC = () => {
2024 tournament = { tournament }
2125 tournamentState = { tournamentState }
2226 spaceRef = { spaceRef . current }
27+ winnerStart = { tournamentWinnerStart }
28+ loserStart = { tournamentLoserStart }
2329 />
2430 ) : (
2531 < > Missing Tournament</ >
@@ -33,6 +39,8 @@ interface TournamentTreeProps {
3339 tournament : Tournament
3440 tournamentState : TournamentState
3541 spaceRef : Space
42+ winnerStart : number
43+ loserStart : number
3644}
3745
3846const TournamentTree : React . FC < TournamentTreeProps > = ( props ) => {
@@ -62,6 +70,8 @@ const TournamentTree: React.FC<TournamentTreeProps> = (props) => {
6270 game = { rootGame }
6371 tournamentState = { props . tournamentState }
6472 spaceRef = { props . spaceRef }
73+ winnerStart = { props . winnerStart }
74+ loserStart = { props . loserStart }
6575 />
6676 { bracketTitle && (
6777 < div className = "text-white pt-2 text-center border-t border-white" > { bracketTitle } </ div >
@@ -76,6 +86,8 @@ interface TournamentGameWrapperProps {
7686 game : TournamentGame
7787 tournamentState : TournamentState
7888 spaceRef : Space
89+ winnerStart : number
90+ loserStart : number
7991}
8092
8193const TournamentGameWrapper : React . FC < TournamentGameWrapperProps > = ( props ) => {
@@ -128,11 +140,13 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
128140 let round = Math . abs ( props . game . round )
129141 let minRound = props . tournamentState . minRoundWinners
130142 let maxRound = props . tournamentState . maxRoundWinners
143+ let startRound = props . winnerStart
131144 if ( Math . sign ( props . game . round ) < 0 ) {
132145 minRound = props . tournamentState . minRoundLosers
133146 maxRound = props . tournamentState . maxRoundLosers
147+ startRound = props . loserStart
134148 }
135- if ( round < minRound ) {
149+ if ( round < minRound || round < startRound ) {
136150 props . game . viewed = true
137151 }
138152
@@ -155,6 +169,8 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
155169 game = { dependA }
156170 tournamentState = { props . tournamentState }
157171 spaceRef = { props . spaceRef }
172+ winnerStart = { props . winnerStart }
173+ loserStart = { props . loserStart }
158174 />
159175 </ div >
160176 ) }
@@ -164,6 +180,8 @@ const TournamentGameWrapper: React.FC<TournamentGameWrapperProps> = (props) => {
164180 game = { dependB }
165181 tournamentState = { props . tournamentState }
166182 spaceRef = { props . spaceRef }
183+ winnerStart = { props . winnerStart }
184+ loserStart = { props . loserStart }
167185 />
168186 </ div >
169187 ) }
0 commit comments