aboutsummaryrefslogtreecommitdiff
path: root/src/View
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-03-08 15:14:07 +0100
committerJoris Guyonvarch2015-03-08 15:14:07 +0100
commit87386e8b148c2536214fdaf6c3140853c751d7b4 (patch)
tree9af29dd893e414f610695f133b32ccf8a3cf79bf /src/View
parent97e494a7c5a105bba6a48f5025e71a376fc8673d (diff)
Showing the score at the end of each round
Diffstat (limited to 'src/View')
-rw-r--r--src/View/Game.elm2
-rw-r--r--src/View/Page.elm36
2 files changed, 25 insertions, 13 deletions
diff --git a/src/View/Game.elm b/src/View/Game.elm
index 8e76b48..0bbea00 100644
--- a/src/View/Game.elm
+++ b/src/View/Game.elm
@@ -69,7 +69,7 @@ outlineColor = rgb 34 34 34
scoreForms : Int -> List Form
scoreForms score =
let text = (toString score)
- scorePos = { x = 0.0, y = boardSize.y / 2 - 30 }
+ scorePos = { x = 0.0, y = boardSize.y / 2 - 35 }
in [textForm text scorePos centered]
textForm : String -> Vec2 -> (Text -> Element) -> Form
diff --git a/src/View/Page.elm b/src/View/Page.elm
index 3aa29a2..c85cf91 100644
--- a/src/View/Page.elm
+++ b/src/View/Page.elm
@@ -3,6 +3,7 @@ module View.Page
) where
import List
+import String (append)
import Html (..)
import Html.Attributes (..)
@@ -10,7 +11,7 @@ import Html.Attributes as A
import Json.Encode (string)
import Model.Game (Game)
-import Model.Round (roundOrder)
+import Model.Round (..)
import View.Game (gameView)
import View.Time (timeView)
@@ -29,18 +30,23 @@ pageView game =
, p
[]
[ text "Use the arrow keys to move and 'e' to change your color." ]
- , ( 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) ]
+ , ( case maybeBestRound game.rounds of
+ Nothing ->
+ div [ class "bestScore" ] []
+ Just bestRound ->
+ p
+ [ class "bestScore isDefined" ]
+ [ roundView bestRound
+ |> append "Best score: "
+ |> text
+ ]
)
+ , ul
+ [ class "rounds" ]
+ ( List.map
+ (\round -> li [] [ text (roundView round) ])
+ game.rounds
+ )
, a
[ href "https://github.com/guyonvarch/catchvoid" ]
[ img
@@ -58,3 +64,9 @@ pageView game =
]
]
+roundView : Round -> String
+roundView round =
+ let score = toString round.score
+ hits = "hit" ++ (if round.score > 1 then "s" else "")
+ duration = timeView round.duration
+ in score ++ " " ++ hits ++ " within " ++ duration