@@ -6,6 +6,9 @@ import WikiLink from './WikiLink';
66import { useGridMasterContext } from '../context/GridMasterContext' ;
77import type { GridMasterTile } from '../types/grid-master' ;
88
9+ const cols = [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' ] ;
10+ const rows = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' ] ;
11+
912export default function GridMasterBoard ( ) {
1013 const { tiles } = useGridMasterContext ( ) ;
1114 return (
@@ -26,15 +29,19 @@ export default function GridMasterBoard() {
2629}
2730
2831function GridMasterTaskTile ( { tile } : { tile : GridMasterTile } ) {
29- const { flipped, hideUnconfirmed } = useGridMasterContext ( ) ;
32+ const { checked, checkable, flipped, hideUnconfirmed, toggleChecked } =
33+ useGridMasterContext ( ) ;
3034 const cell = `${ tile . col } ${ tile . row } ` ;
3135 const unknown =
3236 ( flipped ? ! Boolean ( tile . reward ) : ! Boolean ( tile . task ) ) ||
3337 Boolean ( tile . unconfirmed && hideUnconfirmed ) ;
3438 return (
3539 < TooltipWrapper
3640 id = { cell }
37- className = "grid-master__cell"
41+ className = { classNames ( 'grid-master__cell' , {
42+ unchecked : checkable && ! Boolean ( checked [ cell ] ) ,
43+ checked : checkable && Boolean ( checked [ cell ] ) ,
44+ } ) }
3845 tooltip = {
3946 flipped && ! unknown && tile . rewardDescription ? (
4047 < div style = { { maxWidth : '360px' } } >
@@ -70,6 +77,17 @@ function GridMasterTaskTile({ tile }: { tile: GridMasterTile }) {
7077 [ `grid-master__tile--${ tile . type } ` ] : tile . type ,
7178 'grid-master__tile--unknown' : unknown ,
7279 } ) }
80+ draggable = { false }
81+ onClick = {
82+ checkable
83+ ? e => {
84+ if ( ! e . ctrlKey ) {
85+ e . preventDefault ( ) ;
86+ toggleChecked ( cell ) ;
87+ }
88+ }
89+ : undefined
90+ }
7391 wikiId = {
7492 ( ! unknown && ( flipped ? tile . rewardLink : tile . taskLink ) ) ||
7593 'Grid_Master'
@@ -87,14 +105,21 @@ function GridMasterTaskTile({ tile }: { tile: GridMasterTile }) {
87105}
88106
89107function GridMasterRewardTile ( { tile } : { tile : GridMasterTile } ) {
90- const { hideUnconfirmed } = useGridMasterContext ( ) ;
108+ const { checked , checkable , hideUnconfirmed } = useGridMasterContext ( ) ;
91109 const cell = `${ tile . col } ${ tile . row } ` ;
92110 const unknown =
93111 ! Boolean ( tile . reward ) || Boolean ( tile . unconfirmed && hideUnconfirmed ) ;
112+ const completed =
113+ tile . col === 'R'
114+ ? cols . every ( col => Boolean ( checked [ `${ col } ${ tile . row } ` ] ) )
115+ : rows . every ( row => Boolean ( checked [ `${ tile . col } ${ row } ` ] ) ) ;
94116 return (
95117 < TooltipWrapper
96118 id = { cell }
97- className = "grid-master__cell"
119+ className = { classNames ( 'grid-master__cell' , {
120+ unchecked : checkable && ! completed ,
121+ checked : checkable && completed ,
122+ } ) }
98123 tooltip = {
99124 ! unknown && tile . rewardDescription ? (
100125 < div style = { { maxWidth : '360px' } } >
0 commit comments