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
+19 -5
View File
@@ -1,6 +1,9 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.ItEffect where
import GHC.Generics
import Data.Aeson
import Control.Lens
-- I believe this is called every frame, not sure when though
data ItEffect
@@ -27,8 +30,10 @@ data ItEffect
, _ieDrop :: ItDropEffect --Item -> Creature -> World -> World
, _ieMID :: Maybe Int
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItEffect where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItEffect
data ItInvEffect = NoInvEffect
| RewindEffect
| ResetAttachmentEffect
@@ -36,9 +41,18 @@ data ItInvEffect = NoInvEffect
| CreateHeldLight
| CreateShieldWall
| RemoveShieldWall
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItInvEffect where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItInvEffect
data ItFloorEffect = NoFloorEffect
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItFloorEffect where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItFloorEffect
data ItDropEffect = NoDropEffect
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItDropEffect where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItDropEffect
makeLenses ''ItEffect