aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-07-30 19:42:26 +0200
committerJasper Van der Jeugt2020-07-30 19:42:26 +0200
commit3b7d11c6182b8aa3d3d4f9e36c213e4eba6c8d8f (patch)
treeefbf3a064adefa8cc1228edec835d7403068e779 /client
parentfe56ddfbd14b3e7fbaee8732641bcc00fbd0c856 (diff)
Add cards from CardsAgainstCryptography
Diffstat (limited to 'client')
-rw-r--r--client/index.html1
-rw-r--r--client/src/Client.elm13
-rw-r--r--client/src/Messages.elm5
-rw-r--r--client/style.css16
4 files changed, 33 insertions, 2 deletions
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 @@
<head>
<meta charset="UTF-8">
<title>Client</title>
+ <link rel="stylesheet" type="text/css" href="/assets/style.css">
</head>
<body>
<div id="main"></div>
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;
+}