Skip to content

Commit

Permalink
renamed config elements for clarity of purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
harryprayiv committed Mar 13, 2024
1 parent 66713eb commit a79c21e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/ADT/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ data LgRoster = LgRoster
data DraftParameters = DraftParameters
{ autoDraft :: Bool
, autoDraft_UTC :: Text
, draft_limits :: DraftRoster
, draft_limits :: DraftRosterLimits
}
deriving (Show, Eq)

data DraftRoster = DraftRoster
data DraftRosterLimits = DraftRosterLimits
{ dr_catcher :: Int
, dr_first :: Int
, dr_second :: Int
Expand Down Expand Up @@ -194,10 +194,10 @@ instance FromJSON DraftParameters where
<*> v .: "autoDraft_UTC"
<*> v .: "draft_limits"

instance FromJSON DraftRoster where
parseJSON :: Value -> Parser DraftRoster
parseJSON = withObject "DraftRoster" $ \v ->
DraftRoster
instance FromJSON DraftRosterLimits where
parseJSON :: Value -> Parser DraftRosterLimits
parseJSON = withObject "DraftRosterLimits" $ \v ->
DraftRosterLimits
<$> v .: "catcher"
<*> v .: "first"
<*> v .: "second"
Expand Down Expand Up @@ -287,9 +287,9 @@ instance ToJSON DraftParameters where
, "draft_limits" .= draft_limits
]

instance ToJSON DraftRoster where
toJSON :: DraftRoster -> Value
toJSON DraftRoster{..} = object
instance ToJSON DraftRosterLimits where
toJSON :: DraftRosterLimits -> Value
toJSON DraftRosterLimits{..} = object
[ "catcher" .= dr_catcher
, "first" .= dr_first
, "second" .= dr_second
Expand Down
4 changes: 2 additions & 2 deletions src/League/Validators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ lookupPlayerInRoster playerId roster =
let allPlayers = concat [R.cR roster, R.b1R roster, R.b2R roster, R.b3R roster, R.ssR roster, R.ofR roster, R.uR roster, R.spR roster, R.rpR roster]
in playerId `elem` allPlayers

getRosterDiscrepancies :: R.Roster -> C.DraftRoster -> [String]
getRosterDiscrepancies :: R.Roster -> C.DraftRosterLimits -> [String]
getRosterDiscrepancies roster limits =
mapMaybe validatePosition [ ("catcher", R.cR roster, C.dr_catcher limits)
, ("first", R.b1R roster, C.dr_first limits)
Expand Down Expand Up @@ -194,7 +194,7 @@ validateRoster roster config = do
(Right duplicates, []) -> Left (map T.unpack duplicates ++ ["Duplicate player IDs found in roster."])
(_, errors) -> Left errors

lookupLimit :: T.Text -> C.DraftRoster -> Int
lookupLimit :: T.Text -> C.DraftRosterLimits -> Int
lookupLimit position limits =
case position of
"catcher" -> C.dr_catcher limits
Expand Down

0 comments on commit a79c21e

Please sign in to comment.