Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Creature
|
||||
@@ -5,6 +6,8 @@ module Dodge.Data.Creature
|
||||
, module Dodge.Data.Creature.Misc
|
||||
, module Dodge.Data.Creature.State
|
||||
) where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Data.Creature.Misc
|
||||
import Dodge.Data.Creature.State
|
||||
import Dodge.Data.Item
|
||||
@@ -62,14 +65,23 @@ data Creature = Creature
|
||||
, _crStatistics :: CreatureStatistics
|
||||
, _crCamouflage :: CamouflageStatus
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Creature where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Creature
|
||||
data CreatureCorpse = MakeDefaultCorpse
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON CreatureCorpse where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON CreatureCorpse
|
||||
data Intention = Intention
|
||||
{ _targetCr :: Maybe Creature
|
||||
, _mvToPoint :: Maybe Point2
|
||||
, _viewPoint :: Maybe Point2
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Intention where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Intention
|
||||
makeLenses ''Creature
|
||||
makeLenses ''Intention
|
||||
|
||||
Reference in New Issue
Block a user