Add generic derivations and To/FromJSON instances

This commit is contained in:
2022-07-25 22:49:18 +01:00
parent f5604ef429
commit b8e8413daa
99 changed files with 1406 additions and 517 deletions
+11 -6
View File
@@ -1,12 +1,13 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Item.Attachment.Data
where
import GHC.Generics
import Data.Aeson
import Geometry.Data
import Control.Lens
import qualified Data.Sequence as Seq
data ItAttachment
= AttachFuse {_atFuseTime :: Int}
| AttachMode {_atMode :: Int}
@@ -17,8 +18,10 @@ data ItAttachment
| AttachFloat { _atFloat :: Float }
| AttachBool { _atBool :: Bool }
| NoItAttachment
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItAttachment where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItAttachment
data Scope = NoScope
| RemoteScope
{_scopePos :: Point2 -- ^ a camera offset
@@ -32,7 +35,9 @@ data Scope = NoScope
,_scopeDefaultZoom :: Float
,_scopeIsCamera :: Bool -- ^ if the camera offset is also the center of vision
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Scope where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Scope
makeLenses ''ItAttachment
makeLenses ''Scope
+7 -2
View File
@@ -1,9 +1,14 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StrictData #-}
--{-# LANGUAGE TemplateHaskell #-}
module Dodge.Item.Data where
--import Control.Lens
import GHC.Generics
import Data.Aeson
data CurseStatus
= Uncursed
| UndroppableIdentified
| UndroppableUnidentified
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON CurseStatus where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CurseStatus