module TD.Query.SetInlineGameScore
  (SetInlineGameScore(..)
  , defaultSetInlineGameScore
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T

-- | Updates the game score of the specified user in a game; for bots only. Returns 'TD.Data.Ok.Ok'
data SetInlineGameScore
  = SetInlineGameScore
    { SetInlineGameScore -> Maybe Text
inline_message_id :: Maybe T.Text -- ^ Inline message identifier
    , SetInlineGameScore -> Maybe Bool
edit_message      :: Maybe Bool   -- ^ Pass true to edit the game message to include the current scoreboard
    , SetInlineGameScore -> Maybe Int
user_id           :: Maybe Int    -- ^ User identifier
    , SetInlineGameScore -> Maybe Int
score             :: Maybe Int    -- ^ The new score
    , SetInlineGameScore -> Maybe Bool
force             :: Maybe Bool   -- ^ Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table
    }
  deriving (SetInlineGameScore -> SetInlineGameScore -> Bool
(SetInlineGameScore -> SetInlineGameScore -> Bool)
-> (SetInlineGameScore -> SetInlineGameScore -> Bool)
-> Eq SetInlineGameScore
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetInlineGameScore -> SetInlineGameScore -> Bool
== :: SetInlineGameScore -> SetInlineGameScore -> Bool
$c/= :: SetInlineGameScore -> SetInlineGameScore -> Bool
/= :: SetInlineGameScore -> SetInlineGameScore -> Bool
Eq, Int -> SetInlineGameScore -> ShowS
[SetInlineGameScore] -> ShowS
SetInlineGameScore -> String
(Int -> SetInlineGameScore -> ShowS)
-> (SetInlineGameScore -> String)
-> ([SetInlineGameScore] -> ShowS)
-> Show SetInlineGameScore
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetInlineGameScore -> ShowS
showsPrec :: Int -> SetInlineGameScore -> ShowS
$cshow :: SetInlineGameScore -> String
show :: SetInlineGameScore -> String
$cshowList :: [SetInlineGameScore] -> ShowS
showList :: [SetInlineGameScore] -> ShowS
Show)

instance I.ShortShow SetInlineGameScore where
  shortShow :: SetInlineGameScore -> String
shortShow
    SetInlineGameScore
      { inline_message_id :: SetInlineGameScore -> Maybe Text
inline_message_id = Maybe Text
inline_message_id_
      , edit_message :: SetInlineGameScore -> Maybe Bool
edit_message      = Maybe Bool
edit_message_
      , user_id :: SetInlineGameScore -> Maybe Int
user_id           = Maybe Int
user_id_
      , score :: SetInlineGameScore -> Maybe Int
score             = Maybe Int
score_
      , force :: SetInlineGameScore -> Maybe Bool
force             = Maybe Bool
force_
      }
        = String
"SetInlineGameScore"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"inline_message_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
inline_message_id_
          , String
"edit_message"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
edit_message_
          , String
"user_id"           String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"score"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
score_
          , String
"force"             String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
force_
          ]

instance AT.ToJSON SetInlineGameScore where
  toJSON :: SetInlineGameScore -> Value
toJSON
    SetInlineGameScore
      { inline_message_id :: SetInlineGameScore -> Maybe Text
inline_message_id = Maybe Text
inline_message_id_
      , edit_message :: SetInlineGameScore -> Maybe Bool
edit_message      = Maybe Bool
edit_message_
      , user_id :: SetInlineGameScore -> Maybe Int
user_id           = Maybe Int
user_id_
      , score :: SetInlineGameScore -> Maybe Int
score             = Maybe Int
score_
      , force :: SetInlineGameScore -> Maybe Bool
force             = Maybe Bool
force_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"             Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"setInlineGameScore"
          , Key
"inline_message_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
inline_message_id_
          , Key
"edit_message"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
edit_message_
          , Key
"user_id"           Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
user_id_
          , Key
"score"             Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
score_
          , Key
"force"             Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
force_
          ]

defaultSetInlineGameScore :: SetInlineGameScore
defaultSetInlineGameScore :: SetInlineGameScore
defaultSetInlineGameScore =
  SetInlineGameScore
    { inline_message_id :: Maybe Text
inline_message_id = Maybe Text
forall a. Maybe a
Nothing
    , edit_message :: Maybe Bool
edit_message      = Maybe Bool
forall a. Maybe a
Nothing
    , user_id :: Maybe Int
user_id           = Maybe Int
forall a. Maybe a
Nothing
    , score :: Maybe Int
score             = Maybe Int
forall a. Maybe a
Nothing
    , force :: Maybe Bool
force             = Maybe Bool
forall a. Maybe a
Nothing
    }