aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/Client.elm8
-rw-r--r--client/src/Messages.elm15
2 files changed, 19 insertions, 4 deletions
diff --git a/client/src/Client.elm b/client/src/Client.elm
index 5170e64..246748b 100644
--- a/client/src/Client.elm
+++ b/client/src/Client.elm
@@ -94,6 +94,7 @@ view model = case model of
tableBlackCard : GameState -> Maybe BlackCard
tableBlackCard game = case game.view.table of
Messages.Proposing b _ -> Just b
+ Messages.Voting b _ _ _ -> Just b
selectedWhiteCards : GameState -> List WhiteCard
selectedWhiteCards game = case game.view.table of
@@ -116,6 +117,13 @@ viewTable game = case game.view.table of
]
[Html.text "Propose"]
]
+ Messages.Voting black myProposal proposals myVote -> Html.div [] <|
+ [ Html.h2 [] [Html.text "Your proposal"]
+ , blackCard game.cards black myProposal
+ ] ++
+ [ Html.h2 [] [Html.text "Opponent proposals"]
+ ] ++
+ List.map (blackCard game.cards black) proposals
intersperseWith : List a -> a -> List a -> List a
intersperseWith values def list = case list of
diff --git a/client/src/Messages.elm b/client/src/Messages.elm
index 11c34ca..3979587 100644
--- a/client/src/Messages.elm
+++ b/client/src/Messages.elm
@@ -78,15 +78,22 @@ jsonEncOpponent val =
type TableView =
Proposing BlackCard (List WhiteCard)
+ | Voting BlackCard (List WhiteCard) (List (List WhiteCard)) (Maybe Int)
jsonDecTableView : Json.Decode.Decoder ( TableView )
jsonDecTableView =
- Json.Decode.lazy (\_ -> Json.Decode.map2 Proposing (Json.Decode.index 0 (jsonDecBlackCard)) (Json.Decode.index 1 (Json.Decode.list (jsonDecWhiteCard))))
-
+ let jsonDecDictTableView = Dict.fromList
+ [ ("Proposing", Json.Decode.lazy (\_ -> Json.Decode.map2 Proposing (Json.Decode.index 0 (jsonDecBlackCard)) (Json.Decode.index 1 (Json.Decode.list (jsonDecWhiteCard)))))
+ , ("Voting", Json.Decode.lazy (\_ -> Json.Decode.map4 Voting (Json.Decode.index 0 (jsonDecBlackCard)) (Json.Decode.index 1 (Json.Decode.list (jsonDecWhiteCard))) (Json.Decode.index 2 (Json.Decode.list (Json.Decode.list (jsonDecWhiteCard)))) (Json.Decode.index 3 (Json.Decode.maybe (Json.Decode.int)))))
+ ]
+ in decodeSumObjectWithSingleField "TableView" jsonDecDictTableView
jsonEncTableView : TableView -> Value
-jsonEncTableView (Proposing v1 v2) =
- Json.Encode.list identity [jsonEncBlackCard v1, (Json.Encode.list jsonEncWhiteCard) v2]
+jsonEncTableView val =
+ let keyval v = case v of
+ Proposing v1 v2 -> ("Proposing", encodeValue (Json.Encode.list identity [jsonEncBlackCard v1, (Json.Encode.list jsonEncWhiteCard) v2]))
+ Voting v1 v2 v3 v4 -> ("Voting", encodeValue (Json.Encode.list identity [jsonEncBlackCard v1, (Json.Encode.list jsonEncWhiteCard) v2, (Json.Encode.list (Json.Encode.list jsonEncWhiteCard)) v3, (maybeEncode (Json.Encode.int)) v4]))
+ in encodeSumObjectWithSingleField keyval val