1
1
import './index.css'
2
2
import { EvaluatedMove , Message , MessageType , SkillSetting } from "./message" ;
3
3
import { createStopToken , stop } from "./stopToken" ;
4
- import { boardData , scoreFromCircles } from "./game" ;
4
+ import { Circle , scoreFromCircles } from "./game" ;
5
5
6
6
interface ZWorker extends Worker {
7
7
postMessage ( message : Message ) : void
@@ -136,10 +136,63 @@ document.getElementById('board')?.addEventListener('click', (e) => {
136
136
} )
137
137
138
138
function render ( ) {
139
- const svgData_ = boardData ( board , clickedMove , evals ) ;
139
+ let evals_ = [ ]
140
+ const fieldSize = 100
141
+ const arr = [ ] as Circle [ ]
142
+ for ( let i = 1 ; i <= 8 ; i ++ ) {
143
+ for ( let j = 1 ; j <= 8 ; j ++ ) {
144
+ let color ;
145
+ let move = 10 * i + j ;
146
+
147
+ switch ( board [ move ] ) {
148
+ case 0 :
149
+ color = 'black'
150
+ break ;
151
+
152
+ case 2 :
153
+ color = 'white'
154
+ break ;
155
+
156
+ default : {
157
+ if ( clickedMove === move ) {
158
+ // todo take into account side to move
159
+ color = 'rgba(127, 127, 127, 0.5)'
160
+ break
161
+ }
162
+ const eval_ = evals . find ( ( eval_ : EvaluatedMove ) => eval_ . move === move )
163
+ if ( ! eval_ ) {
164
+ continue
165
+ }
166
+
167
+ if ( eval_ . best ) {
168
+ color = '#00FFFF'
169
+ } else {
170
+ color = '#FFFF00'
171
+ }
172
+ const text = eval_ . eval_s
173
+ evals_ . push ( {
174
+ x : ( j - 1 ) * fieldSize + 0.2 * fieldSize ,
175
+ y : ( i - 1 ) * fieldSize + 0.65 * fieldSize ,
176
+ color,
177
+ text
178
+ } )
179
+ continue
180
+ }
181
+ }
182
+
183
+ const pieceSize = 80
184
+ arr . push ( {
185
+ cx : ( j - 1 ) * fieldSize + 0.5 * fieldSize ,
186
+ cy : ( i - 1 ) * fieldSize + 0.5 * fieldSize ,
187
+ r : pieceSize / 2 ,
188
+ color
189
+ } )
190
+ }
191
+ }
192
+
193
+ const circles = arr
194
+ const score = scoreFromCircles ( circles )
140
195
141
- const score = scoreFromCircles ( svgData_ . circles )
142
- const circles = svgData_ . circles ;
143
196
const circlesHtml = circles . map ( circle => {
144
197
return `<circle r="${ circle . r } " cx="${ circle . cx } " cy="${ circle . cy } " style="fill: ${ circle . color } "></circle>`
145
198
} ) . join ( '' )
@@ -148,7 +201,6 @@ function render() {
148
201
document . getElementById ( 'score-black' ) ! . innerText = '' + score . black
149
202
document . getElementById ( 'score-white' ) ! . innerText = '' + score . white
150
203
151
- const evals_ = svgData_ . evals ;
152
204
const evalsHtml = evals_ . map ( eval_ => {
153
205
return `<text x="${ eval_ . x } " y="${ eval_ . y } " style="fill: ${ eval_ . color } ; font-size: 50px">${ eval_ . text } </text>`
154
206
} ) . join ( '' )
0 commit comments