2023-12-10 16:00:50 +00:00
|
|
|
module Library.Types
|
|
|
|
( module T
|
2023-12-10 19:12:53 +00:00
|
|
|
, module Library.Types
|
2023-12-10 16:00:50 +00:00
|
|
|
) where
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
import Data.Matrix
|
|
|
|
import Graphics.Vty
|
2023-12-07 16:31:28 +00:00
|
|
|
import Linear
|
2023-12-05 04:41:16 +00:00
|
|
|
|
2023-12-10 16:00:50 +00:00
|
|
|
import Library.Types.Communication as T
|
|
|
|
|
2023-12-05 04:41:16 +00:00
|
|
|
-- | 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)
|
2023-12-08 04:19:32 +00:00
|
|
|
, wizardEffects :: [Effect]
|
2023-12-05 04:41:16 +00:00
|
|
|
-- ^ 'Effect's affecting the player
|
|
|
|
}
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
-- | 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
|
2023-12-07 17:20:28 +00:00
|
|
|
type ServerMap = Matrix Tile
|
|
|
|
|
|
|
|
-- | Type synonym for the Map. Translates to a Matrix of 'Maybe Tile's
|
|
|
|
type ClientMap = Matrix (Maybe Tile)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
data Tile
|
|
|
|
= Air -- ^ walkable area
|
|
|
|
| Wall -- ^ obstacle
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
data Arena = Arena
|
2023-12-07 17:20:28 +00:00
|
|
|
{ arenaMap :: ServerMap
|
2023-12-05 04:41:16 +00:00
|
|
|
, arenaSpawners :: [Spawner]
|
|
|
|
}
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
data Spawner = Spawner
|
|
|
|
{ spawnerPowerup :: Wand -- ^ Which 'Powerup' is being spawned
|
|
|
|
, spawnerReloadTime :: Int -- ^ How long does it take for the 'Powerup' to reappear
|
2023-12-07 21:17:03 +00:00
|
|
|
, spawnerState :: SpawnerState
|
|
|
|
, spawnerReloadTTL :: Float
|
2023-12-05 04:41:16 +00:00
|
|
|
, spawnerPosition :: Position -- ^ Position of the `Spawner` on the map
|
|
|
|
}
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
-- List of all available Wands
|
|
|
|
data Wand
|
|
|
|
= HealthUp -- ^ Instant Health boost
|
|
|
|
| ManaUp -- ^ Instant Mana boost
|
2023-12-07 16:31:28 +00:00
|
|
|
| Shield -- ^ Magical shield protecting the player
|
2023-12-05 04:41:16 +00:00
|
|
|
| BigWand -- ^ Stronger Zap spell
|
|
|
|
| FireWand -- ^ Spell for causing fire damage
|
|
|
|
| IceWand -- ^ Spell for causing ice damage
|
2023-12-05 07:20:10 +00:00
|
|
|
| BlinkWand -- ^ Spell for random teleport
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq, Enum, Bounded)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
2023-12-07 21:17:03 +00:00
|
|
|
data SpawnerState
|
|
|
|
= SpawnerFull
|
|
|
|
| SpawnerEmpty
|
|
|
|
deriving (Eq, Show)
|
|
|
|
|
2023-12-05 04:41:16 +00:00
|
|
|
data Effect = Effect
|
|
|
|
{ effectType :: Affliction -- ^ What is happening
|
|
|
|
, effectTTL :: Float -- ^ remaining time
|
|
|
|
}
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-05 04:41:16 +00:00
|
|
|
|
|
|
|
data Affliction
|
2023-12-07 21:17:03 +00:00
|
|
|
= Burning -- ^ Damage over time
|
|
|
|
| Frozen -- ^ Unable to perform any action
|
|
|
|
| Shielded -- ^ invulnerable until next hit or time runs out.
|
2023-12-07 16:31:28 +00:00
|
|
|
deriving (Show, Eq)
|
2023-12-08 04:19:32 +00:00
|
|
|
|
|
|
|
harmingAfflictions :: [ Affliction ]
|
|
|
|
harmingAfflictions =
|
|
|
|
[ Burning
|
|
|
|
, Frozen
|
|
|
|
]
|