{-# LANGUAGE DeriveGeneric #-}

module Battlesnake.Core.RulesetSettings where

import Data.Aeson (FromJSON)
import GHC.Generics

{-|
  Information about the ruleset settings used in the game.
  See: https://docs.battlesnake.com/api/objects/ruleset-settings
-}
data RulesetSettings = RulesetSettings
  { RulesetSettings -> Int
foodSpawnChance :: Int
  -- ^ The chance of a food spawning on a new round (0-100).
  , RulesetSettings -> Int
minimumFood :: Int
  -- ^ The minimum number of food that must be kept on the board
  , RulesetSettings -> Int
hazardDamagePerTurn :: Int
  -- ^ The amount of damage snakes take each turn they are in contact with a
  -- hazard. This stacks on top of the base damage of 1 that each snake takes
  -- per turn
  , RulesetSettings -> RoyaleModeSettings
royale :: RoyaleModeSettings
  -- ^ Settings uses in 'royale' mode
  , RulesetSettings -> SquadModeSettings
squad :: SquadModeSettings
  -- ^ Settings used in 'squad' mode
  }
  deriving (Int -> RulesetSettings -> ShowS
[RulesetSettings] -> ShowS
RulesetSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RulesetSettings] -> ShowS
$cshowList :: [RulesetSettings] -> ShowS
show :: RulesetSettings -> String
$cshow :: RulesetSettings -> String
showsPrec :: Int -> RulesetSettings -> ShowS
$cshowsPrec :: Int -> RulesetSettings -> ShowS
Show, RulesetSettings -> RulesetSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RulesetSettings -> RulesetSettings -> Bool
$c/= :: RulesetSettings -> RulesetSettings -> Bool
== :: RulesetSettings -> RulesetSettings -> Bool
$c== :: RulesetSettings -> RulesetSettings -> Bool
Eq, forall x. Rep RulesetSettings x -> RulesetSettings
forall x. RulesetSettings -> Rep RulesetSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RulesetSettings x -> RulesetSettings
$cfrom :: forall x. RulesetSettings -> Rep RulesetSettings x
Generic)

instance FromJSON RulesetSettings

-- | Settings used in `royale` mode
newtype RoyaleModeSettings = RoyaleModeSettings
  { RoyaleModeSettings -> Int
shrinkEveryNTurns :: Int
  -- ^ The number of turns between shrinking the safe board area
  }
  deriving (Int -> RoyaleModeSettings -> ShowS
[RoyaleModeSettings] -> ShowS
RoyaleModeSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoyaleModeSettings] -> ShowS
$cshowList :: [RoyaleModeSettings] -> ShowS
show :: RoyaleModeSettings -> String
$cshow :: RoyaleModeSettings -> String
showsPrec :: Int -> RoyaleModeSettings -> ShowS
$cshowsPrec :: Int -> RoyaleModeSettings -> ShowS
Show, RoyaleModeSettings -> RoyaleModeSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoyaleModeSettings -> RoyaleModeSettings -> Bool
$c/= :: RoyaleModeSettings -> RoyaleModeSettings -> Bool
== :: RoyaleModeSettings -> RoyaleModeSettings -> Bool
$c== :: RoyaleModeSettings -> RoyaleModeSettings -> Bool
Eq, forall x. Rep RoyaleModeSettings x -> RoyaleModeSettings
forall x. RoyaleModeSettings -> Rep RoyaleModeSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoyaleModeSettings x -> RoyaleModeSettings
$cfrom :: forall x. RoyaleModeSettings -> Rep RoyaleModeSettings x
Generic)

instance FromJSON RoyaleModeSettings

-- | Settings used in 'squad' mode
data SquadModeSettings = SquadModeSettings
  { SquadModeSettings -> Bool
allowBodyCollisions :: Bool
  -- ^ Whether or not snakes on the same squad can collide with each other
  -- without diyng
  , SquadModeSettings -> Bool
sharedElimination :: Bool
  -- ^ Whether or not snakes on the same squad  are eliminated together
  , SquadModeSettings -> Bool
sharedHealth :: Bool
  -- ^ Whether or not snakes on the same squad share health
  , SquadModeSettings -> Bool
sharedLength :: Bool
  -- ^ Whether or not snakes on the same squad share length
  }
  deriving (Int -> SquadModeSettings -> ShowS
[SquadModeSettings] -> ShowS
SquadModeSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SquadModeSettings] -> ShowS
$cshowList :: [SquadModeSettings] -> ShowS
show :: SquadModeSettings -> String
$cshow :: SquadModeSettings -> String
showsPrec :: Int -> SquadModeSettings -> ShowS
$cshowsPrec :: Int -> SquadModeSettings -> ShowS
Show, SquadModeSettings -> SquadModeSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SquadModeSettings -> SquadModeSettings -> Bool
$c/= :: SquadModeSettings -> SquadModeSettings -> Bool
== :: SquadModeSettings -> SquadModeSettings -> Bool
$c== :: SquadModeSettings -> SquadModeSettings -> Bool
Eq, forall x. Rep SquadModeSettings x -> SquadModeSettings
forall x. SquadModeSettings -> Rep SquadModeSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SquadModeSettings x -> SquadModeSettings
$cfrom :: forall x. SquadModeSettings -> Rep SquadModeSettings x
Generic)

instance FromJSON SquadModeSettings