From 076586eb1b8a61341b2331162046f20eee49b788 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 21 Nov 2017 19:51:54 -0500 Subject: [PATCH] Show discards --- priv/src/Client.elm | 2 +- priv/src/Client/Decode.elm | 3 ++- priv/src/Client/Player.elm | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/priv/src/Client.elm b/priv/src/Client.elm index 96a8a4b..fe53746 100644 --- a/priv/src/Client.elm +++ b/priv/src/Client.elm @@ -55,7 +55,7 @@ socketMsg : String -> Maybe Msg socketMsg message = let splitMsg = - case String.split ":" message of + case String.split ":" (Debug.log "message" message) of msgType :: rest -> Just ( msgType, String.join ":" rest ) diff --git a/priv/src/Client/Decode.elm b/priv/src/Client/Decode.elm index 26ce15d..3016c77 100644 --- a/priv/src/Client/Decode.elm +++ b/priv/src/Client/Decode.elm @@ -49,11 +49,12 @@ wind = player : Decoder Player player = - map4 Player + map5 Player (field "name" <| map (\s -> s == "Websocket") string) (field "name" string) (field "seat" wind) (field "hand" hand) + (field "discards" (list tile)) game : Decoder Game diff --git a/priv/src/Client/Player.elm b/priv/src/Client/Player.elm index 621ddd3..0d8c90f 100644 --- a/priv/src/Client/Player.elm +++ b/priv/src/Client/Player.elm @@ -1,6 +1,7 @@ module Client.Player exposing (..) import Client.Hand exposing (Hand) +import Tile exposing (Tile) import Html exposing (..) type Wind = East | South | West | North @@ -10,6 +11,7 @@ type alias Player = , name : String , seat : Wind , hand : Hand + , discards : List Tile } @@ -18,4 +20,9 @@ view player = fieldset [] [ legend [] [ text ("Player: " ++ player.name ++ "(" ++ (toString player.seat) ++ ")") ] , Client.Hand.view player.hand player.isMe + , viewDiscards player.discards ] + +viewDiscards : List Tile -> Html msg +viewDiscards tiles = + div [] <| List.map Tile.view tiles