refactored Mtlstats.Control.EditPlayer

This commit is contained in:
Jonathan Lamothe 2019-11-16 11:36:13 -05:00
parent 0efac07a33
commit e8b850c23a

View File

@ -50,51 +50,19 @@ editPlayerC eps
EPLtPMin -> ltPMinC EPLtPMin -> ltPMinC
selectPlayerC :: Controller selectPlayerC :: Controller
selectPlayerC = Controller selectPlayerC = promptController playerToEditPrompt
{ drawController = drawPrompt playerToEditPrompt
, handleController = \e -> do
promptHandler playerToEditPrompt e
return True
}
menuC :: Controller menuC :: Controller
menuC = Controller menuC = menuControllerWith header editPlayerMenu
{ drawController = \s -> do
let
header = fromMaybe "" $ do
pid <- s^.progMode.editPlayerStateL.epsSelectedPlayer
p <- nth pid $ s^.database.dbPlayers
Just $ playerDetails p ++ "\n"
C.drawString header
drawMenu editPlayerMenu
, handleController = \e -> do
menuHandler editPlayerMenu e
return True
}
numberC :: Controller numberC :: Controller
numberC = Controller numberC = promptController editPlayerNumPrompt
{ drawController = drawPrompt editPlayerNumPrompt
, handleController = \e -> do
promptHandler editPlayerNumPrompt e
return True
}
nameC :: Controller nameC :: Controller
nameC = Controller nameC = promptController editPlayerNamePrompt
{ drawController = drawPrompt editPlayerNamePrompt
, handleController = \e -> do
promptHandler editPlayerNamePrompt e
return True
}
positionC :: Controller positionC :: Controller
positionC = Controller positionC = promptController editPlayerPosPrompt
{ drawController = drawPrompt editPlayerPosPrompt
, handleController = \e -> do
promptHandler editPlayerPosPrompt e
return True
}
ytdC :: Controller ytdC :: Controller
ytdC = undefined ytdC = undefined
@ -103,49 +71,25 @@ lifetimeC :: Controller
lifetimeC = undefined lifetimeC = undefined
ytdGoalsC :: Controller ytdGoalsC :: Controller
ytdGoalsC = Controller ytdGoalsC = promptController editPlayerYtdGoalsPrompt
{ drawController = drawPrompt editPlayerYtdGoalsPrompt
, handleController = \e -> do
promptHandler editPlayerYtdGoalsPrompt e
return True
}
ytdAssistsC :: Controller ytdAssistsC :: Controller
ytdAssistsC = Controller ytdAssistsC = promptController editPlayerYtdAssistsPrompt
{ drawController = drawPrompt editPlayerYtdAssistsPrompt
, handleController = \e -> do
promptHandler editPlayerYtdAssistsPrompt e
return True
}
ytdPMinC :: Controller ytdPMinC :: Controller
ytdPMinC = Controller ytdPMinC = promptController editPlayerYtdPMinPrompt
{ drawController = drawPrompt editPlayerYtdPMinPrompt
, handleController = \e -> do
promptHandler editPlayerYtdPMinPrompt e
return True
}
ltGoalsC :: Controller ltGoalsC :: Controller
ltGoalsC = Controller ltGoalsC = promptController editPlayerLtGoalsPrompt
{ drawController = drawPrompt editPlayerLtGoalsPrompt
, handleController = \e -> do
promptHandler editPlayerLtGoalsPrompt e
return True
}
ltAssistsC :: Controller ltAssistsC :: Controller
ltAssistsC = Controller ltAssistsC = promptController editPlayerLtAssistsPrompt
{ drawController = drawPrompt editPlayerLtAssistsPrompt
, handleController = \e -> do
promptHandler editPlayerLtAssistsPrompt e
return True
}
ltPMinC :: Controller ltPMinC :: Controller
ltPMinC = Controller ltPMinC = promptController editPlayerLtPMinPrompt
{ drawController = drawPrompt editPlayerLtPMinPrompt
, handleController = \e -> do header :: ProgState -> C.Update ()
promptHandler editPlayerLtPMinPrompt e header s = C.drawString $ fromMaybe "" $ do
return True pid <- s^.progMode.editPlayerStateL.epsSelectedPlayer
} player <- nth pid $ s^.database.dbPlayers
Just $ playerDetails player