implemented recordGoalPrompt
This commit is contained in:
parent
b125e72034
commit
e80b7ec48c
|
@ -37,18 +37,20 @@ module Mtlstats.Prompt (
|
|||
playerNamePrompt,
|
||||
playerPosPrompt,
|
||||
selectPlayerPrompt,
|
||||
recordGoalPrompt,
|
||||
) where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Control.Monad.Trans.State (gets, modify)
|
||||
import Data.Char (isDigit, toUpper)
|
||||
import Data.Foldable (forM_)
|
||||
import Lens.Micro ((^.), (&), (.~), (?~))
|
||||
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
||||
import Lens.Micro.Extras (view)
|
||||
import Text.Read (readMaybe)
|
||||
import qualified UI.NCurses as C
|
||||
|
||||
import Mtlstats.Actions
|
||||
import Mtlstats.Format
|
||||
import Mtlstats.Types
|
||||
import Mtlstats.Util
|
||||
|
||||
|
@ -193,5 +195,21 @@ selectPlayerPrompt pStr callback = Prompt
|
|||
_ -> return ()
|
||||
}
|
||||
|
||||
-- | Prompts for the player who scored the goal
|
||||
recordGoalPrompt
|
||||
:: Int
|
||||
-- ^ The game number
|
||||
-> Int
|
||||
-- ^ The goal number
|
||||
-> Prompt
|
||||
recordGoalPrompt game goal = selectPlayerPrompt
|
||||
("*** GAME " ++ padNum 2 game ++ " ***\n" ++
|
||||
"Who scored goal number " ++ show goal ++ "? ") $
|
||||
\case
|
||||
Nothing -> return ()
|
||||
Just n -> modify
|
||||
$ awardGoal n
|
||||
. (progMode.gameStateL.pointsAccounted %~ succ)
|
||||
|
||||
drawSimplePrompt :: String -> ProgState -> C.Update ()
|
||||
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer
|
||||
|
|
Loading…
Reference in New Issue
Block a user