gameServer/CoreTypes.hs
changeset 4932 f11d80bac7ed
parent 4918 c6d3aec73f93
child 4941 90572c338e60
equal deleted inserted replaced
4931:da43c36a6e92 4932:f11d80bac7ed
     1 {-# LANGUAGE OverloadedStrings #-}
     1 {-# LANGUAGE OverloadedStrings #-}
     2 module CoreTypes where
     2 module CoreTypes where
     3 
     3 
     4 import System.IO
       
     5 import Control.Concurrent
     4 import Control.Concurrent
     6 import Control.Concurrent.Chan
       
     7 import Control.Concurrent.STM
     5 import Control.Concurrent.STM
     8 import Data.Word
     6 import Data.Word
     9 import qualified Data.Map as Map
     7 import qualified Data.Map as Map
    10 import qualified Data.IntSet as IntSet
       
    11 import Data.Sequence(Seq, empty)
     8 import Data.Sequence(Seq, empty)
    12 import Data.Time
     9 import Data.Time
    13 import Network
    10 import Network
    14 import Data.Function
    11 import Data.Function
    15 import Data.ByteString.Char8 as B
    12 import Data.ByteString.Char8 as B
    39         clientClan :: B.ByteString,
    36         clientClan :: B.ByteString,
    40         teamsInGame :: Word
    37         teamsInGame :: Word
    41     }
    38     }
    42 
    39 
    43 instance Show ClientInfo where
    40 instance Show ClientInfo where
    44     show ci = " nick: " ++ (unpack $ nick ci) ++ " host: " ++ (unpack $ host ci)
    41     show ci = " nick: " ++ unpack (nick ci) ++ " host: " ++ unpack (host ci)
    45 
    42 
    46 instance Eq ClientInfo where
    43 instance Eq ClientInfo where
    47     (==) = (==) `on` clientSocket
    44     (==) = (==) `on` clientSocket
    48 
    45 
    49 data HedgehogInfo =
    46 data HedgehogInfo =
    64         hhnum :: Int,
    61         hhnum :: Int,
    65         hedgehogs :: [HedgehogInfo]
    62         hedgehogs :: [HedgehogInfo]
    66     }
    63     }
    67 
    64 
    68 instance Show TeamInfo where
    65 instance Show TeamInfo where
    69     show ti = "owner: " ++ (unpack $ teamowner ti)
    66     show ti = "owner: " ++ unpack (teamowner ti)
    70             ++ "name: " ++ (unpack $ teamname ti)
    67             ++ "name: " ++ unpack (teamname ti)
    71             ++ "color: " ++ (unpack $ teamcolor ti)
    68             ++ "color: " ++ unpack (teamcolor ti)
    72 
    69 
    73 data RoomInfo =
    70 data RoomInfo =
    74     RoomInfo
    71     RoomInfo
    75     {
    72     {
    76         masterID :: ClientIndex,
    73         masterID :: ClientIndex,
    93     show ri = ", players: " ++ show (playersIn ri)
    90     show ri = ", players: " ++ show (playersIn ri)
    94             ++ ", ready: " ++ show (readyPlayers ri)
    91             ++ ", ready: " ++ show (readyPlayers ri)
    95             ++ ", teams: " ++ show (teams ri)
    92             ++ ", teams: " ++ show (teams ri)
    96 
    93 
    97 newRoom :: RoomInfo
    94 newRoom :: RoomInfo
    98 newRoom = (
    95 newRoom =
    99     RoomInfo
    96     RoomInfo
   100         undefined
    97         undefined
   101         ""
    98         ""
   102         ""
    99         ""
   103         0
   100         0
   109         False
   106         False
   110         Data.Sequence.empty
   107         Data.Sequence.empty
   111         []
   108         []
   112         []
   109         []
   113         (Map.singleton "MAP" ["+rnd+"])
   110         (Map.singleton "MAP" ["+rnd+"])
   114     )
       
   115 
   111 
   116 data StatisticsInfo =
   112 data StatisticsInfo =
   117     StatisticsInfo
   113     StatisticsInfo
   118     {
   114     {
   119         playersNumber :: Int,
   115         playersNumber :: Int,
   140 
   136 
   141 instance Show ServerInfo where
   137 instance Show ServerInfo where
   142     show _ = "Server Info"
   138     show _ = "Server Info"
   143 
   139 
   144 newServerInfo :: TMVar StatisticsInfo -> Chan CoreMessage -> Chan DBQuery -> ServerInfo
   140 newServerInfo :: TMVar StatisticsInfo -> Chan CoreMessage -> Chan DBQuery -> ServerInfo
   145 newServerInfo = (
   141 newServerInfo =
   146     ServerInfo
   142     ServerInfo
   147         True
   143         True
   148         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   144         "<h2><p align=center><a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a></p></h2>"
   149         "<font color=yellow><h3 align=center>Hedgewars 0.9.14.1 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   145         "<font color=yellow><h3 align=center>Hedgewars 0.9.14.1 is out! Please update.</h3><p align=center><a href=http://hedgewars.org/download.html>Download page here</a></font>"
   150         35
   146         35
   152         0
   148         0
   153         ""
   149         ""
   154         ""
   150         ""
   155         ""
   151         ""
   156         []
   152         []
   157     )
       
   158 
   153 
   159 data AccountInfo =
   154 data AccountInfo =
   160     HasAccount B.ByteString Bool
   155     HasAccount B.ByteString Bool
   161     | Guest
   156     | Guest
   162     | Admin
   157     | Admin