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
+23 -7
View File
@@ -1,15 +1,20 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Data.Item.Misc where
import GHC.Generics
import Data.Aeson
import Geometry.Data
import Control.Lens
data ItemDimension = ItemDimension
{ _dimRad :: Float
, _dimCenter :: Point3
, _dimAttachPos :: Point3
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemDimension where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemDimension
data ItemPortage
= HeldItem
{ _handlePos :: Float
@@ -17,20 +22,31 @@ data ItemPortage
}
| WornItem
| NoPortage
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemPortage where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemPortage
data ItemValue = ItemValue
{ _ivInt :: Int
, _ivType :: ItemValueType
}
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemValue where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemValue
data ItemValueType = MundaneItem | ArtefactItem
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemValueType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemValueType
data ItemPos
= InInv { _ipCrID :: Int , _ipInvID :: Int }
| OnFloor { _ipFlID :: Int }
| VoidItm
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON ItemPos where
toEncoding = genericToEncoding defaultOptions
instance FromJSON ItemPos
makeLenses ''ItemDimension
makeLenses ''ItemPortage
makeLenses ''ItemValue