From 980cd96a41b8b030f849e9d31d18988e6260b3a7 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 3 Nov 2022 22:43:21 -0400 Subject: further toward implementation of accessory lifts --- repgoal.hs | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/repgoal.hs b/repgoal.hs index 7a019db..2f76432 100755 --- a/repgoal.hs +++ b/repgoal.hs @@ -173,6 +173,30 @@ annotatePosition (x:xs) = (FirstInList, x) : map (NotFirstInList,) xs lookup' :: Int -> NESeq a -> a lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq +wendlerLiftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]] +wendlerLiftRows week lift = filter (not . null) $ (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow lift +wendlerLiftRow :: (Lift, Maybe LiftRecord) -> (ListPosition, SetScheme) -> [Widget n] +wendlerLiftRow (_, Nothing) _ = [] +wendlerLiftRow (_, Just LiftRecord{..}) (position, (SetScheme targetRatio targetReps amrap)) = + let best = bestPerformance stats + computedTarget = targetRatio * (90 % 100) * computeOneRepMax best + targetWeight = ceilingN 5 computedTarget + repGoal = computeRepGoal targetWeight stats + goalTo1RM g = computeOneRepMax $ Achieved g targetWeight + showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g)) + pad = padBottom (Pad $ if amrap then 1 else 0) + in + map (padLeftRight 2) + [ + pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ", + pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight, + pad $ str $ showPlates targetWeight, + str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ", + pad $ txt " ", + pad $ txt " " + ] + + drawUI :: St -> [Widget ()] drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] where @@ -185,7 +209,7 @@ drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrol 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 + lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (wendlerLiftRows (view week st)) lifts' header = renderTable $ table $ map (padLeftRight 1 . txt) ["Date", "Time", "Bodyweight", "Week", "Session"] : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName session] ] @@ -200,27 +224,6 @@ drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrol str $ printf "%d @ %d" achievedReps achievedWeight, str $ showRational $ computeOneRepMax best ] - toLiftRows :: WeekSelection -> LiftRecord -> [[Widget n]] - toLiftRows week lift = (flip map) (annotatePosition $ liftScheme Fresher week) $ toLiftRow lift - toLiftRow :: LiftRecord -> (ListPosition, SetScheme) -> [Widget n] - toLiftRow LiftRecord{..} (position, (SetScheme targetRatio targetReps amrap)) = - let best = bestPerformance stats - computedTarget = targetRatio * (90 % 100) * computeOneRepMax best - targetWeight = ceilingN 5 computedTarget - repGoal = computeRepGoal targetWeight stats - goalTo1RM g = computeOneRepMax $ Achieved g targetWeight - showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g)) - pad = padBottom (Pad $ if amrap then 1 else 0) - in - map (padLeftRight 2) - [ - pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ", - pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight, - pad $ str $ showPlates targetWeight, - str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ", - pad $ txt " ", - pad $ txt " " - ] showPlates :: Integer -> String showPlates (fromIntegral -> wt) = fromMaybe " " $ fmap (ourShow . reverse) $ showPlates' (wt - 45) ourPlates [] -- cgit v1.2.3