Skip to content

Commit

Permalink
instance ToJSON StaticKeywordAbility
Browse files Browse the repository at this point in the history
  • Loading branch information
MedeaMelana committed Nov 8, 2013
1 parent 02e659d commit 18e08df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Magic-Web-Server/src/Magic/Json.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

module Magic.Json (interactToJSON) where

Expand Down Expand Up @@ -144,7 +145,7 @@ instance ToJSONPairs Object where
, "timestamp" .= _timestamp o
, "counters" .= _counters o
, "pt" .= maybe Null (\(p,t) -> obj [ "power" .= p, "toughness" .= t ]) (_pt o)
--, "staticKeywordAbilities" .= _staticKeywordAbilities
, "staticKeywordAbilities" .= _staticKeywordAbilities o
]


Expand Down Expand Up @@ -180,6 +181,13 @@ instance ToJSON LandSubtype where toJSON = toJSON . show
instance ToJSON PlaneswalkerSubtype where toJSON = toJSON . show


instance ToJSON StaticKeywordAbility where
toJSON = \case
FirstStrike -> "first strike"
ProtectionFromColor c ->
toJSON ("protection from " ++ map toLower (show c))
ab -> (toJSON . map toLower . show) ab

instance ToJSON PriorityAction where
toJSON a = typedObject $ case a of
PlayCard r -> ("playCard", [ "objectRef" .= someObjectRefToJSON r ])
Expand Down

0 comments on commit 18e08df

Please sign in to comment.