92 lines
2.5 KiB
Haskell
92 lines
2.5 KiB
Haskell
module Library.Types where
|
|
|
|
import Data.Matrix
|
|
import Graphics.Vty
|
|
import Linear
|
|
|
|
-- | 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)
|
|
, wizardEffects :: [Effect]
|
|
-- ^ 'Effect's affecting the player
|
|
}
|
|
deriving (Show, Eq)
|
|
|
|
-- | 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
|
|
}
|
|
|
|
-- | Type synonym for the Map. Translates to a Matrix of 'Tile's
|
|
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
|
|
| Wall -- ^ obstacle
|
|
deriving (Show, Eq)
|
|
|
|
data Arena = Arena
|
|
{ arenaMap :: ServerMap
|
|
, arenaSpawners :: [Spawner]
|
|
}
|
|
deriving (Show, Eq)
|
|
|
|
data Spawner = Spawner
|
|
{ spawnerPowerup :: Wand -- ^ Which 'Powerup' is being spawned
|
|
, spawnerReloadTime :: Int -- ^ How long does it take for the 'Powerup' to reappear
|
|
, spawnerState :: SpawnerState
|
|
, spawnerReloadTTL :: Float
|
|
, spawnerPosition :: Position -- ^ Position of the `Spawner` on the map
|
|
}
|
|
deriving (Show, Eq)
|
|
|
|
-- List of all available Wands
|
|
data Wand
|
|
= HealthUp -- ^ Instant Health boost
|
|
| ManaUp -- ^ Instant Mana boost
|
|
| Shield -- ^ Magical shield protecting the player
|
|
| BigWand -- ^ Stronger Zap spell
|
|
| FireWand -- ^ Spell for causing fire damage
|
|
| IceWand -- ^ Spell for causing ice damage
|
|
| BlinkWand -- ^ Spell for random teleport
|
|
deriving (Show, Eq, Enum, Bounded)
|
|
|
|
data SpawnerState
|
|
= SpawnerFull
|
|
| SpawnerEmpty
|
|
deriving (Eq, Show)
|
|
|
|
data Effect = Effect
|
|
{ effectType :: Affliction -- ^ What is happening
|
|
, effectTTL :: Float -- ^ remaining time
|
|
}
|
|
deriving (Show, Eq)
|
|
|
|
data Affliction
|
|
= Burning -- ^ Damage over time
|
|
| Frozen -- ^ Unable to perform any action
|
|
| Shielded -- ^ invulnerable until next hit or time runs out.
|
|
deriving (Show, Eq)
|
|
|
|
harmingAfflictions :: [ Affliction ]
|
|
harmingAfflictions =
|
|
[ Burning
|
|
, Frozen
|
|
]
|