diff options
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 |