summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-11-03 22:43:21 -0400
committerAndrew Cady <d@jerkface.net>2022-11-03 22:43:21 -0400
commit980cd96a41b8b030f849e9d31d18988e6260b3a7 (patch)
tree8809c34c05c252e6efce4e92b521a1e100015876
parentaa0ca6987b09d0403687ead52a57a1fd0fe69254 (diff)
further toward implementation of accessory lifts
-rwxr-xr-xrepgoal.hs47
1 files 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
173lookup' :: Int -> NESeq a -> a 173lookup' :: Int -> NESeq a -> a
174lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq 174lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq
175 175
176wendlerLiftRows :: WeekSelection -> (Lift, Maybe LiftRecord) -> [[Widget n]]
177wendlerLiftRows week lift = filter (not . null) $ (flip map) (annotatePosition $ liftScheme Fresher week) $ wendlerLiftRow lift
178wendlerLiftRow :: (Lift, Maybe LiftRecord) -> (ListPosition, SetScheme) -> [Widget n]
179wendlerLiftRow (_, Nothing) _ = []
180wendlerLiftRow (_, Just LiftRecord{..}) (position, (SetScheme targetRatio targetReps amrap)) =
181 let best = bestPerformance stats
182 computedTarget = targetRatio * (90 % 100) * computeOneRepMax best
183 targetWeight = ceilingN 5 computedTarget
184 repGoal = computeRepGoal targetWeight stats
185 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight
186 showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g))
187 pad = padBottom (Pad $ if amrap then 1 else 0)
188 in
189 map (padLeftRight 2)
190 [
191 pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ",
192 pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight,
193 pad $ str $ showPlates targetWeight,
194 str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ",
195 pad $ txt " ",
196 pad $ txt " "
197 ]
198
199
176drawUI :: St -> [Widget ()] 200drawUI :: St -> [Widget ()]
177drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] 201drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]]
178 where 202 where
@@ -185,7 +209,7 @@ drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrol
185 liftNames = session & sessionLifts & fmap liftName & toList 209 liftNames = session & sessionLifts & fmap liftName & toList
186 liftRecords :: [LiftRecord] 210 liftRecords :: [LiftRecord]
187 liftRecords = filter ((`elem` liftNames) . liftRecordName) (view lifts st) 211 liftRecords = filter ((`elem` liftNames) . liftRecordName) (view lifts st)
188 lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) liftRecords 212 lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (wendlerLiftRows (view week st)) lifts'
189 header = renderTable $ table $ map (padLeftRight 1 . txt) 213 header = renderTable $ table $ map (padLeftRight 1 . txt)
190 ["Date", "Time", "Bodyweight", "Week", "Session"] 214 ["Date", "Time", "Bodyweight", "Week", "Session"]
191 : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName session] ] 215 : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName session] ]
@@ -200,27 +224,6 @@ drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrol
200 str $ printf "%d @ %d" achievedReps achievedWeight, 224 str $ printf "%d @ %d" achievedReps achievedWeight,
201 str $ showRational $ computeOneRepMax best 225 str $ showRational $ computeOneRepMax best
202 ] 226 ]
203 toLiftRows :: WeekSelection -> LiftRecord -> [[Widget n]]
204 toLiftRows week lift = (flip map) (annotatePosition $ liftScheme Fresher week) $ toLiftRow lift
205 toLiftRow :: LiftRecord -> (ListPosition, SetScheme) -> [Widget n]
206 toLiftRow LiftRecord{..} (position, (SetScheme targetRatio targetReps amrap)) =
207 let best = bestPerformance stats
208 computedTarget = targetRatio * (90 % 100) * computeOneRepMax best
209 targetWeight = ceilingN 5 computedTarget
210 repGoal = computeRepGoal targetWeight stats
211 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight
212 showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g))
213 pad = padBottom (Pad $ if amrap then 1 else 0)
214 in
215 map (padLeftRight 2)
216 [
217 pad $ txt $ case position of FirstInList -> liftRecordName; NotFirstInList -> " ",
218 pad $ str $ printf "%2d%s @ %d" targetReps (if amrap then "+" else "" :: Text) targetWeight,
219 pad $ str $ showPlates targetWeight,
220 str $ if amrap then showGoal repGoal ++ "\n" ++ showGoal (repGoal + 1) else " ",
221 pad $ txt " ",
222 pad $ txt " "
223 ]
224 227
225showPlates :: Integer -> String 228showPlates :: Integer -> String
226showPlates (fromIntegral -> wt) = fromMaybe " " $ fmap (ourShow . reverse) $ showPlates' (wt - 45) ourPlates [] 229showPlates (fromIntegral -> wt) = fromMaybe " " $ fmap (ourShow . reverse) $ showPlates' (wt - 45) ourPlates []