80 lines
2.3 KiB
Haskell
80 lines
2.3 KiB
Haskell
module Library.Types where
|
|
|
|
import Data.Matrix
|
|
import Linear
|
|
import Graphics.Vty
|
|
|
|
-- | Just a type synonym for any kind of position. Translates to a 2D vector
|
|
type Position = V2 Float
|
|
|
|
-- | Data object for storing player state
|
|
data Wizard = Wizard
|
|
{ wizardPos :: Position
|
|
-- ^ Player's position
|
|
, wizardRot :: Float
|
|
-- ^ Player's view direction
|
|
, wizardHealth :: Int
|
|
-- ^ Player's hit points
|
|
, wizardMana :: Int
|
|
-- ^ Player's Mana (magic fuel)
|
|
, wizardWands :: [Wand]
|
|
-- ^ Player's wands (read: weapons)
|
|
, wizardEffect :: [Effect]
|
|
-- ^ 'Effect's affecting the player
|
|
}
|
|
|
|
-- | Data object for storing the client's state
|
|
data ClientState = ClientState
|
|
{ clientVty :: Vty -- ^ Context object for graphics
|
|
, clientGameOver :: Bool -- ^ client game over (contestant died)
|
|
, clientStop :: Bool -- ^ client shutdown
|
|
}
|
|
|
|
-- | Data object for storing the server's state
|
|
data ServerState = ServerState
|
|
{ serverGameOver :: Bool -- ^ global game over state (only one contestant left)
|
|
, serverStop :: Bool -- ^ Server shutdown
|
|
}
|
|
|
|
-- | Type synonym for the Map. Translates to a Matrix of 'Tile's
|
|
type Map = Matrix Tile
|
|
|
|
data Tile
|
|
= Air -- ^ walkable area
|
|
| Wall -- ^ obstacle
|
|
deriving (Show)
|
|
|
|
data ServerOptions = ServerOptions
|
|
{ serOptMapWidth :: Int -- ^ Map width
|
|
, serOptMapHeight :: Int -- ^ Map height
|
|
}
|
|
|
|
data Arena = Arena
|
|
{ arenaMap :: Map
|
|
, arenaSpawners :: [Spawner]
|
|
}
|
|
|
|
data Spawner = Spawner
|
|
{ spawnerPowerup :: Wand -- ^ Which 'Powerup' is being spawned
|
|
, spawnerReloadTime :: Int -- ^ How long does it take for the 'Powerup' to reappear
|
|
, spawnerPosition :: Position -- ^ Position of the `Spawner` on the map
|
|
}
|
|
|
|
-- List of all available Wands
|
|
data Wand
|
|
= HealthUp -- ^ Instant Health boost
|
|
| ManaUp -- ^ Instant Mana boost
|
|
| Shield -- ^ Magical sield protecting the player
|
|
| BigWand -- ^ Stronger Zap spell
|
|
| FireWand -- ^ Spell for causing fire damage
|
|
| IceWand -- ^ Spell for causing ice damage
|
|
| BlinkWand -- ^ Spell for random teleport
|
|
|
|
data Effect = Effect
|
|
{ effectType :: Affliction -- ^ What is happening
|
|
, effectTTL :: Float -- ^ remaining time
|
|
}
|
|
|
|
data Affliction
|
|
= Burning -- ^ Damage over time
|
|
| Frozen -- ^ Unable to perform any action
|