gameServer/CoreTypes.hs
changeset 5006 6913d677c891
parent 5001 312f4dd41753
child 5007 c401891fe5e0
equal deleted inserted replaced
5005:d7bddb280f4f 5006:6913d677c891
    37         isAdministrator :: Bool,
    37         isAdministrator :: Bool,
    38         clientClan :: Maybe B.ByteString,
    38         clientClan :: Maybe B.ByteString,
    39         teamsInGame :: Word
    39         teamsInGame :: Word
    40     }
    40     }
    41 
    41 
    42 instance Show ClientInfo where
       
    43     show ci = " nick: " ++ unpack (nick ci) ++ " host: " ++ unpack (host ci)
       
    44 
       
    45 instance Eq ClientInfo where
    42 instance Eq ClientInfo where
    46     (==) = (==) `on` clientSocket
    43     (==) = (==) `on` clientSocket
    47 
    44 
    48 data HedgehogInfo =
    45 data HedgehogInfo =
    49     HedgehogInfo B.ByteString B.ByteString
    46     HedgehogInfo B.ByteString B.ByteString
    62         difficulty :: Int,
    59         difficulty :: Int,
    63         hhnum :: Int,
    60         hhnum :: Int,
    64         hedgehogs :: [HedgehogInfo]
    61         hedgehogs :: [HedgehogInfo]
    65     }
    62     }
    66 
    63 
    67 instance Show TeamInfo where
       
    68     show ti = "owner: " ++ unpack (teamowner ti)
       
    69             ++ "name: " ++ unpack (teamname ti)
       
    70             ++ "color: " ++ unpack (teamcolor ti)
       
    71 
       
    72 data RoomInfo =
    64 data RoomInfo =
    73     RoomInfo
    65     RoomInfo
    74     {
    66     {
    75         masterID :: ClientIndex,
    67         masterID :: ClientIndex,
    76         name :: B.ByteString,
    68         name :: B.ByteString,
    86         leftTeams :: [B.ByteString],
    78         leftTeams :: [B.ByteString],
    87         teamsAtStart :: [TeamInfo],
    79         teamsAtStart :: [TeamInfo],
    88         mapParams :: Map.Map B.ByteString B.ByteString,
    80         mapParams :: Map.Map B.ByteString B.ByteString,
    89         params :: Map.Map B.ByteString [B.ByteString]
    81         params :: Map.Map B.ByteString [B.ByteString]
    90     }
    82     }
    91 
       
    92 instance Show RoomInfo where
       
    93     show ri = ", players: " ++ show (playersIn ri)
       
    94             ++ ", ready: " ++ show (readyPlayers ri)
       
    95             ++ ", teams: " ++ show (teams ri)
       
    96 
    83 
    97 newRoom :: RoomInfo
    84 newRoom :: RoomInfo
    98 newRoom =
    85 newRoom =
    99     RoomInfo
    86     RoomInfo
   100         (error "No room master defined")
    87         (error "No room master defined")
   143         coreChan :: Chan CoreMessage,
   130         coreChan :: Chan CoreMessage,
   144         dbQueries :: Chan DBQuery,
   131         dbQueries :: Chan DBQuery,
   145         serverConfig :: Maybe Conf
   132         serverConfig :: Maybe Conf
   146     }
   133     }
   147 
   134 
   148 instance Show ServerInfo where
       
   149     show _ = "Server Info"
       
   150 
   135 
   151 newServerInfo :: Chan CoreMessage -> Chan DBQuery -> Maybe Conf -> ServerInfo
   136 newServerInfo :: Chan CoreMessage -> Chan DBQuery -> Maybe Conf -> ServerInfo
   152 newServerInfo =
   137 newServerInfo =
   153     ServerInfo
   138     ServerInfo
   154         True
   139         True
   182     | ClientMessage (ClientIndex, [B.ByteString])
   167     | ClientMessage (ClientIndex, [B.ByteString])
   183     | ClientAccountInfo ClientIndex Int AccountInfo
   168     | ClientAccountInfo ClientIndex Int AccountInfo
   184     | TimerAction Int
   169     | TimerAction Int
   185     | Remove ClientIndex
   170     | Remove ClientIndex
   186 
   171 
   187 instance Show CoreMessage where
       
   188     show (Accept _) = "Accept"
       
   189     show (ClientMessage _) = "ClientMessage"
       
   190     show (ClientAccountInfo {}) = "ClientAccountInfo"
       
   191     show (TimerAction _) = "TimerAction"
       
   192     show (Remove _) = "Remove"
       
   193 
       
   194 type MRnC = MRoomsAndClients RoomInfo ClientInfo
   172 type MRnC = MRoomsAndClients RoomInfo ClientInfo
   195 type IRnC = IRoomsAndClients RoomInfo ClientInfo
   173 type IRnC = IRoomsAndClients RoomInfo ClientInfo
   196 
   174 
   197 data Notice =
   175 data Notice =
   198     NickAlreadyInUse
   176     NickAlreadyInUse
   210      deriving Typeable
   188      deriving Typeable
   211 
   189 
   212 instance Show ShutdownThreadException where
   190 instance Show ShutdownThreadException where
   213     show (ShutdownThreadException s) = s
   191     show (ShutdownThreadException s) = s
   214 instance Exception ShutdownThreadException
   192 instance Exception ShutdownThreadException
       
   193 
       
   194 data BanInfo =
       
   195     BanByIP String UTCTime
       
   196     | BanByNickname String UTCTime
       
   197     deriving (Show, Read)