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
+20 -4
View File
@@ -1,7 +1,10 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StrictData #-}
module Dodge.Creature.State.Data
where
import GHC.Generics
import Data.Aeson
--import Geometry
import Geometry.Data
import Color
@@ -12,11 +15,17 @@ data CreatureDropType
= DropAll
| DropAmount Int
| DropSpecific [Int]
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON CreatureDropType where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CreatureDropType
data CrSpState
= Barrel { _piercedPoints :: [Point2]}
| GenCr
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON CrSpState where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CrSpState
data Faction
= GenericFaction Int
| ZombieFaction
@@ -26,7 +35,10 @@ data Faction
| NoFaction
| ColorFaction Color
| PlayerFaction
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON Faction where
toEncoding = genericToEncoding defaultOptions
instance FromJSON Faction
data CrGroup
= LoneWolf
| Swarm
@@ -35,5 +47,9 @@ data CrGroup
}
| CrGroupID { _crGroupID :: Int }
| ShieldGroup
deriving (Eq,Ord,Show,Read)
deriving (Eq,Ord,Show,Read,Generic)
instance ToJSON CrGroup where
toEncoding = genericToEncoding defaultOptions
instance FromJSON CrGroup
makeLenses ''CrSpState
makeLenses ''CrGroup