{-# LANGUAGE DerivingVia #-}
module Swarm.Game.Scenario.Topography.EntityFacade where
import Control.Lens ((^.))
import Data.Text (Text)
import Data.Yaml as Y (ToJSON (toJSON))
import Swarm.Game.Display (Display)
import Swarm.Game.Entity qualified as E
type EntityName = Text
data EntityFacade = EntityFacade EntityName Display
deriving (EntityFacade -> EntityFacade -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityFacade -> EntityFacade -> Bool
$c/= :: EntityFacade -> EntityFacade -> Bool
== :: EntityFacade -> EntityFacade -> Bool
$c== :: EntityFacade -> EntityFacade -> Bool
Eq)
instance ToJSON EntityFacade where
toJSON :: EntityFacade -> Value
toJSON (EntityFacade EntityName
eName Display
_display) = forall a. ToJSON a => a -> Value
toJSON EntityName
eName
mkFacade :: E.Entity -> EntityFacade
mkFacade :: Entity -> EntityFacade
mkFacade Entity
e =
EntityName -> Display -> EntityFacade
EntityFacade
(Entity
e forall s a. s -> Getting a s a -> a
^. Lens' Entity EntityName
E.entityName)
(Entity
e forall s a. s -> Getting a s a -> a
^. Lens' Entity Display
E.entityDisplay)