diff options
author | Joris Guyonvarch | 2015-03-08 15:14:07 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-08 15:14:07 +0100 |
commit | 87386e8b148c2536214fdaf6c3140853c751d7b4 (patch) | |
tree | 9af29dd893e414f610695f133b32ccf8a3cf79bf /src/Model | |
parent | 97e494a7c5a105bba6a48f5025e71a376fc8673d (diff) |
Showing the score at the end of each round
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Round.elm | 13 |
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 |