From 83c408cea2ec7cd1c1c23b96d39760cfb9d4c26f Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 16 Jan 2020 21:34:19 -0500 Subject: [PATCH] implemented editing prompts --- src/Mtlstats/Prompt/EditStandings.hs | 44 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/Mtlstats/Prompt/EditStandings.hs b/src/Mtlstats/Prompt/EditStandings.hs index 2aeced0..94b74fc 100644 --- a/src/Mtlstats/Prompt/EditStandings.hs +++ b/src/Mtlstats/Prompt/EditStandings.hs @@ -32,34 +32,58 @@ module Mtlstats.Prompt.EditStandings , editAwayGoalsAgainstPrompt ) where +import Control.Monad.Trans.State (modify) +import Lens.Micro ((.~), (%~)) + +import Mtlstats.Prompt import Mtlstats.Types editHomeWinsPrompt :: Prompt -editHomeWinsPrompt = undefined +editHomeWinsPrompt = + mkPrompt "Home wins: " (dbHomeGameStats.gmsWins .~) editHomeLossesPrompt :: Prompt -editHomeLossesPrompt = undefined +editHomeLossesPrompt = + mkPrompt "Home losses: " (dbHomeGameStats.gmsLosses .~) editHomeOvertimePrompt :: Prompt -editHomeOvertimePrompt = undefined +editHomeOvertimePrompt = + mkPrompt "Home overtime games: " (dbHomeGameStats.gmsOvertime .~) editHomeGoalsForPrompt :: Prompt -editHomeGoalsForPrompt = undefined +editHomeGoalsForPrompt = + mkPrompt "Home goals for: " (dbHomeGameStats.gmsGoalsFor .~) editHomeGoalsAgainstPrompt :: Prompt -editHomeGoalsAgainstPrompt = undefined +editHomeGoalsAgainstPrompt = + mkPrompt "Home goals against: " (dbHomeGameStats.gmsGoalsAgainst .~) editAwayWinsPrompt :: Prompt -editAwayWinsPrompt = undefined +editAwayWinsPrompt = + mkPrompt "Road wins: " (dbAwayGameStats.gmsWins .~) editAwayLossesPrompt :: Prompt -editAwayLossesPrompt = undefined +editAwayLossesPrompt = + mkPrompt "Road losses: " (dbAwayGameStats.gmsLosses .~) editAwayOvertimePrompt :: Prompt -editAwayOvertimePrompt = undefined +editAwayOvertimePrompt = + mkPrompt "Road overtime games: " (dbAwayGameStats.gmsOvertime .~) editAwayGoalsForPrompt :: Prompt -editAwayGoalsForPrompt = undefined +editAwayGoalsForPrompt = + mkPrompt "Road goals for: " (dbAwayGameStats.gmsGoalsFor .~) editAwayGoalsAgainstPrompt :: Prompt -editAwayGoalsAgainstPrompt = undefined +editAwayGoalsAgainstPrompt = + mkPrompt "Road goals against: " (dbAwayGameStats.gmsGoalsAgainst .~) + +mkPrompt :: String -> (Int -> Database -> Database) -> Prompt +mkPrompt pStr f = numPromptWithFallback pStr + (modify subMenu) + (\n -> modify + $ (database %~ f n) + . subMenu) + +subMenu :: ProgState -> ProgState +subMenu = progMode.editStandingsModeL.esmSubModeL .~ ESMSubMenu