{-# LANGUAGE DeriveGeneric, GeneralizedNewtypeDeriving #-}
module Game.LambdaHack.Common.Types
( ItemId, FactionId, LevelId, ActorId
, Container(..), ppContainer
) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Data.Binary
import Data.Hashable
import GHC.Generics (Generic)
import Game.LambdaHack.Common.Point
import Game.LambdaHack.Definition.Defs
newtype ItemId = ItemId Int
deriving (Show, Eq, Ord, Enum, Binary)
newtype FactionId = FactionId Int
deriving (Show, Eq, Ord, Enum, Hashable, Binary)
newtype LevelId = LevelId Int
deriving (Show, Eq, Ord, Hashable, Binary)
instance Enum LevelId where
fromEnum (LevelId n) = n
toEnum = LevelId
newtype ActorId = ActorId Int
deriving (Show, Eq, Ord, Enum, Binary)
data Container =
CFloor LevelId Point
| CEmbed LevelId Point
| CActor ActorId CStore
| CTrunk FactionId LevelId Point
deriving (Show, Eq, Ord, Generic)
instance Binary Container
ppContainer :: Container -> Text
ppContainer CFloor{} = "nearby"
ppContainer CEmbed{} = "embedded nearby"
ppContainer (CActor _ cstore) = ppCStoreIn cstore
ppContainer c@CTrunk{} = error $ "" `showFailure` c