File tree Expand file tree Collapse file tree
hooks/useOpeningDrillController Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { buildUrl } from './utils'
22import { Color , TimeControl } from 'src/types'
33
4+ const normalizeOpeningBookFen = ( fen : string ) => {
5+ const parts = fen . trim ( ) . split ( / \s + / )
6+ if ( parts . length >= 4 ) {
7+ return parts . slice ( 0 , 4 ) . join ( ' ' )
8+ }
9+ return fen . trim ( )
10+ }
11+
412export const startGame = async (
513 playerColor : Color ,
614 maiaVersion : string ,
@@ -107,27 +115,36 @@ export const fetchGameMove = async (
107115}
108116
109117export const fetchOpeningBookMoves = async ( fen : string ) => {
110- const res = await fetch ( buildUrl ( `play/get_book_moves?fen=${ fen } ` ) , {
111- method : 'POST' ,
112- headers : {
113- Accept : 'application/json' ,
114- 'Content-Type' : 'application/json' ,
118+ const normalizedFen = normalizeOpeningBookFen ( fen )
119+ const res = await fetch (
120+ buildUrl (
121+ 'play/get_book_moves?' +
122+ new URLSearchParams ( {
123+ fen : normalizedFen ,
124+ } ) ,
125+ ) ,
126+ {
127+ method : 'POST' ,
128+ headers : {
129+ Accept : 'application/json' ,
130+ 'Content-Type' : 'application/json' ,
131+ } ,
132+ body : JSON . stringify ( {
133+ moves : [ ] ,
134+ maia_names : [
135+ 'maia_kdd_1100' ,
136+ 'maia_kdd_1200' ,
137+ 'maia_kdd_1300' ,
138+ 'maia_kdd_1400' ,
139+ 'maia_kdd_1500' ,
140+ 'maia_kdd_1600' ,
141+ 'maia_kdd_1700' ,
142+ 'maia_kdd_1800' ,
143+ 'maia_kdd_1900' ,
144+ ] ,
145+ } ) ,
115146 } ,
116- body : JSON . stringify ( {
117- moves : [ ] ,
118- maia_names : [
119- 'maia_kdd_1100' ,
120- 'maia_kdd_1200' ,
121- 'maia_kdd_1300' ,
122- 'maia_kdd_1400' ,
123- 'maia_kdd_1500' ,
124- 'maia_kdd_1600' ,
125- 'maia_kdd_1700' ,
126- 'maia_kdd_1800' ,
127- 'maia_kdd_1900' ,
128- ] ,
129- } ) ,
130- } )
147+ )
131148
132149 return res . json ( )
133150}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ interface Props {
1616 analysisEnabled ?: boolean
1717 continueAnalyzingMode ?: boolean
1818 drillTerminationNote ?: string
19+ showBottomNavigation ?: boolean
1920}
2021
2122export const OpeningDrillSidebar : React . FC < Props > = ( {
@@ -28,6 +29,7 @@ export const OpeningDrillSidebar: React.FC<Props> = ({
2829 analysisEnabled,
2930 continueAnalyzingMode,
3031 drillTerminationNote,
32+ showBottomNavigation = true ,
3133} ) => {
3234 const containerClass = embedded
3335 ? 'flex h-full w-full max-w-full flex-col'
@@ -304,7 +306,7 @@ export const OpeningDrillSidebar: React.FC<Props> = ({
304306 </ div >
305307
306308 { /* Bottom: Moves + Controller (embedded) */ }
307- { tree ?. gameTree && currentDrill && (
309+ { showBottomNavigation && tree ?. gameTree && currentDrill && (
308310 < div className = "flex w-full flex-1 flex-col overflow-hidden border-t border-glass-border" >
309311 < div className = "red-scrollbar flex w-full flex-1 flex-col overflow-y-auto overflow-x-hidden" >
310312 < MovesContainer
You can’t perform that action at this time.
0 commit comments