module Rattletrap.Type.Attribute.ExtendedExplosion where import qualified Rattletrap.BitGet as BitGet import qualified Rattletrap.BitPut as BitPut import qualified Rattletrap.Schema as Schema import qualified Rattletrap.Type.Attribute.Explosion as Explosion import qualified Rattletrap.Type.Attribute.FlaggedInt as FlaggedInt import qualified Rattletrap.Type.Version as Version import qualified Rattletrap.Utility.Json as Json data ExtendedExplosion = ExtendedExplosion { ExtendedExplosion -> Explosion explosion :: Explosion.Explosion , ExtendedExplosion -> FlaggedInt unknown :: FlaggedInt.FlaggedInt } deriving (ExtendedExplosion -> ExtendedExplosion -> Bool (ExtendedExplosion -> ExtendedExplosion -> Bool) -> (ExtendedExplosion -> ExtendedExplosion -> Bool) -> Eq ExtendedExplosion forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: ExtendedExplosion -> ExtendedExplosion -> Bool $c/= :: ExtendedExplosion -> ExtendedExplosion -> Bool == :: ExtendedExplosion -> ExtendedExplosion -> Bool $c== :: ExtendedExplosion -> ExtendedExplosion -> Bool Eq, Int -> ExtendedExplosion -> ShowS [ExtendedExplosion] -> ShowS ExtendedExplosion -> String (Int -> ExtendedExplosion -> ShowS) -> (ExtendedExplosion -> String) -> ([ExtendedExplosion] -> ShowS) -> Show ExtendedExplosion forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [ExtendedExplosion] -> ShowS $cshowList :: [ExtendedExplosion] -> ShowS show :: ExtendedExplosion -> String $cshow :: ExtendedExplosion -> String showsPrec :: Int -> ExtendedExplosion -> ShowS $cshowsPrec :: Int -> ExtendedExplosion -> ShowS Show) instance Json.FromJSON ExtendedExplosion where parseJSON :: Value -> Parser ExtendedExplosion parseJSON = String -> (Object -> Parser ExtendedExplosion) -> Value -> Parser ExtendedExplosion forall a. String -> (Object -> Parser a) -> Value -> Parser a Json.withObject String "ExtendedExplosion" ((Object -> Parser ExtendedExplosion) -> Value -> Parser ExtendedExplosion) -> (Object -> Parser ExtendedExplosion) -> Value -> Parser ExtendedExplosion forall a b. (a -> b) -> a -> b $ \Object object -> do Explosion explosion <- Object -> String -> Parser Explosion forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "explosion" FlaggedInt unknown <- Object -> String -> Parser FlaggedInt forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "unknown" ExtendedExplosion -> Parser ExtendedExplosion forall (f :: * -> *) a. Applicative f => a -> f a pure ExtendedExplosion :: Explosion -> FlaggedInt -> ExtendedExplosion ExtendedExplosion { Explosion explosion :: Explosion explosion :: Explosion explosion, FlaggedInt unknown :: FlaggedInt unknown :: FlaggedInt unknown } instance Json.ToJSON ExtendedExplosion where toJSON :: ExtendedExplosion -> Value toJSON ExtendedExplosion x = [Pair] -> Value Json.object [String -> Explosion -> Pair forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "explosion" (Explosion -> Pair) -> Explosion -> Pair forall a b. (a -> b) -> a -> b $ ExtendedExplosion -> Explosion explosion ExtendedExplosion x, String -> FlaggedInt -> Pair forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "unknown" (FlaggedInt -> Pair) -> FlaggedInt -> Pair forall a b. (a -> b) -> a -> b $ ExtendedExplosion -> FlaggedInt unknown ExtendedExplosion x] schema :: Schema.Schema schema :: Schema schema = String -> Value -> Schema Schema.named String "attribute-extended-explosion" (Value -> Schema) -> Value -> Schema forall a b. (a -> b) -> a -> b $ [(Pair, Bool)] -> Value Schema.object [ (String -> Value -> Pair forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "explosion" (Value -> Pair) -> Value -> Pair forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema Explosion.schema, Bool True) , (String -> Value -> Pair forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "unknown" (Value -> Pair) -> Value -> Pair forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema FlaggedInt.schema, Bool True) ] bitPut :: ExtendedExplosion -> BitPut.BitPut bitPut :: ExtendedExplosion -> BitPut bitPut ExtendedExplosion x = Explosion -> BitPut Explosion.bitPut (ExtendedExplosion -> Explosion explosion ExtendedExplosion x) BitPut -> BitPut -> BitPut forall a. Semigroup a => a -> a -> a <> FlaggedInt -> BitPut FlaggedInt.bitPut (ExtendedExplosion -> FlaggedInt unknown ExtendedExplosion x) bitGet :: Version.Version -> BitGet.BitGet ExtendedExplosion bitGet :: Version -> BitGet ExtendedExplosion bitGet Version version = String -> BitGet ExtendedExplosion -> BitGet ExtendedExplosion forall a. String -> BitGet a -> BitGet a BitGet.label String "ExtendedExplosion" (BitGet ExtendedExplosion -> BitGet ExtendedExplosion) -> BitGet ExtendedExplosion -> BitGet ExtendedExplosion forall a b. (a -> b) -> a -> b $ do Explosion explosion <- String -> BitGet Explosion -> BitGet Explosion forall a. String -> BitGet a -> BitGet a BitGet.label String "explosion" (BitGet Explosion -> BitGet Explosion) -> BitGet Explosion -> BitGet Explosion forall a b. (a -> b) -> a -> b $ Version -> BitGet Explosion Explosion.bitGet Version version FlaggedInt unknown <- String -> BitGet FlaggedInt -> BitGet FlaggedInt forall a. String -> BitGet a -> BitGet a BitGet.label String "unknown" BitGet FlaggedInt FlaggedInt.bitGet ExtendedExplosion -> BitGet ExtendedExplosion forall (f :: * -> *) a. Applicative f => a -> f a pure ExtendedExplosion :: Explosion -> FlaggedInt -> ExtendedExplosion ExtendedExplosion { Explosion explosion :: Explosion explosion :: Explosion explosion, FlaggedInt unknown :: FlaggedInt unknown :: FlaggedInt unknown }