implemented confirmGoalDataC
This commit is contained in:
parent
66148a25d8
commit
2be7d2bf1d
|
@ -35,6 +35,7 @@ module Mtlstats.Actions
|
|||
, recordGoalAssists
|
||||
, awardGoal
|
||||
, awardAssist
|
||||
, resetGoalData
|
||||
) where
|
||||
|
||||
import Control.Monad.Trans.State (modify)
|
||||
|
@ -195,3 +196,7 @@ awardAssist n ps = ps
|
|||
& pYtd.psAssists %~ succ
|
||||
& pLifetime.psAssists %~ succ
|
||||
else p) . zip [0..]
|
||||
|
||||
-- | Resets the entered data for the current goal
|
||||
resetGoalData :: ProgState -> ProgState
|
||||
resetGoalData = undefined
|
||||
|
|
|
@ -36,6 +36,7 @@ import Mtlstats.Menu
|
|||
import Mtlstats.Prompt
|
||||
import Mtlstats.Report
|
||||
import Mtlstats.Types
|
||||
import Mtlstats.Util
|
||||
|
||||
-- | Reads the program state and returs the apropriate controller to
|
||||
-- run
|
||||
|
@ -185,7 +186,8 @@ verifyDataC = Controller
|
|||
goalInput :: GameState -> Controller
|
||||
goalInput gs
|
||||
| null (gs^.goalBy ) = recordGoalC
|
||||
| otherwise = recordAssistC
|
||||
| not (gs^.confirmGoalDataFlag) = recordAssistC
|
||||
| otherwise = confirmGoalDataC
|
||||
|
||||
recordGoalC :: Controller
|
||||
recordGoalC = Controller
|
||||
|
@ -209,6 +211,34 @@ recordAssistC = Controller
|
|||
return True
|
||||
}
|
||||
|
||||
confirmGoalDataC :: Controller
|
||||
confirmGoalDataC = Controller
|
||||
{ drawController = \s -> do
|
||||
let
|
||||
(game, goal) = gameGoal s
|
||||
gs = s^.progMode.gameStateL
|
||||
players = s^.database.dbPlayers
|
||||
msg = unlines $
|
||||
[ " Game: " ++ padNum 2 game
|
||||
, " Goal: " ++ show goal
|
||||
, "Goal scored by: " ++
|
||||
playerSummary (fromJust $ gs^.goalBy >>= flip nth players)
|
||||
] ++
|
||||
map
|
||||
(\pid -> " Assisted by: " ++
|
||||
playerSummary (fromJust $ nth pid players))
|
||||
(gs^.assistsBy) ++
|
||||
[ "Is the above information correct? (Y/N)" ]
|
||||
C.drawString msg
|
||||
return C.CursorInvisible
|
||||
, handleController = \e -> do
|
||||
case ynHandler e of
|
||||
Just True -> modify recordGoalAssists
|
||||
Just False -> modify resetGoalData
|
||||
Nothing -> return ()
|
||||
return True
|
||||
}
|
||||
|
||||
reportC :: Controller
|
||||
reportC = Controller
|
||||
{ drawController = \s -> do
|
||||
|
|
|
@ -128,7 +128,8 @@ module Mtlstats.Types (
|
|||
pPoints,
|
||||
playerSearch,
|
||||
playerSearchExact,
|
||||
modifyPlayer
|
||||
modifyPlayer,
|
||||
playerSummary
|
||||
) where
|
||||
|
||||
import Control.Monad.Trans.State (StateT)
|
||||
|
@ -713,3 +714,7 @@ modifyPlayer f n = map
|
|||
(\p -> if p^.pName == n
|
||||
then f p
|
||||
else p)
|
||||
|
||||
-- | Provides a short summary string for a player
|
||||
playerSummary :: Player -> String
|
||||
playerSummary = undefined
|
||||
|
|
Loading…
Reference in New Issue
Block a user