gameServer/Utils.hs
changeset 7766 98edc0724a28
parent 6981 045e8162c9cd
child 7862 bd76ca40db68
equal deleted inserted replaced
7765:1e162c1d6dc7 7766:98edc0724a28
     2 module Utils where
     2 module Utils where
     3 
     3 
     4 import Data.Char
     4 import Data.Char
     5 import Data.Word
     5 import Data.Word
     6 import qualified Data.Map as Map
     6 import qualified Data.Map as Map
     7 import qualified Data.Set as Set
       
     8 import qualified Data.Char as Char
     7 import qualified Data.Char as Char
     9 import Numeric
     8 import Numeric
    10 import Network.Socket
     9 import Network.Socket
    11 import System.IO
    10 import System.IO
    12 import qualified Data.List as List
    11 import qualified Data.List as List
    13 import Control.Monad
    12 import Control.Monad
    14 import qualified Codec.Binary.Base64 as Base64
       
    15 import qualified Data.ByteString.Lazy as BL
    13 import qualified Data.ByteString.Lazy as BL
    16 import qualified Text.Show.ByteString as BS
    14 import qualified Text.Show.ByteString as BS
    17 import qualified Data.ByteString.Char8 as B
    15 import qualified Data.ByteString.Char8 as B
    18 import qualified Data.ByteString.UTF8 as UTF8
    16 import qualified Data.ByteString.UTF8 as UTF8
    19 import qualified Data.ByteString as BW
       
    20 import Data.Maybe
    17 import Data.Maybe
    21 -------------------------------------------------
    18 -------------------------------------------------
    22 import CoreTypes
    19 import CoreTypes
    23 
    20 
    24 
    21 
   121 caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool
   118 caseInsensitiveCompare :: B.ByteString -> B.ByteString -> Bool
   122 caseInsensitiveCompare a b = f a == f b
   119 caseInsensitiveCompare a b = f a == f b
   123     where
   120     where
   124         f = map Char.toUpper . UTF8.toString
   121         f = map Char.toUpper . UTF8.toString
   125 
   122 
       
   123 
       
   124 roomInfo :: B.ByteString -> RoomInfo -> [B.ByteString]
   126 roomInfo n r = [
   125 roomInfo n r = [
   127         showB $ isJust $ gameInfo r,
   126         showB $ isJust $ gameInfo r,
   128         name r,
   127         name r,
   129         showB $ playersIn r,
   128         showB $ playersIn r,
   130         showB $ length $ teams r,
   129         showB $ length $ teams r,