From 8ededa8f0024179c7314989ccef1b5b8c5f0577b Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 3 Nov 2022 20:26:10 -0400 Subject: begin implementation of accessory lifts --- repgoal.hs | 61 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/repgoal.hs b/repgoal.hs index 5a4e6e4..a31b189 100755 --- a/repgoal.hs +++ b/repgoal.hs @@ -118,12 +118,24 @@ showRational n = printf format $ (realToFrac :: Rational -> Float) $ n data WeekSelection = Week1 | Week2 | Week3 deriving (Enum, Bounded, Show, Eq) +data Programming = Wendler | Accessory Int Int | Unspecified + +data Lift = Lift { + liftName :: Text, + liftProgramming :: Programming +} + +data Session = Session { + sessionName :: Text, + sessionLifts :: NESeq Lift +} + -- TODO: State contains chosen repmax formula -- TODO: State contains performances data St = St { _lifts :: [LiftRecord], _week :: WeekSelection, - _sessions :: NESeq (Set Text), + _sessions :: NESeq (Session), _selectedSession :: Int } makeLenses ''St @@ -164,14 +176,21 @@ lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq drawUI :: St -> [Widget ()] drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] where - lifts' = filter ((flip Set.member $ view sessions st & lookup' (view selectedSession st)) . liftRecordName) (view lifts st) - lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) lifts' + session :: Session + session = view sessions st & lookup' (view selectedSession st) + sameName a b = liftName a == liftRecordName b + lifts' :: [(Lift, Maybe LiftRecord)] + lifts' = session & sessionLifts & toList & map (\lift -> (lift, find (sameName lift) $ view lifts st)) + liftNames :: [Text] + liftNames = session & sessionLifts & fmap liftName & toList + liftRecords :: [LiftRecord] + liftRecords = filter ((`elem` liftNames) . liftRecordName) (view lifts st) + lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) liftRecords header = renderTable $ table $ map (padLeftRight 1 . txt) ["Date", "Time", "Bodyweight", "Week", "Session"] - : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName] ] + : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName session] ] weekNumber = case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3" - sessionName = liftRecordName $ head lifts' - oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts' + oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow liftRecords toRow LiftRecord{..} = let best@Achieved{..} = bestPerformance stats in @@ -270,14 +289,26 @@ powerClean = clean * 80 / 100 pushPress = press * 100 / 75 jerk = pushPress / 100 * 85 -routine :: NESeq (Set Text) -routine = - Set.fromList ["Deadlift", "Press"] :<|| - Seq.fromList - [ Set.fromList ["Front Squat"] - , Set.fromList ["Left-Arm Snatch", "Right-Arm Snatch"] - , Set.fromList ["Squat", "Bench"] - , Set.fromList ["Push Press", "Power Clean"] +program :: NESeq Session +program = + Session "Deadlift" (Lift "Deadlift" Wendler :<|| Seq.fromList [ + Lift "Press" Wendler, + Lift "Row" $ Accessory 5 10, + Lift "Dip" $ Accessory 5 2, + Lift "Good Morning" $ Accessory 3 10]) + :<|| + Seq.fromList [ + Session "Front Squat" (Lift "Front Squat" Wendler :<|| Seq.fromList + [Lift "Naked Bar Warmup" Unspecified, + Lift "Left-Arm Snatch" Unspecified, + Lift "Right-Arm Snatch" Unspecified]) , + Session "Squat" (Lift "Squat" Wendler :<|| Seq.fromList [ + Lift "Bench" Wendler, + Lift "Row" $ Accessory 5 10, + Lift "Back Raise" $ Accessory 3 15, + Lift "DB Bench" $ Accessory 3 10, + Lift "Rear Lateral" $ Accessory 3 20]), + Session "Power Clean" (Lift "Power Clean" Wendler :<|| Seq.fromList [Lift "Push Press" Wendler]) ] main :: IO () @@ -287,4 +318,4 @@ main = do -- liftIO $ setMode (outputIface vty) Mouse True chan <- newBChan 10 initial <- read <$> readFile "lifts.dat" :: IO [LiftRecord] - void $ customMain vty buildVty (Just chan) (theApp) (St initial Week1 routine 0) + void $ customMain vty buildVty (Just chan) (theApp) (St initial Week1 program 0) -- cgit v1.2.3