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)
-- | 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)

View file

@ -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

View file

@ -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