From 647ec16b358bf4383369619065e57ef605c11f54 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 14 Oct 2022 16:34:48 -0400 Subject: calculate final sets for all 3 weeks & corresponding goal reps --- repgoal.hs | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/repgoal.hs b/repgoal.hs index dcd956f..83ba9d6 100755 --- a/repgoal.hs +++ b/repgoal.hs @@ -102,25 +102,52 @@ showRational n = printf format $ (realToFrac :: Rational -> Float) $ n format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f" drawUI :: St -> [Widget ()] -drawUI (St lifts) = [a] +drawUI (St lifts) = [vCenter $ vBox [hCenter oneRepMaxTable, hCenter lastSetTable]] where - a = vCenter $ hCenter $ renderTable $ table $ - map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow lifts - toRow target@LiftTarget{..} = + lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Week", "Last Set", "Goal", "Goal+1"] : concatMap toWeekRows lifts + oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts + toRow LiftTarget{..} = let best@Achieved{..} = bestPerformance stats + in + map (padLeftRight 2) + [ + txt $ liftName, + str $ printf "%d @ %s" achievedReps (showRational achievedWeight), + str $ showRational $ computeOneRepMax best + ] + toWeekRows lift = (flip map) [1,2,3::Int] $ \week -> toWeekRow week lift + toWeekRow :: Int -> LiftTarget -> [Widget n] + toWeekRow week target@LiftTarget{..} = + let best = bestPerformance stats + programWeight = (* (percentage week)) $ (* (90 % 100)) $ computeOneRepMax best repGoal = computeRepGoal target goalTo1RM g = computeOneRepMax $ Achieved g targetWeight showGoal g = printf "%d @ %s ≈ 1 @ %s" g (showRational targetWeight) (showRational (goalTo1RM g)) in map (padLeftRight 2) [ - txt $ liftName, - str $ printf "%d @ %s" achievedReps (showRational achievedWeight), - str $ showRational $ computeOneRepMax best, + txt $ (if week == 1 then liftName else " "), + str $ show week, + str $ printf "%d @ %d" (targetReps week) (ceilingN 5 programWeight), + -- str $ showRational $ (* (percentage week)) $ (* (90 % 100)) $ computeOneRepMax best, str $ showGoal repGoal, str $ showGoal (repGoal + 1) ] + targetReps :: Int -> Int + targetReps 1 = 5 + targetReps 2 = 3 + targetReps 3 = 1 + targetReps _ = undefined + + percentage 1 = 85 % 100 + percentage 2 = 90 % 100 + percentage 3 = 95 % 100 + percentage _ = undefined + +ceilingN :: Integer -> Rational -> Integer +ceilingN n x = ceiling (x / toRational n) * n + -- TODO: State contains chosen repmax formula -- TODO: State contains performances data St = St { -- cgit v1.2.3