diff --git a/src/Data/Aeson/TickLeiste.hs b/src/Data/Aeson/TickLeiste.hs new file mode 100644 index 0000000..ee3cbf3 --- /dev/null +++ b/src/Data/Aeson/TickLeiste.hs @@ -0,0 +1,37 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} + +module Data.Aeson.TickLeiste + ( JSONRequest (..), + JSONEvent (..), + ) +where + +import Data.Aeson +import Data.Aeson.TH +import qualified Data.Text as T +import Data.TickLeiste +import qualified Data.UUID as U + +$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "tickType", contentsFieldName = "tickValue"}} ''Tick) + +data JSONRequest + = SetPlayerTickR {sptRplayerUUID :: U.UUID, sptRtick :: Tick} + | AddPlayerTickR {aptRplayerName :: T.Text, aptRtick :: Tick} + | InitializeTickLeisteR {itlRtickLeiste :: [(Tick, [T.Text])]} + | TickLeisteR + | ChangeNameR {cnaRplayerUUID :: U.UUID, cnaRplayerName :: T.Text} + | RemovePlayerR {rmpRplayerUUID :: U.UUID} + deriving (Show,Eq) + +$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "requestType"}, fieldLabelModifier = drop 4} ''JSONRequest) + +data JSONEvent + = SetPlayerTickE {sptEplayerUUID :: U.UUID, sptEtick :: Tick} + | AddPlayerTickE {aptEplayerUUID :: U.UUID, aptEplayerName :: T.Text, aptEtick :: Tick} + | InitializeTickLeisteE {itlEtickLeiste :: [(Tick, [(U.UUID, T.Text)])]} + | ChangeNameE {cnaEplayerUUID :: U.UUID, cnaEplayerName :: T.Text} + | RemovePlayerE {rmpEplayerUUID :: U.UUID} + deriving (Show,Eq) + +$(deriveJSON defaultOptions {sumEncoding = defaultTaggedObject {tagFieldName = "eventType"}, fieldLabelModifier = drop 4} ''JSONEvent)