summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-10-14 16:34:48 -0400
committerAndrew Cady <d@jerkface.net>2022-10-14 16:34:48 -0400
commit647ec16b358bf4383369619065e57ef605c11f54 (patch)
tree2ad44bc18e8b695674b23198d456bf24f8ca26c2
parentf560f21f27c5c2f9fe219ecd6e53939cc6559358 (diff)
calculate final sets for all 3 weeks & corresponding goal reps
-rwxr-xr-xrepgoal.hs41
1 files 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
102 format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f" 102 format = if floor (n * 10) `mod` 10 == (0 :: Integer) then "%.0f" else "%.2f"
103 103
104drawUI :: St -> [Widget ()] 104drawUI :: St -> [Widget ()]
105drawUI (St lifts) = [a] 105drawUI (St lifts) = [vCenter $ vBox [hCenter oneRepMaxTable, hCenter lastSetTable]]
106 where 106 where
107 a = vCenter $ hCenter $ renderTable $ table $ 107 lastSetTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Week", "Last Set", "Goal", "Goal+1"] : concatMap toWeekRows lifts
108 map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow lifts 108 oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts
109 toRow target@LiftTarget{..} = 109 toRow LiftTarget{..} =
110 let best@Achieved{..} = bestPerformance stats 110 let best@Achieved{..} = bestPerformance stats
111 in
112 map (padLeftRight 2)
113 [
114 txt $ liftName,
115 str $ printf "%d @ %s" achievedReps (showRational achievedWeight),
116 str $ showRational $ computeOneRepMax best
117 ]
118 toWeekRows lift = (flip map) [1,2,3::Int] $ \week -> toWeekRow week lift
119 toWeekRow :: Int -> LiftTarget -> [Widget n]
120 toWeekRow week target@LiftTarget{..} =
121 let best = bestPerformance stats
122 programWeight = (* (percentage week)) $ (* (90 % 100)) $ computeOneRepMax best
111 repGoal = computeRepGoal target 123 repGoal = computeRepGoal target
112 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight 124 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight
113 showGoal g = printf "%d @ %s ≈ 1 @ %s" g (showRational targetWeight) (showRational (goalTo1RM g)) 125 showGoal g = printf "%d @ %s ≈ 1 @ %s" g (showRational targetWeight) (showRational (goalTo1RM g))
114 in 126 in
115 map (padLeftRight 2) 127 map (padLeftRight 2)
116 [ 128 [
117 txt $ liftName, 129 txt $ (if week == 1 then liftName else " "),
118 str $ printf "%d @ %s" achievedReps (showRational achievedWeight), 130 str $ show week,
119 str $ showRational $ computeOneRepMax best, 131 str $ printf "%d @ %d" (targetReps week) (ceilingN 5 programWeight),
132 -- str $ showRational $ (* (percentage week)) $ (* (90 % 100)) $ computeOneRepMax best,
120 str $ showGoal repGoal, 133 str $ showGoal repGoal,
121 str $ showGoal (repGoal + 1) 134 str $ showGoal (repGoal + 1)
122 ] 135 ]
123 136
137 targetReps :: Int -> Int
138 targetReps 1 = 5
139 targetReps 2 = 3
140 targetReps 3 = 1
141 targetReps _ = undefined
142
143 percentage 1 = 85 % 100
144 percentage 2 = 90 % 100
145 percentage 3 = 95 % 100
146 percentage _ = undefined
147
148ceilingN :: Integer -> Rational -> Integer
149ceilingN n x = ceiling (x / toRational n) * n
150
124-- TODO: State contains chosen repmax formula 151-- TODO: State contains chosen repmax formula
125-- TODO: State contains performances 152-- TODO: State contains performances
126data St = St { 153data St = St {