2018-05-25 12:06:15 -07:00
|
|
|
module Go.View exposing (..)
|
|
|
|
import Go.Util exposing (allIndices, pair, lookup)
|
|
|
|
import Go.Types exposing (..)
|
|
|
|
import Html exposing (Html, div, text, p)
|
|
|
|
import Html.Attributes exposing (class, classList)
|
|
|
|
import Html.Events exposing (onClick)
|
|
|
|
|
|
|
|
renderIndex : (Index, Maybe Color) -> Html Msg
|
|
|
|
renderIndex (index, color) =
|
|
|
|
let
|
|
|
|
extraClass = case color of
|
|
|
|
Just c -> (if c == Black then "black-cell" else "white-cell", True)
|
|
|
|
Nothing -> ("", False)
|
|
|
|
in
|
|
|
|
div [ classList [ ("board-cell", True), extraClass ]
|
|
|
|
, onClick (Place index)
|
|
|
|
]
|
2018-05-25 17:27:59 -07:00
|
|
|
[ div [ class "overlay" ] []
|
2018-05-25 12:06:15 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
renderBoard : Int -> Board -> Html Msg
|
|
|
|
renderBoard size board =
|
|
|
|
let
|
|
|
|
cells = List.map (\i -> (lookup i board) |> (pair i)) <| allIndices size
|
|
|
|
in
|
2018-05-25 12:11:18 -07:00
|
|
|
div [ class "board" ] <| List.map renderIndex cells
|