prepare server/client communication

This commit is contained in:
nek0 2023-12-07 18:20:28 +01:00
parent 8aeef3505b
commit b7714fbb09
3 changed files with 9 additions and 4 deletions

View file

@ -39,7 +39,10 @@ data ServerState = ServerState
deriving (Show, Eq) deriving (Show, Eq)
-- | Type synonym for the Map. Translates to a Matrix of 'Tile's -- | 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 data Tile
= Air -- ^ walkable area = Air -- ^ walkable area
@ -53,7 +56,7 @@ data ServerOptions = ServerOptions
deriving (Show, Eq) deriving (Show, Eq)
data Arena = Arena data Arena = Arena
{ arenaMap :: Map { arenaMap :: ServerMap
, arenaSpawners :: [Spawner] , arenaSpawners :: [Spawner]
} }
deriving (Show, Eq) deriving (Show, Eq)

View file

@ -43,12 +43,12 @@ generateArena arenaRows arenaColumns spawnerChance = do
generateMap generateMap
:: Int -- ^ Map's height :: Int -- ^ Map's height
-> Int -- ^ Map's width -> Int -- ^ Map's width
-> IO Map -- ^ resulting Map -> IO ServerMap -- ^ resulting Map
generateMap mapRows mapColumns = do generateMap mapRows mapColumns = do
let initMap = M.matrix mapRows mapColumns (const Air) let initMap = M.matrix mapRows mapColumns (const Air)
divide 0 0 mapRows mapColumns initMap divide 0 0 mapRows mapColumns initMap
where where
divide :: Int -> Int -> Int -> Int -> Map -> IO Map divide :: Int -> Int -> Int -> Int -> ServerMap -> IO ServerMap
divide rowOffset colOffset rowSize colSize tilemap divide rowOffset colOffset rowSize colSize tilemap
| rowSize <= 3 || colSize <= 3 = pure tilemap | rowSize <= 3 || colSize <= 3 = pure tilemap
| otherwise = do | otherwise = do

View file

@ -33,6 +33,7 @@ executable wizard-wipeout-client
-- other-modules: -- other-modules:
-- other-extensions: -- other-extensions:
build-depends: base ^>=4.17.2.1 build-depends: base ^>=4.17.2.1
, network
, wizard-wipeout , wizard-wipeout
hs-source-dirs: src-client hs-source-dirs: src-client
default-language: GHC2021 default-language: GHC2021
@ -46,6 +47,7 @@ executable wizard-wipeout-server
build-depends: base ^>=4.17.2.1 build-depends: base ^>=4.17.2.1
, linear , linear
, matrix , matrix
, network
, random , random
, wizard-wipeout , wizard-wipeout
hs-source-dirs: src-server hs-source-dirs: src-server