aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/Client.elm14
-rw-r--r--client/src/Messages.elm39
-rw-r--r--client/style.css13
3 files changed, 56 insertions, 10 deletions
diff --git a/client/src/Client.elm b/client/src/Client.elm
index efd97fb..41871e9 100644
--- a/client/src/Client.elm
+++ b/client/src/Client.elm
@@ -70,16 +70,22 @@ view model = case model of
] ++
(case game.view.blackCard of
Nothing -> []
- Just c -> [blackCard c])
+ Just c -> [blackCard c]) ++
+ (List.map whiteCard game.view.hand)
-blackCard : String -> Html a
-blackCard string =
+blackCard : Messages.BlackCard -> Html a
+blackCard (Messages.BlackCard string) =
let blank = Html.span [Html.Attributes.class "blank"] [] in
- Html.div [Html.Attributes.class "black"] <|
+ Html.div [Html.Attributes.class "card", Html.Attributes.class "black"] <|
List.intersperse blank <|
List.map Html.text <|
String.split "\\BLANK" string
+whiteCard : Messages.WhiteCard -> Html a
+whiteCard (Messages.WhiteCard string) = Html.div
+ [Html.Attributes.class "card", Html.Attributes.class "white"]
+ [Html.text string]
+
subscriptions : Model -> Sub Msg
subscriptions model = webSocketIn WebSocketIn
diff --git a/client/src/Messages.elm b/client/src/Messages.elm
index 77b3830..d2c2716 100644
--- a/client/src/Messages.elm
+++ b/client/src/Messages.elm
@@ -8,25 +8,56 @@ import Dict exposing (Dict)
import Set exposing (Set)
+type BlackCard =
+ BlackCard String
+
+jsonDecBlackCard : Json.Decode.Decoder ( BlackCard )
+jsonDecBlackCard =
+ Json.Decode.lazy (\_ -> Json.Decode.map BlackCard (Json.Decode.string))
+
+
+jsonEncBlackCard : BlackCard -> Value
+jsonEncBlackCard (BlackCard v1) =
+ Json.Encode.string v1
+
+
+
+type WhiteCard =
+ WhiteCard String
+
+jsonDecWhiteCard : Json.Decode.Decoder ( WhiteCard )
+jsonDecWhiteCard =
+ Json.Decode.lazy (\_ -> Json.Decode.map WhiteCard (Json.Decode.string))
+
+
+jsonEncWhiteCard : WhiteCard -> Value
+jsonEncWhiteCard (WhiteCard v1) =
+ Json.Encode.string v1
+
+
+
type alias GameView =
{ opponents: (List String)
, myName: String
- , blackCard: (Maybe String)
+ , blackCard: (Maybe BlackCard)
+ , hand: (List WhiteCard)
}
jsonDecGameView : Json.Decode.Decoder ( GameView )
jsonDecGameView =
- Json.Decode.succeed (\popponents pmyName pblackCard -> {opponents = popponents, myName = pmyName, blackCard = pblackCard})
+ Json.Decode.succeed (\popponents pmyName pblackCard phand -> {opponents = popponents, myName = pmyName, blackCard = pblackCard, hand = phand})
|> required "opponents" (Json.Decode.list (Json.Decode.string))
|> required "myName" (Json.Decode.string)
- |> fnullable "blackCard" (Json.Decode.string)
+ |> fnullable "blackCard" (jsonDecBlackCard)
+ |> required "hand" (Json.Decode.list (jsonDecWhiteCard))
jsonEncGameView : GameView -> Value
jsonEncGameView val =
Json.Encode.object
[ ("opponents", (Json.Encode.list Json.Encode.string) val.opponents)
, ("myName", Json.Encode.string val.myName)
- , ("blackCard", (maybeEncode (Json.Encode.string)) val.blackCard)
+ , ("blackCard", (maybeEncode (jsonEncBlackCard)) val.blackCard)
+ , ("hand", (Json.Encode.list jsonEncWhiteCard) val.hand)
]
diff --git a/client/style.css b/client/style.css
index fd26c52..6cd9f5d 100644
--- a/client/style.css
+++ b/client/style.css
@@ -2,11 +2,20 @@ html {
font-size: 18px;
}
+.card {
+ padding: 18px;
+ border-radius: 18px;
+}
+
.black {
color: white;
background: black;
- padding: 18px;
- border-radius: 18px;
+}
+
+.white {
+ color: black;
+ background: white;
+ border: 2px solid black;
}
.blank {