aboutsummaryrefslogtreecommitdiff
path: root/src/Model/Round.elm
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/Model/Round.elm
parent97e494a7c5a105bba6a48f5025e71a376fc8673d (diff)
Showing the score at the end of each round
Diffstat (limited to 'src/Model/Round.elm')
-rw-r--r--src/Model/Round.elm13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Model/Round.elm b/src/Model/Round.elm
index d5210d5..16e8f5e 100644
--- a/src/Model/Round.elm
+++ b/src/Model/Round.elm
@@ -1,8 +1,9 @@
module Model.Round
( Round
- , roundOrder
+ , maybeBestRound
) where
+import List
import Time (Time)
type alias Round =
@@ -10,6 +11,16 @@ type alias Round =
, score : Int
}
+maybeBestRound : List Round -> Maybe Round
+maybeBestRound rounds =
+ let orderedRounds =
+ rounds
+ |> List.sortWith roundOrder
+ |> List.reverse
+ in case orderedRounds of
+ [] -> Nothing
+ best :: _ -> Just best
+
roundOrder : Round -> Round -> Order
roundOrder round1 round2 =
if round1.score == round2.score