From 97e494a7c5a105bba6a48f5025e71a376fc8673d Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 8 Mar 2015 13:26:52 +0100 Subject: Save round durations --- src/View/Page.elm | 21 +++++++++++++-------- src/View/Time.elm | 10 ++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 src/View/Time.elm (limited to 'src/View') diff --git a/src/View/Page.elm b/src/View/Page.elm index 4dd54b5..3aa29a2 100644 --- a/src/View/Page.elm +++ b/src/View/Page.elm @@ -10,8 +10,10 @@ import Html.Attributes as A import Json.Encode (string) import Model.Game (Game) +import Model.Round (roundOrder) import View.Game (gameView) +import View.Time (timeView) pageView : Game -> Html pageView game = @@ -27,14 +29,17 @@ pageView game = , p [] [ text "Use the arrow keys to move and 'e' to change your color." ] - , ( if List.isEmpty game.scores - then - div [ class "bestScore" ] [] - else - let bestScore = List.maximum game.scores - in p - [ class "bestScore isDefined" ] - [ text <| "Best score: " ++ (toString bestScore) ] + , ( let orderedRounds = + game.rounds + |> List.sortWith roundOrder + |> List.reverse + in case orderedRounds of + [] -> + div [ class "bestScore" ] [] + bestRound :: _ -> + p + [ class "bestScore isDefined" ] + [ text <| "Best score: " ++ (toString bestRound.score) ++ " hits within " ++ (timeView bestRound.duration) ] ) , a [ href "https://github.com/guyonvarch/catchvoid" ] diff --git a/src/View/Time.elm b/src/View/Time.elm new file mode 100644 index 0000000..363a0b6 --- /dev/null +++ b/src/View/Time.elm @@ -0,0 +1,10 @@ +module View.Time + ( timeView + ) where + +import Time (Time) + +timeView : Time -> String +timeView time = + let s = truncate (time / 1000) + in (toString s) ++ " seconds" -- cgit v1.2.3