use player creation callbacks
This commit is contained in:
parent
6dd9350189
commit
6ceb5415c5
|
@ -34,6 +34,7 @@ module Mtlstats.Actions
|
|||
, addPlayer
|
||||
) where
|
||||
|
||||
import Control.Monad.Trans.State (modify)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Time.Calendar (fromGregorianValid)
|
||||
import Lens.Micro (over, (^.), (&), (.~), (?~), (%~), (+~))
|
||||
|
@ -116,7 +117,13 @@ validateGameDate s = fromMaybe s $ do
|
|||
|
||||
-- | Starts player creation mode
|
||||
createPlayer :: ProgState -> ProgState
|
||||
createPlayer = progMode .~ CreatePlayer newCreatePlayerState
|
||||
createPlayer = let
|
||||
cb = modify $ progMode .~ MainMenu
|
||||
cps
|
||||
= newCreatePlayerState
|
||||
& cpsSuccessCallback .~ cb
|
||||
& cpsFailureCallback .~ cb
|
||||
in progMode .~ CreatePlayer cps
|
||||
|
||||
-- | Adds the entered player to the roster
|
||||
addPlayer :: ProgState -> ProgState
|
||||
|
|
|
@ -21,11 +21,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
module Mtlstats.Control (dispatch) where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Control.Monad.Trans.State (modify)
|
||||
import Control.Monad (join, when)
|
||||
import Control.Monad.Trans.State (gets, modify)
|
||||
import Data.Char (toUpper)
|
||||
import Data.Maybe (fromJust)
|
||||
import Lens.Micro ((^.), (.~))
|
||||
import Lens.Micro.Extras (view)
|
||||
import qualified UI.NCurses as C
|
||||
|
||||
import Mtlstats.Actions
|
||||
|
@ -237,8 +238,8 @@ confirmCreatePlayerC = Controller
|
|||
case ynHandler e of
|
||||
Just True -> do
|
||||
modify addPlayer
|
||||
modify $ progMode .~ MainMenu
|
||||
Just False -> modify $ progMode .~ MainMenu
|
||||
join $ gets (view $ progMode.createPlayerStateL.cpsSuccessCallback)
|
||||
Just False -> join $ gets (view $ progMode.createPlayerStateL.cpsFailureCallback)
|
||||
Nothing -> return ()
|
||||
return True
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user