Write a basic view function. Without styling, it's impossible to see.

This commit is contained in:
2018-05-25 12:06:15 -07:00
parent 0283e060e4
commit 43ad995c62
5 changed files with 40 additions and 6 deletions

8
Go.elm
View File

@@ -2,6 +2,7 @@ import Go.Types exposing (..)
import Go.Game exposing (verify)
import Go.Decoders exposing (decodeUpdatestring)
import Go.Ws exposing (..)
import Go.View exposing (..)
import WebSocket
import Html exposing (Html, div, text)
@@ -26,11 +27,14 @@ initDummy = (Model
[], Cmd.none)
view : Model -> Html Msg
view m = div [] [ text (toString m.currentColor) ]
view m = div []
[ text (toString m.currentColor)
, renderBoard m.sessionSize m.board
]
update : Msg -> Model -> (Model, Cmd Msg)
update msg model = case msg of
Place c -> case verify c model of
Place indx -> case verify (indx, model.sessionColor) model of
Nothing -> ( { model | error = Just "Can't place piece" }, Cmd.none)
Just c -> ( { model | board = c::model.board }, sendMove model c)
Update s -> case decodeUpdatestring s of