aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-08-05 18:11:56 +0200
committerJasper Van der Jeugt2020-08-05 18:11:56 +0200
commit6a97925fc3747dbc7c99bc3694589fc79bbbda97 (patch)
treeddbfb2c283bcaaa3ab912bd63dc659e5937463b9 /client
parentcd474b375d59a36f94108fa308fd598edd26183e (diff)
Win message
Diffstat (limited to 'client')
-rw-r--r--client/src/Client.elm26
-rw-r--r--client/style.css4
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;
+}