@@ -123,12 +123,12 @@ function Board({gameState, setGameState}) {
123
123
124
124
useEffect ( ( ) => {
125
125
let onKeyDown = ( e ) => {
126
- if ( e . ctrlKey ) {
126
+ if ( e . ctrlKey || e . shiftKey ) {
127
127
setCtrlKeyDown ( true )
128
128
}
129
129
}
130
130
let onKeyUp = ( e ) => {
131
- if ( ! e . ctrlKey ) {
131
+ if ( ! e . shiftKey && ! e . shiftKey ) {
132
132
setCtrlKeyDown ( false )
133
133
}
134
134
}
@@ -151,20 +151,24 @@ function Board({gameState, setGameState}) {
151
151
if ( gameHasEnded ( gameState ) ) {
152
152
return undefined
153
153
}
154
- if ( ! gameState . counting ) {
154
+ if ( ! counting ) {
155
155
return undefined
156
156
}
157
157
if ( ! isCursorInBounds ( ) ) {
158
158
return undefined
159
159
}
160
160
let x = cursorXref . current
161
161
let y = cursorYref . current
162
- let { has, hasStone} = board [ x ] [ y ]
162
+ let { has, hasStone} = board [ y ] [ x ]
163
163
if ( ! hasStone ) {
164
164
return undefined
165
165
}
166
166
return has
167
- } , [ gameState , board , isCursorInBounds ] )
167
+ } , [ gameState , counting , board , isCursorInBounds ] )
168
+
169
+ let showMoveNumbers = useCallback ( ( ) => {
170
+ return ctrlKeyDownRef . current && ( isKibitz ( gameState , auth ) || gameHasEnded ( gameState ) )
171
+ } , [ gameState , auth ] )
168
172
169
173
let context = useMemo ( ( ) => {
170
174
let dim = board . length
@@ -215,7 +219,6 @@ function Board({gameState, setGameState}) {
215
219
step,
216
220
grid,
217
221
canvasRef,
218
- ctrlKeyDownRef,
219
222
cursorXref,
220
223
cursorYref,
221
224
hoshis : hoshis ,
@@ -233,7 +236,7 @@ function Board({gameState, setGameState}) {
233
236
return
234
237
}
235
238
let dim = board . length
236
- setCtrlKeyDown ( e . ctrlKey )
239
+ setCtrlKeyDown ( e . shiftKey || e . ctrlKey )
237
240
let cursor_x = Math . round ( ( e . nativeEvent . offsetX - context . margin ) / context . step )
238
241
let cursor_y = Math . round ( ( e . nativeEvent . offsetY - context . margin ) / context . step )
239
242
if ( cursor_x >= 0 && cursor_x < dim && cursor_y >= 0 && cursor_y < dim ) {
@@ -299,16 +302,15 @@ function Board({gameState, setGameState}) {
299
302
return
300
303
}
301
304
paintGrid ( context )
302
- let showMoveNumbers = ctrlKeyDownRef . current && ( isKibitz ( gameState , auth ) || gameHasEnded ( gameState ) )
303
305
if ( counting && ! isReviewing ( gameState ) ) {
304
- paintStonesCounting ( context , board , getCountingGroup ( ) )
305
- if ( showMoveNumbers ) {
306
+ paintStonesCounting ( context , board , getCountingGroup ( ) , showMoveNumbers ( ) )
307
+ if ( showMoveNumbers ( ) ) {
306
308
paintMoveNumbers ( context , board )
307
309
}
308
310
return
309
311
}
310
- paintStones ( context , board , showMoveNumbers )
311
- if ( showMoveNumbers ) {
312
+ paintStones ( context , board , showMoveNumbers ( ) )
313
+ if ( showMoveNumbers ( ) ) {
312
314
paintMoveNumbers ( context , board )
313
315
} else {
314
316
paintLastMove ( context , lastMove )
@@ -329,7 +331,7 @@ function Board({gameState, setGameState}) {
329
331
return
330
332
}
331
333
paintShadow ( context , cursor_x , cursor_y , currentColor ( gameState ) )
332
- } , [ gameState , context , cursor_x , cursor_y , ctrlKeyDown , canvasRef , auth , board , counting , forbidden_x , forbidden_y , lastMove , isCursorInBounds , getCountingGroup ] )
334
+ } , [ gameState , context , cursor_x , cursor_y , ctrlKeyDown , canvasRef , auth , board , counting , forbidden_x , forbidden_y , lastMove , isCursorInBounds , getCountingGroup , showMoveNumbers ] )
333
335
334
336
useEffect ( ( ) => {
335
337
if ( id === gameId && queueStatus === "up_to_date" ) {
@@ -359,7 +361,11 @@ function Board({gameState, setGameState}) {
359
361
360
362
return (
361
363
< div className = "grid h-full" >
362
- < canvas className = { twJoin ( "place-self-center" ) } ref = { canvasRef }
364
+ < canvas className = { twJoin (
365
+ "place-self-center" ,
366
+ isCursorInBounds ( ) && showMoveNumbers ( ) && board [ cursor_y ] [ cursor_x ] . hasStone && "cursor-pointer" ,
367
+ ) }
368
+ ref = { canvasRef }
363
369
onMouseLeave = { ( ) => {
364
370
setCursor_x ( - 1 )
365
371
setCursor_y ( - 1 )
0 commit comments