From 6a97925fc3747dbc7c99bc3694589fc79bbbda97 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 5 Aug 2020 18:11:56 +0200 Subject: Win message --- client/src/Client.elm | 26 +++++++++++++++++--------- client/style.css | 4 ++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/client/src/Client.elm b/client/src/Client.elm index 54081c2..fd4663e 100644 --- a/client/src/Client.elm +++ b/client/src/Client.elm @@ -45,6 +45,10 @@ type Model | Connecting (Maybe String) | Game GameState +pluralize : Int -> String -> String -> String +pluralize x singular plural = + String.fromInt x ++ " " ++ if x < 2 then singular else plural + viewPlayers : List Messages.PlayerView -> Html msg viewPlayers players = Html.table [] <| Html.tr [] @@ -143,9 +147,7 @@ viewTable game = case game.view.table of Messages.Proposing c my -> Html.div [] <| [ Html.p [] [ Html.text <| "Select " ++ - String.fromInt (blackCardBlanks game.cards c) ++ - " card" ++ - (if blackCardBlanks game.cards c < 2 then "" else "s") ++ + pluralize (blackCardBlanks game.cards c) "card" "cards" ++ " from your hand" ] , blackCard [] game.cards c <| selectedWhiteCards game @@ -186,12 +188,18 @@ viewTable game = case game.view.table of Messages.Tally black results -> Html.div [] <| [Html.p [] [Html.text "Vote results"]] ++ List.map (\voted -> - let attrs = - if List.length voted.winners > 0 then - [Html.Attributes.class "winner"] - else - [] in - blackCard attrs game.cards black voted.proposal) + if List.length voted.winners <= 0 then + blackCard [] game.cards black voted.proposal + else + Html.div [] <| + [ blackCard [Html.Attributes.class "winner"] + game.cards black voted.proposal + , Html.p [Html.Attributes.class "authors"] + [ Html.text <| + String.join ", " voted.winners ++ " wins with " ++ + pluralize voted.score "vote" "votes" + ] + ]) results ++ if not game.view.me.admin then [] diff --git a/client/style.css b/client/style.css index 5a26150..64d2a42 100644 --- a/client/style.css +++ b/client/style.css @@ -99,3 +99,7 @@ button, input { .filled { text-decoration: underline; } + +.authors { + margin-top: 6px; +} -- cgit v1.2.3