prepare server/client communication
This commit is contained in:
parent
8aeef3505b
commit
b7714fbb09
3 changed files with 9 additions and 4 deletions
|
@ -39,7 +39,10 @@ data ServerState = ServerState
|
|||
deriving (Show, Eq)
|
||||
|
||||
-- | Type synonym for the Map. Translates to a Matrix of 'Tile's
|
||||
type Map = Matrix Tile
|
||||
type ServerMap = Matrix Tile
|
||||
|
||||
-- | Type synonym for the Map. Translates to a Matrix of 'Maybe Tile's
|
||||
type ClientMap = Matrix (Maybe Tile)
|
||||
|
||||
data Tile
|
||||
= Air -- ^ walkable area
|
||||
|
@ -53,7 +56,7 @@ data ServerOptions = ServerOptions
|
|||
deriving (Show, Eq)
|
||||
|
||||
data Arena = Arena
|
||||
{ arenaMap :: Map
|
||||
{ arenaMap :: ServerMap
|
||||
, arenaSpawners :: [Spawner]
|
||||
}
|
||||
deriving (Show, Eq)
|
||||
|
|
|
@ -43,12 +43,12 @@ generateArena arenaRows arenaColumns spawnerChance = do
|
|||
generateMap
|
||||
:: Int -- ^ Map's height
|
||||
-> Int -- ^ Map's width
|
||||
-> IO Map -- ^ resulting Map
|
||||
-> IO ServerMap -- ^ resulting Map
|
||||
generateMap mapRows mapColumns = do
|
||||
let initMap = M.matrix mapRows mapColumns (const Air)
|
||||
divide 0 0 mapRows mapColumns initMap
|
||||
where
|
||||
divide :: Int -> Int -> Int -> Int -> Map -> IO Map
|
||||
divide :: Int -> Int -> Int -> Int -> ServerMap -> IO ServerMap
|
||||
divide rowOffset colOffset rowSize colSize tilemap
|
||||
| rowSize <= 3 || colSize <= 3 = pure tilemap
|
||||
| otherwise = do
|
||||
|
|
|
@ -33,6 +33,7 @@ executable wizard-wipeout-client
|
|||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base ^>=4.17.2.1
|
||||
, network
|
||||
, wizard-wipeout
|
||||
hs-source-dirs: src-client
|
||||
default-language: GHC2021
|
||||
|
@ -46,6 +47,7 @@ executable wizard-wipeout-server
|
|||
build-depends: base ^>=4.17.2.1
|
||||
, linear
|
||||
, matrix
|
||||
, network
|
||||
, random
|
||||
, wizard-wipeout
|
||||
hs-source-dirs: src-server
|
||||
|
|
Loading…
Reference in a new issue