Add generic derivations and To/FromJSON instances
This commit is contained in:
+19
-5
@@ -3,6 +3,8 @@
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
module Dodge.Data.Wall where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Data.Material
|
||||
import Geometry
|
||||
import Color
|
||||
@@ -26,15 +28,24 @@ data Wall = Wall
|
||||
, _wlHeight :: Float
|
||||
, _wlMaterial :: Material
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Wall where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Wall
|
||||
data Opacity
|
||||
= SeeThrough
|
||||
| SeeAbove
|
||||
| DrawnWall {_opDraw :: WallDraw } -- Wall -> SPic
|
||||
| Opaque
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON Opacity where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON Opacity
|
||||
data WallDraw = DrawForceField
|
||||
deriving (Eq,Ord,Show,Read,Enum,Bounded)
|
||||
deriving (Eq,Ord,Show,Read,Enum,Bounded,Generic)
|
||||
instance ToJSON WallDraw where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON WallDraw
|
||||
data WallStructure
|
||||
= StandaloneWall
|
||||
| DoorPart { _wsDoor :: Int }
|
||||
@@ -44,7 +55,10 @@ data WallStructure
|
||||
{ _wlStCreature :: Int
|
||||
-- , _wlStDamCreature :: Damage -> Wall -> Int -> World -> World
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON WallStructure where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON WallStructure
|
||||
makeLenses ''Wall
|
||||
makeLenses ''WallStructure
|
||||
makeLenses ''Opacity
|
||||
makeLenses ''WallStructure
|
||||
|
||||
Reference in New Issue
Block a user