From 87386e8b148c2536214fdaf6c3140853c751d7b4 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 8 Mar 2015 15:14:07 +0100 Subject: Showing the score at the end of each round --- src/Model/Round.elm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Model/Round.elm') 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 -- cgit v1.2.3