implemented confirmGoalDataC
This commit is contained in:
parent
66148a25d8
commit
2be7d2bf1d
|
@ -35,6 +35,7 @@ module Mtlstats.Actions
|
||||||
, recordGoalAssists
|
, recordGoalAssists
|
||||||
, awardGoal
|
, awardGoal
|
||||||
, awardAssist
|
, awardAssist
|
||||||
|
, resetGoalData
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (modify)
|
import Control.Monad.Trans.State (modify)
|
||||||
|
@ -195,3 +196,7 @@ awardAssist n ps = ps
|
||||||
& pYtd.psAssists %~ succ
|
& pYtd.psAssists %~ succ
|
||||||
& pLifetime.psAssists %~ succ
|
& pLifetime.psAssists %~ succ
|
||||||
else p) . zip [0..]
|
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.Prompt
|
||||||
import Mtlstats.Report
|
import Mtlstats.Report
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
import Mtlstats.Util
|
||||||
|
|
||||||
-- | Reads the program state and returs the apropriate controller to
|
-- | Reads the program state and returs the apropriate controller to
|
||||||
-- run
|
-- run
|
||||||
|
@ -184,8 +185,9 @@ verifyDataC = Controller
|
||||||
|
|
||||||
goalInput :: GameState -> Controller
|
goalInput :: GameState -> Controller
|
||||||
goalInput gs
|
goalInput gs
|
||||||
| null (gs^.goalBy) = recordGoalC
|
| null (gs^.goalBy ) = recordGoalC
|
||||||
| otherwise = recordAssistC
|
| not (gs^.confirmGoalDataFlag) = recordAssistC
|
||||||
|
| otherwise = confirmGoalDataC
|
||||||
|
|
||||||
recordGoalC :: Controller
|
recordGoalC :: Controller
|
||||||
recordGoalC = Controller
|
recordGoalC = Controller
|
||||||
|
@ -209,6 +211,34 @@ recordAssistC = Controller
|
||||||
return True
|
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
|
||||||
reportC = Controller
|
reportC = Controller
|
||||||
{ drawController = \s -> do
|
{ drawController = \s -> do
|
||||||
|
|
|
@ -128,7 +128,8 @@ module Mtlstats.Types (
|
||||||
pPoints,
|
pPoints,
|
||||||
playerSearch,
|
playerSearch,
|
||||||
playerSearchExact,
|
playerSearchExact,
|
||||||
modifyPlayer
|
modifyPlayer,
|
||||||
|
playerSummary
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (StateT)
|
import Control.Monad.Trans.State (StateT)
|
||||||
|
@ -713,3 +714,7 @@ modifyPlayer f n = map
|
||||||
(\p -> if p^.pName == n
|
(\p -> if p^.pName == n
|
||||||
then f p
|
then f p
|
||||||
else p)
|
else p)
|
||||||
|
|
||||||
|
-- | Provides a short summary string for a player
|
||||||
|
playerSummary :: Player -> String
|
||||||
|
playerSummary = undefined
|
||||||
|
|
Loading…
Reference in New Issue
Block a user