Add generic derivations and To/FromJSON instances
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
module Dodge.Data.RightButtonOptions where
|
||||
import GHC.Generics
|
||||
import Data.Aeson
|
||||
import Dodge.Equipment.Data
|
||||
import Control.Lens
|
||||
|
||||
@@ -13,13 +16,19 @@ data RightButtonOptions
|
||||
,_opAllocateEquipment :: AllocateEquipment
|
||||
,_opActivateEquipment :: ActivateEquipment
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON RightButtonOptions where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON RightButtonOptions
|
||||
data ActivateEquipment
|
||||
= ActivateEquipment {_activateEquipment :: Int }
|
||||
| DeactivateEquipment {_deactivateEquipment :: Int}
|
||||
| ActivateDeactivateEquipment {_activateEquipment :: Int ,_deactivateEquipment :: Int}
|
||||
| NoChangeActivateEquipment
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON ActivateEquipment where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON ActivateEquipment
|
||||
data AllocateEquipment
|
||||
= DoNotMoveEquipment
|
||||
| PutOnEquipment
|
||||
@@ -41,7 +50,10 @@ data AllocateEquipment
|
||||
| RemoveEquipment
|
||||
{ _allocOldPos :: EquipPosition
|
||||
}
|
||||
deriving (Eq,Ord,Show,Read)
|
||||
deriving (Eq,Ord,Show,Read,Generic)
|
||||
instance ToJSON AllocateEquipment where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
instance FromJSON AllocateEquipment
|
||||
makeLenses ''RightButtonOptions
|
||||
makeLenses ''AllocateEquipment
|
||||
makeLenses ''ActivateEquipment
|
||||
|
||||
Reference in New Issue
Block a user