From 3b7d11c6182b8aa3d3d4f9e36c213e4eba6c8d8f Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 30 Jul 2020 19:42:26 +0200 Subject: Add cards from CardsAgainstCryptography --- client/index.html | 1 + client/src/Client.elm | 13 ++++++++++++- client/src/Messages.elm | 5 ++++- client/style.css | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 client/style.css (limited to 'client') diff --git a/client/index.html b/client/index.html index 75ee56d..adc2ac8 100644 --- a/client/index.html +++ b/client/index.html @@ -3,6 +3,7 @@ Client +
diff --git a/client/src/Client.elm b/client/src/Client.elm index 1938711..efd97fb 100644 --- a/client/src/Client.elm +++ b/client/src/Client.elm @@ -67,7 +67,18 @@ view model = case model of ] [Html.text "change"] ] - ] + ] ++ + (case game.view.blackCard of + Nothing -> [] + Just c -> [blackCard c]) + +blackCard : String -> Html a +blackCard string = + let blank = Html.span [Html.Attributes.class "blank"] [] in + Html.div [Html.Attributes.class "black"] <| + List.intersperse blank <| + List.map Html.text <| + String.split "\\BLANK" string subscriptions : Model -> Sub Msg subscriptions model = webSocketIn WebSocketIn diff --git a/client/src/Messages.elm b/client/src/Messages.elm index 3fbacc3..77b3830 100644 --- a/client/src/Messages.elm +++ b/client/src/Messages.elm @@ -11,19 +11,22 @@ import Set exposing (Set) type alias GameView = { opponents: (List String) , myName: String + , blackCard: (Maybe String) } jsonDecGameView : Json.Decode.Decoder ( GameView ) jsonDecGameView = - Json.Decode.succeed (\popponents pmyName -> {opponents = popponents, myName = pmyName}) + Json.Decode.succeed (\popponents pmyName pblackCard -> {opponents = popponents, myName = pmyName, blackCard = pblackCard}) |> required "opponents" (Json.Decode.list (Json.Decode.string)) |> required "myName" (Json.Decode.string) + |> fnullable "blackCard" (Json.Decode.string) 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) ] diff --git a/client/style.css b/client/style.css new file mode 100644 index 0000000..fd26c52 --- /dev/null +++ b/client/style.css @@ -0,0 +1,16 @@ +html { + font-size: 18px; +} + +.black { + color: white; + background: black; + padding: 18px; + border-radius: 18px; +} + +.blank { + border-bottom: 2px solid white; + display: inline-block; + width: 42px; +} -- cgit v1.2.3