Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user