renamed GameState fields to prevent name collisions
This commit is contained in:
@@ -203,7 +203,7 @@ resetCreateGoalieState = progMode.createGoalieStateL
|
||||
|
||||
-- | Attempts to finish game goalie entry
|
||||
finishGameGoalieEntry :: ProgState -> ProgState
|
||||
finishGameGoalieEntry s = s & progMode.gameStateL.goaliesRecorded
|
||||
finishGameGoalieEntry s = s & progMode.gameStateL.gameGoaliesRecorded
|
||||
.~ not (null $ s^.progMode.gameStateL.gameGoalieStats)
|
||||
|
||||
-- | Awards the goal and assists to the players
|
||||
@@ -271,7 +271,7 @@ assignPMins
|
||||
-> ProgState
|
||||
-> ProgState
|
||||
assignPMins mins s = fromMaybe s $ do
|
||||
n <- s^.progMode.gameStateL.selectedPlayer
|
||||
n <- s^.progMode.gameStateL.gameSelectedPlayer
|
||||
Just $ s
|
||||
& database.dbPlayers %~ modifyNth n
|
||||
(((pYtd.psPMin) +~ mins) . ((pLifetime.psPMin) +~ mins))
|
||||
@@ -279,7 +279,7 @@ assignPMins mins s = fromMaybe s $ do
|
||||
%~ ( gamePlayerStats %~ updateMap n newPlayerStats
|
||||
(psPMin +~ mins)
|
||||
)
|
||||
. (selectedPlayer .~ Nothing)
|
||||
. (gameSelectedPlayer .~ Nothing)
|
||||
|
||||
-- | Records the goalie's game stats
|
||||
recordGoalieStats :: ProgState -> ProgState
|
||||
@@ -287,8 +287,8 @@ recordGoalieStats s = fromMaybe s $ do
|
||||
let gs = s^.progMode.gameStateL
|
||||
gid <- gs^.gameSelectedGoalie
|
||||
goalie <- nth gid $ s^.database.dbGoalies
|
||||
mins <- gs^.goalieMinsPlayed
|
||||
goals <- gs^.goalsAllowed
|
||||
mins <- gs^.gameGoalieMinsPlayed
|
||||
goals <- gs^.gameGoalsAllowed
|
||||
|
||||
let
|
||||
gameStats = M.findWithDefault newGoalieStats gid $ gs^.gameGoalieStats
|
||||
@@ -304,9 +304,9 @@ recordGoalieStats s = fromMaybe s $ do
|
||||
Just $ s
|
||||
& progMode.gameStateL
|
||||
%~ (gameGoalieStats %~ updateMap gid newGoalieStats bumpStats)
|
||||
. (gameSelectedGoalie .~ Nothing)
|
||||
. (goalieMinsPlayed .~ Nothing)
|
||||
. (goalsAllowed .~ Nothing)
|
||||
. (gameSelectedGoalie .~ Nothing)
|
||||
. (gameGoalieMinsPlayed .~ Nothing)
|
||||
. (gameGoalsAllowed .~ Nothing)
|
||||
& database.dbGoalies
|
||||
%~ modifyNth gid (\goalie -> goalie
|
||||
& gYtd %~ bumpStats
|
||||
|
||||
@@ -58,9 +58,9 @@ dispatch s = case s^.progMode of
|
||||
| null $ gs^.overtimeFlag -> overtimeFlagC
|
||||
| not $ gs^.dataVerified -> verifyDataC
|
||||
| fromJust (unaccountedPoints gs) -> goalInput gs
|
||||
| isJust $ gs^.selectedPlayer -> getPMinsC
|
||||
| not $ gs^.pMinsRecorded -> pMinPlayerC
|
||||
| not $ gs^.goaliesRecorded -> goalieInput gs
|
||||
| isJust $ gs^.gameSelectedPlayer -> getPMinsC
|
||||
| not $ gs^.gamePMinsRecorded -> pMinPlayerC
|
||||
| not $ gs^.gameGoaliesRecorded -> goalieInput gs
|
||||
| otherwise -> reportC
|
||||
CreatePlayer cps
|
||||
| null $ cps^.cpsNumber -> getPlayerNumC
|
||||
@@ -267,7 +267,7 @@ getPMinsC = Controller
|
||||
{ drawController = \s -> do
|
||||
header s
|
||||
C.drawString $ fromMaybe "" $ do
|
||||
pid <- s^.progMode.gameStateL.selectedPlayer
|
||||
pid <- s^.progMode.gameStateL.gameSelectedPlayer
|
||||
player <- nth pid $ s^.database.dbPlayers
|
||||
Just $ playerSummary player ++ "\n"
|
||||
drawPrompt assignPMinsPrompt s
|
||||
|
||||
@@ -33,9 +33,9 @@ import Mtlstats.Util
|
||||
-- | The dispatcher for handling goalie input
|
||||
goalieInput :: GameState -> Controller
|
||||
goalieInput gs
|
||||
| null $ gs^.gameSelectedGoalie = selectGoalieC
|
||||
| null $ gs^.goalieMinsPlayed = minsPlayedC
|
||||
| otherwise = goalsAllowedC
|
||||
| null $ gs^.gameSelectedGoalie = selectGoalieC
|
||||
| null $ gs^.gameGoalieMinsPlayed = minsPlayedC
|
||||
| otherwise = goalsAllowedC
|
||||
|
||||
selectGoalieC :: Controller
|
||||
selectGoalieC = Controller
|
||||
|
||||
@@ -316,8 +316,8 @@ pMinPlayerPrompt :: Prompt
|
||||
pMinPlayerPrompt = selectPlayerPrompt
|
||||
"Assign penalty minutes to: " $
|
||||
\case
|
||||
Nothing -> modify $ progMode.gameStateL.pMinsRecorded .~ True
|
||||
Just n -> modify $ progMode.gameStateL.selectedPlayer ?~ n
|
||||
Nothing -> modify $ progMode.gameStateL.gamePMinsRecorded .~ True
|
||||
Just n -> modify $ progMode.gameStateL.gameSelectedPlayer ?~ n
|
||||
|
||||
-- | Prompts for the number of penalty mintues to assign to the player
|
||||
assignPMinsPrompt :: Prompt
|
||||
@@ -344,15 +344,15 @@ selectGameGoaliePrompt = selectGoaliePrompt "Which goalie played this game: " $
|
||||
-- | Prompts for the number of minutes the goalie has played
|
||||
goalieMinsPlayedPrompt :: Prompt
|
||||
goalieMinsPlayedPrompt = numPrompt "Minutes played: " $
|
||||
modify . (progMode.gameStateL.goalieMinsPlayed ?~)
|
||||
modify . (progMode.gameStateL.gameGoalieMinsPlayed ?~)
|
||||
|
||||
-- | Prompts for the number of goals the goalie allowed
|
||||
goalsAllowedPrompt :: Prompt
|
||||
goalsAllowedPrompt = numPrompt "Goals allowed: " $ \n -> do
|
||||
modify (progMode.gameStateL.goalsAllowed ?~ n)
|
||||
mins <- fromMaybe 0 <$> gets (^.progMode.gameStateL.goalieMinsPlayed)
|
||||
modify (progMode.gameStateL.gameGoalsAllowed ?~ n)
|
||||
mins <- fromMaybe 0 <$> gets (^.progMode.gameStateL.gameGoalieMinsPlayed)
|
||||
when (mins >= gameLength) $
|
||||
modify $ progMode.gameStateL.goaliesRecorded .~ True
|
||||
modify $ progMode.gameStateL.gameGoaliesRecorded .~ True
|
||||
modify recordGoalieStats
|
||||
|
||||
playerToEditPrompt :: Prompt
|
||||
|
||||
+38
-38
@@ -67,13 +67,13 @@ module Mtlstats.Types (
|
||||
assistsBy,
|
||||
gamePlayerStats,
|
||||
confirmGoalDataFlag,
|
||||
selectedPlayer,
|
||||
pMinsRecorded,
|
||||
gameSelectedPlayer,
|
||||
gamePMinsRecorded,
|
||||
gameGoalieStats,
|
||||
gameSelectedGoalie,
|
||||
goalieMinsPlayed,
|
||||
goalsAllowed,
|
||||
goaliesRecorded,
|
||||
gameGoalieMinsPlayed,
|
||||
gameGoalsAllowed,
|
||||
gameGoaliesRecorded,
|
||||
gameGoalieAssigned,
|
||||
-- ** CreatePlayerState Lenses
|
||||
cpsNumber,
|
||||
@@ -252,30 +252,30 @@ data GameState = GameState
|
||||
, _goalBy :: Maybe Int
|
||||
-- ^ The index number of the player who scored the most recently
|
||||
-- entered goal
|
||||
, _assistsBy :: [Int]
|
||||
, _assistsBy :: [Int]
|
||||
-- ^ The index numbers of the players who have assisted the most
|
||||
-- recently entered goal
|
||||
, _gamePlayerStats :: M.Map Int PlayerStats
|
||||
, _gamePlayerStats :: M.Map Int PlayerStats
|
||||
-- ^ The player stats accumulated over the game
|
||||
, _confirmGoalDataFlag :: Bool
|
||||
, _confirmGoalDataFlag :: Bool
|
||||
-- ^ Set when the user confirms the goal data
|
||||
, _selectedPlayer :: Maybe Int
|
||||
, _gameSelectedPlayer :: Maybe Int
|
||||
-- ^ Index number of the selected 'Player'
|
||||
, _pMinsRecorded :: Bool
|
||||
, _gamePMinsRecorded :: Bool
|
||||
-- ^ Set when the penalty mintes have been recorded
|
||||
, _gameGoalieStats :: M.Map Int GoalieStats
|
||||
, _gameGoalieStats :: M.Map Int GoalieStats
|
||||
-- ^ The goalie stats accumulated over the game
|
||||
, _gameSelectedGoalie :: Maybe Int
|
||||
, _gameSelectedGoalie :: Maybe Int
|
||||
-- ^ Index number of the selected 'Goalie'
|
||||
, _goalieMinsPlayed :: Maybe Int
|
||||
, _gameGoalieMinsPlayed :: Maybe Int
|
||||
-- ^ The number of minutes the currently selected goalie played in
|
||||
-- the game
|
||||
, _goalsAllowed :: Maybe Int
|
||||
, _gameGoalsAllowed :: Maybe Int
|
||||
-- ^ The number of goals the currently selected goalie allowed in
|
||||
-- the game
|
||||
, _goaliesRecorded :: Bool
|
||||
, _gameGoaliesRecorded :: Bool
|
||||
-- ^ Set when the user confirms that all goalie info has been entered
|
||||
, _gameGoalieAssigned :: Bool
|
||||
, _gameGoalieAssigned :: Bool
|
||||
-- ^ Set to 'True' when the goalie has been selected who will be
|
||||
-- given the win/loss/tie
|
||||
} deriving (Eq, Show)
|
||||
@@ -628,28 +628,28 @@ newProgState = ProgState
|
||||
-- | Constructor for a 'GameState'
|
||||
newGameState :: GameState
|
||||
newGameState = GameState
|
||||
{ _gameYear = Nothing
|
||||
, _gameMonth = Nothing
|
||||
, _gameDay = Nothing
|
||||
, _gameType = Nothing
|
||||
, _otherTeam = ""
|
||||
, _homeScore = Nothing
|
||||
, _awayScore = Nothing
|
||||
, _overtimeFlag = Nothing
|
||||
, _dataVerified = False
|
||||
, _pointsAccounted = 0
|
||||
, _goalBy = Nothing
|
||||
, _assistsBy = []
|
||||
, _gamePlayerStats = M.empty
|
||||
, _confirmGoalDataFlag = False
|
||||
, _selectedPlayer = Nothing
|
||||
, _pMinsRecorded = False
|
||||
, _gameGoalieStats = M.empty
|
||||
, _gameSelectedGoalie = Nothing
|
||||
, _goalieMinsPlayed = Nothing
|
||||
, _goalsAllowed = Nothing
|
||||
, _goaliesRecorded = False
|
||||
, _gameGoalieAssigned = False
|
||||
{ _gameYear = Nothing
|
||||
, _gameMonth = Nothing
|
||||
, _gameDay = Nothing
|
||||
, _gameType = Nothing
|
||||
, _otherTeam = ""
|
||||
, _homeScore = Nothing
|
||||
, _awayScore = Nothing
|
||||
, _overtimeFlag = Nothing
|
||||
, _dataVerified = False
|
||||
, _pointsAccounted = 0
|
||||
, _goalBy = Nothing
|
||||
, _assistsBy = []
|
||||
, _gamePlayerStats = M.empty
|
||||
, _confirmGoalDataFlag = False
|
||||
, _gameSelectedPlayer = Nothing
|
||||
, _gamePMinsRecorded = False
|
||||
, _gameGoalieStats = M.empty
|
||||
, _gameSelectedGoalie = Nothing
|
||||
, _gameGoalieMinsPlayed = Nothing
|
||||
, _gameGoalsAllowed = Nothing
|
||||
, _gameGoaliesRecorded = False
|
||||
, _gameGoalieAssigned = False
|
||||
}
|
||||
|
||||
-- | Constructor for a 'CreatePlayerState'
|
||||
|
||||
Reference in New Issue
Block a user