aboutsummaryrefslogtreecommitdiff
path: root/client/src/Client.elm
diff options
context:
space:
mode:
authorJasper Van der Jeugt2020-08-06 20:09:14 +0200
committerJasper Van der Jeugt2020-08-06 20:09:14 +0200
commitb8a5f115793a9f1b39c236e0862ead27b76cc92a (patch)
tree24ee04384d215aefda5a0e5f458dc7a553b16c3f /client/src/Client.elm
parentf57f7ff6ca1441cfabb921bdf7267012bae3b172 (diff)
Skipping rounds
Diffstat (limited to '')
-rw-r--r--client/src/Client.elm34
1 files changed, 26 insertions, 8 deletions
diff --git a/client/src/Client.elm b/client/src/Client.elm
index fd4663e..840e9b6 100644
--- a/client/src/Client.elm
+++ b/client/src/Client.elm
@@ -23,11 +23,13 @@ type Msg
-- Card selection
| SelectWhiteCard WhiteCard
| ProposeWhiteCards
+ | AdminSkipProposals
-- Voting
| SelectVote Int
| SubmitVote
+ | AdminSkipVotes
-- Tally
- | ConfirmTally
+ | AdminConfirmTally
type alias Cards = {black : Array String, white : Array String}
@@ -159,7 +161,12 @@ viewTable game = case game.view.table of
, Html.Events.onClick ProposeWhiteCards
]
[Html.text "Propose"]
- ]
+ ] ++
+ ifAdmin game.view
+ [ Html.button
+ [Html.Events.onClick AdminSkipProposals]
+ [Html.text "Skip remaining players"]
+ ]
Messages.Voting black proposals myProposal myVote -> Html.div [] <|
[Html.p [] [Html.text <| "Vote for the funniest combination"]] ++
List.indexedMap (\i proposal ->
@@ -183,7 +190,12 @@ viewTable game = case game.view.table of
, Html.Events.onClick SubmitVote
]
[Html.text "Vote"]
- ]
+ ] ++
+ ifAdmin game.view
+ [ Html.button
+ [Html.Events.onClick AdminSkipVotes]
+ [Html.text "Skip remaining players"]
+ ]
Messages.Tally black results -> Html.div [] <|
[Html.p [] [Html.text "Vote results"]] ++
@@ -201,13 +213,15 @@ viewTable game = case game.view.table of
]
])
results ++
- if not game.view.me.admin then
- []
- else
+ ifAdmin game.view
[ Html.button
- [Html.Events.onClick ConfirmTally] [Html.text "Next round"]
+ [Html.Events.onClick AdminConfirmTally]
+ [Html.text "Next round"]
]
+ifAdmin : GameView -> List (Html a) -> List (Html a)
+ifAdmin gameView html = if gameView.me.admin then html else []
+
intersperseWith : List a -> a -> List a -> List a
intersperseWith values def list = case list of
[] -> []
@@ -326,6 +340,8 @@ update msg model = case msg of
)
_ -> (model, Cmd.none)
+ AdminSkipProposals -> (model, send Messages.AdminSkipProposals)
+
SelectVote i -> case model of
Game game -> case game.view.table of
Messages.Voting _ _ _ Nothing ->
@@ -333,6 +349,8 @@ update msg model = case msg of
_ -> (model, Cmd.none)
_ -> (model, Cmd.none)
+ AdminSkipVotes -> (model, send Messages.AdminSkipVotes)
+
SubmitVote -> case model of
Game game -> case game.selectedVote of
Just vote ->
@@ -342,7 +360,7 @@ update msg model = case msg of
_ -> (model, Cmd.none)
_ -> (model, Cmd.none)
- ConfirmTally -> (model, send <| Messages.ConfirmTally)
+ AdminConfirmTally -> (model, send Messages.AdminConfirmTally)
main : Program () Model Msg
main = Browser.application