@@ -7,14 +7,15 @@ import type { CellRenderer } from '@/ps/games/render';
77import type { Scrabble } from '@/ps/games/scrabble' ;
88import type { Log } from '@/ps/games/scrabble/logs' ;
99import type { BoardTile , Bonus , RenderCtx } from '@/ps/games/scrabble/types' ;
10- import type { ReactElement , ReactNode } from 'react' ;
10+ import type { CSSProperties , ReactElement , ReactNode } from 'react' ;
11+ import { WIDE_LETTERS } from '@/ps/games/scrabble/constants' ;
1112
1213export function renderMove ( logEntry : Log , { id, players, $T, renderCtx : { msg } } : Scrabble ) : [ ReactElement , { name : string } ] {
1314 const Wrapper = ( { children } : { children : ReactNode } ) : ReactElement => (
1415 < >
1516 < hr />
1617 { children }
17- < Button name = "send" value = { `${ msg } watch ${ id } ` } style = { { float : 'right' } } >
18+ < Button name = "send" value = { `${ msg } watch` } style = { { float : 'right' } } >
1819 Watch!
1920 </ Button >
2021 < hr />
@@ -92,6 +93,12 @@ function renderBoard(this: This, ctx: RenderCtx) {
9293 const Cell : CellRenderer < BoardTile | null > = ( { cell, i, j } ) : ReactElement => {
9394 const baseCell = ctx . baseBoard [ i ] [ j ] ;
9495 const isSelected = ! ! ctx . selected && coincident ( [ i , j ] , ctx . selected ) ;
96+ const buttonStyles : CSSProperties = {
97+ border : ! isSelected ? 'none' : undefined ,
98+ background : 'none' ,
99+ height : 20 ,
100+ width : 20 ,
101+ } ;
95102 return (
96103 < td
97104 style = { {
@@ -103,15 +110,13 @@ function renderBoard(this: This, ctx: RenderCtx) {
103110 >
104111 { cell ? (
105112 < Button
106- value = { `${ this . msg } ! ${ ctx . id } , s${ encodePos ( [ i , j ] ) } ` }
113+ value = { `${ this . msg } ! s${ encodePos ( [ i , j ] ) } ` }
107114 style = { {
108- color : cell . blank ? 'grey' : '#000' ,
115+ ...buttonStyles ,
116+ color : cell . blank ? '#333' : '#000' ,
109117 padding : 0 ,
110- border : ! isSelected ? 'none' : undefined ,
111- background : 'none' ,
112- height : 20 ,
113- width : 20 ,
114118 fontSize : 16 ,
119+ overflow : WIDE_LETTERS . includes ( cell . letter ) && cell . points ? 'hidden' : undefined ,
115120 } }
116121 >
117122 < b >
@@ -122,14 +127,18 @@ function renderBoard(this: This, ctx: RenderCtx) {
122127 ) : null }
123128 { ! cell && clickable ? (
124129 < Button
125- value = { `${ this . msg } ! ${ ctx . id } , s${ encodePos ( [ i , j ] ) } ` }
130+ value = { `${ this . msg } ! s${ encodePos ( [ i , j ] ) } ` }
126131 style = { {
127- border : ! isSelected ? 'none' : undefined ,
128- background : 'none' ,
129- height : 20 ,
130- width : 20 ,
131- fontSize : 16 ,
132- ...( baseCell === '2*' ? { color : '#000' , padding : 0 , lineHeight : '15px' } : { } ) ,
132+ ...buttonStyles ,
133+ ...( baseCell === '2*'
134+ ? {
135+ color : '#000' ,
136+ padding : 0 ,
137+ fontSize : 16 ,
138+ textAlign : 'center' ,
139+ lineHeight : '18px' ,
140+ }
141+ : { } ) ,
133142 } }
134143 >
135144 { baseCell === '2*' ? '★' : ' ' }
@@ -167,41 +176,50 @@ function Letter({ letter, points }: { letter: string; points: number }): ReactEl
167176
168177function Scores ( { players } : { players : RenderCtx [ 'players' ] } ) : ReactElement [ ] {
169178 return Object . values ( players ) . map ( player => {
179+ const username = < Username name = { player . name } /> ;
170180 return (
171181 < div >
172- < Username name = { player . name } /> : { player . score } p ({ player . rack } tiles in rack)
182+ { player . out ? < s > { username } </ s > : username } : { player . score } ({ player . rack } tile(s) in rack)
173183 </ div >
174184 ) ;
175185 } ) ;
176186}
177187
178188function renderInput ( this : This , ctx : RenderCtx ) : ReactElement | null {
179189 // ctx.selected is only passed for the active player
180- if ( ! ctx . selected ) {
181- if ( ctx . side && ctx . side === ctx . turn ) return < h3 > Select a tile to play from.</ h3 > ;
182- return null ;
183- }
190+ if ( ! ctx . isActive ) return null ;
184191 return (
185192 < >
186- < br />
187- < Form value = { `${ this . msg } ! ${ ctx . id } ,p${ encodePos ( ctx . selected ) } {dir} {word}` } >
188- < center style = { { display : 'inline-block' } } >
189- < input name = "word" type = "text" width = "200" placeholder = "Your word here" />
190- < br />
191- < button > Play!</ button >
192- </ center >
193+ { ctx . selected ? (
194+ < Form value = { `${ this . msg } ! p${ encodePos ( ctx . selected ) } {dir} {word}` } style = { { display : 'inline-block' , margin : '0 8px' } } >
195+ < center style = { { display : 'inline-block' } } >
196+ < input name = "word" type = "text" width = "200" placeholder = "Your word here" />
197+ < br />
198+ < div style = { { textAlign : 'left' , margin : '4px 0' } } >
199+ < select name = "dir" >
200+ < option value = "r" > Right</ option >
201+ < option value = "d" > Down</ option >
202+ </ select >
203+ < button style = { { float : 'right' } } > Go!</ button >
204+ </ div >
205+ </ center >
206+ </ Form >
207+ ) : (
208+ < h3 > Select a tile to play from!</ h3 >
209+ ) }
210+ {
193211 < div style = { { display : 'inline-block' } } >
194- < label >
195- < input type = "radio" name = "dir " value = "r" style = { { position : 'relative' , top : 2 } } required checked / >
196- Right
197- </ label >
198- < br / >
199- < label >
200- < input type = "radio" name = "dir" value = "d " style = { { position : 'relative' , top : 2 } } />
201- Down
202- </ label >
212+ < div style = { { textAlign : 'right' } } >
213+ < Button name = "send " value = { ` ${ this . msg } ! -` } >
214+ Pass
215+ </ Button >
216+ </ div >
217+ < Form value = { ` ${ this . msg } ! x {tiles}` } style = { { margin : '4px 0' } } >
218+ < input name = "tiles" placeholder = "Exchange tiles" width = "100 " style = { { marginRight : 4 } } />
219+ < button > Exchange </ button >
220+ </ Form >
203221 </ div >
204- </ Form >
222+ }
205223 </ >
206224 ) ;
207225}
0 commit comments