displayInGame = (data) => {
const max_selected = Math.max(...data.map(x=>x.selected_order))
const initDiv = x => {
let hitbox = html`<div class="hitbox"></div>`
e => handleClickState(x.id)
hitbox.onpointerdown = e => handleClickState(x.id)
hitbox.onpointerenter = (e) => {
if(e.buttons !== 0 && guess !== '') {
handleClickState(x.id)
}
}
let color = x.clicked === true ? '#479d2f' : 'black'
let backgroundColor = x.letter === '_' ? 'black' : 'white'
if(x.selected_order === max_selected && max_selected > 0) backgroundColor = '#bbdcac'
let underline = checkbox.includes("Play Around The Table") && ['M', 'W', 'N', 'Z'].includes(x.letter) ? 'underline' : 'none'
let deg = !checkbox.includes("Play Around The Table") ? 0 : _.sample([0, 90, 180, 270])
let div = html`<div
id=${x.id}
class="tile"
style="background-color:${backgroundColor}"
>
<div class="tileText" style="color:${color}; transform: rotate(${deg}deg); text-decoration:${underline}; ">${x.letter}</div>
${hitbox}
</div>`
div.onpointerdown = e => handleClickState(x.id)
return div
}
const container = html`<div class="prevent-select"></div>`
const board = html`<div class="board"></div>`
const divs = data.map(x => initDiv(x))
for (const el of divs) board.appendChild(el)
container.appendChild(board)
return container
}