diff options
author | Julien Dessaux | 2011-09-02 16:38:27 +0200 |
---|---|---|
committer | Julien Dessaux | 2011-09-02 16:38:27 +0200 |
commit | f1ce0cfee09c5ba316abe437befa8ad75b3a5aa6 (patch) | |
tree | 42ca439fb01a8cb867522393d1e81707c74e839c /Hsbot/Plugin | |
parent | Fixed mistake that prevented death message to be parsed upon restarting (diff) | |
download | hsbot-f1ce0cfee09c5ba316abe437befa8ad75b3a5aa6.tar.gz hsbot-f1ce0cfee09c5ba316abe437befa8ad75b3a5aa6.tar.bz2 hsbot-f1ce0cfee09c5ba316abe437befa8ad75b3a5aa6.zip |
Added score sorting for the duck module
Diffstat (limited to 'Hsbot/Plugin')
-rw-r--r-- | Hsbot/Plugin/Duck.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Hsbot/Plugin/Duck.hs b/Hsbot/Plugin/Duck.hs index b152685..1044591 100644 --- a/Hsbot/Plugin/Duck.hs +++ b/Hsbot/Plugin/Duck.hs @@ -13,6 +13,7 @@ import Data.Acid import qualified Data.List as L import qualified Data.Map as M import Data.Maybe +import Data.Ord () import Data.SafeCopy import Data.Typeable import qualified Network.IRC as IRC @@ -151,8 +152,13 @@ bangs = [ "PAN", "PAN!" ] printDuckStats :: String -> StatDB -> Plugin (Env IO) () printDuckStats channel statDB = do sendLine "Duck slaughter simulator - Hall of Fame" - mapM_ (sendLine . buildLine) $ M.toList (nickStats statDB) + mapM_ (sendLine . buildLine) . reverse . L.sortBy scoreSort $ M.toList (nickStats statDB) where + scoreSort :: (String, Int) -> (String, Int) -> Ordering + scoreSort (_, s1) (_,s2) + | s1 < s2 = LT + | s1 > s2 = GT + | otherwise = EQ buildLine :: (String, Int) -> String buildLine (nick, score) = concat [ nick, ": ", show score ] sendLine :: String -> Plugin (Env IO) () |