Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.Sensor where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Combine.Data
|
||||
import Dodge.Data.Damage.Type
|
||||
import Control.Lens
|
||||
|
||||
data Sensor = NoSensor
|
||||
| DamageSensor
|
||||
{ _sensToggle :: Bool
|
||||
@@ -17,13 +19,22 @@ data Sensor = NoSensor
|
||||
, _proxRequirement :: ProximityRequirement
|
||||
, _sensToggle :: Bool
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Sensor where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Sensor
|
||||
data ProximityRequirement
|
||||
= RequireHealth {_proxReqMinHealth :: Int}
|
||||
| RequireEquipment {_proxReqEquipment :: ItemBaseType}
|
||||
| RequireImpossible
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ProximityRequirement where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ProximityRequirement
|
||||
data CloseToggle = NotClose | IsClose
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON CloseToggle where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON CloseToggle
|
||||
makeLenses ''Sensor
|
||||
makeLenses ''ProximityRequirement
|
||||
|
||||
Reference in New Issue
Block a user