diff options
author | Andrew Cady <d@jerkface.net> | 2022-11-03 20:26:10 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-11-03 20:26:10 -0400 |
commit | 8ededa8f0024179c7314989ccef1b5b8c5f0577b (patch) | |
tree | 831bdf42b23a415e9943635d9b69cc1e21a04a7e | |
parent | fa09e6ce131e9669baca8ce2562fe87dd1f43528 (diff) |
begin implementation of accessory lifts
-rwxr-xr-x | repgoal.hs | 61 |
1 files changed, 46 insertions, 15 deletions
@@ -118,12 +118,24 @@ showRational n = printf format $ (realToFrac :: Rational -> Float) $ n | |||
118 | 118 | ||
119 | data WeekSelection = Week1 | Week2 | Week3 deriving (Enum, Bounded, Show, Eq) | 119 | data WeekSelection = Week1 | Week2 | Week3 deriving (Enum, Bounded, Show, Eq) |
120 | 120 | ||
121 | data Programming = Wendler | Accessory Int Int | Unspecified | ||
122 | |||
123 | data Lift = Lift { | ||
124 | liftName :: Text, | ||
125 | liftProgramming :: Programming | ||
126 | } | ||
127 | |||
128 | data Session = Session { | ||
129 | sessionName :: Text, | ||
130 | sessionLifts :: NESeq Lift | ||
131 | } | ||
132 | |||
121 | -- TODO: State contains chosen repmax formula | 133 | -- TODO: State contains chosen repmax formula |
122 | -- TODO: State contains performances | 134 | -- TODO: State contains performances |
123 | data St = St { | 135 | data St = St { |
124 | _lifts :: [LiftRecord], | 136 | _lifts :: [LiftRecord], |
125 | _week :: WeekSelection, | 137 | _week :: WeekSelection, |
126 | _sessions :: NESeq (Set Text), | 138 | _sessions :: NESeq (Session), |
127 | _selectedSession :: Int | 139 | _selectedSession :: Int |
128 | } | 140 | } |
129 | makeLenses ''St | 141 | makeLenses ''St |
@@ -164,14 +176,21 @@ lookup' i seq = fromJust $ NESeq.lookup (i `mod` NESeq.length seq) seq | |||
164 | drawUI :: St -> [Widget ()] | 176 | drawUI :: St -> [Widget ()] |
165 | drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] | 177 | drawUI st = [vCenter $ vBox [hCenter $ hBox [header, oneRepMaxTable], withVScrollBarHandles $ withVScrollBars OnRight $ viewport () Vertical $ hCenter lastSetTable]] |
166 | where | 178 | where |
167 | lifts' = filter ((flip Set.member $ view sessions st & lookup' (view selectedSession st)) . liftRecordName) (view lifts st) | 179 | session :: Session |
168 | lastSetTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Set", "Plates", "Goal", "Done", "Rest"] : concatMap (toLiftRows (view week st)) lifts' | 180 | session = view sessions st & lookup' (view selectedSession st) |
181 | sameName a b = liftName a == liftRecordName b | ||
182 | lifts' :: [(Lift, Maybe LiftRecord)] | ||
183 | lifts' = session & sessionLifts & toList & map (\lift -> (lift, find (sameName lift) $ view lifts st)) | ||
184 | liftNames :: [Text] | ||
185 | liftNames = session & sessionLifts & fmap liftName & toList | ||
186 | liftRecords :: [LiftRecord] | ||
187 | 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 | ||
169 | header = renderTable $ table $ map (padLeftRight 1 . txt) | 189 | header = renderTable $ table $ map (padLeftRight 1 . txt) |
170 | ["Date", "Time", "Bodyweight", "Week", "Session"] | 190 | ["Date", "Time", "Bodyweight", "Week", "Session"] |
171 | : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName] ] | 191 | : [ map (padLeftRight 2 . txt) [" ", " ", " ", weekNumber, sessionName session] ] |
172 | weekNumber = case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3" | 192 | weekNumber = case (view week st) of Week1 -> "1"; Week2 -> "2"; Week3 -> "3" |
173 | sessionName = liftRecordName $ head lifts' | 193 | oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow liftRecords |
174 | oneRepMaxTable = renderTable $ table $ map (padLeftRight 1 . txt) ["Lift", "Achieved Best", "Computed 1RM"] : map toRow lifts' | ||
175 | toRow LiftRecord{..} = | 194 | toRow LiftRecord{..} = |
176 | let best@Achieved{..} = bestPerformance stats | 195 | let best@Achieved{..} = bestPerformance stats |
177 | in | 196 | in |
@@ -270,14 +289,26 @@ powerClean = clean * 80 / 100 | |||
270 | pushPress = press * 100 / 75 | 289 | pushPress = press * 100 / 75 |
271 | jerk = pushPress / 100 * 85 | 290 | jerk = pushPress / 100 * 85 |
272 | 291 | ||
273 | routine :: NESeq (Set Text) | 292 | program :: NESeq Session |
274 | routine = | 293 | program = |
275 | Set.fromList ["Deadlift", "Press"] :<|| | 294 | Session "Deadlift" (Lift "Deadlift" Wendler :<|| Seq.fromList [ |
276 | Seq.fromList | 295 | Lift "Press" Wendler, |
277 | [ Set.fromList ["Front Squat"] | 296 | Lift "Row" $ Accessory 5 10, |
278 | , Set.fromList ["Left-Arm Snatch", "Right-Arm Snatch"] | 297 | Lift "Dip" $ Accessory 5 2, |
279 | , Set.fromList ["Squat", "Bench"] | 298 | Lift "Good Morning" $ Accessory 3 10]) |
280 | , Set.fromList ["Push Press", "Power Clean"] | 299 | :<|| |
300 | Seq.fromList [ | ||
301 | Session "Front Squat" (Lift "Front Squat" Wendler :<|| Seq.fromList | ||
302 | [Lift "Naked Bar Warmup" Unspecified, | ||
303 | Lift "Left-Arm Snatch" Unspecified, | ||
304 | Lift "Right-Arm Snatch" Unspecified]) , | ||
305 | Session "Squat" (Lift "Squat" Wendler :<|| Seq.fromList [ | ||
306 | Lift "Bench" Wendler, | ||
307 | Lift "Row" $ Accessory 5 10, | ||
308 | Lift "Back Raise" $ Accessory 3 15, | ||
309 | Lift "DB Bench" $ Accessory 3 10, | ||
310 | Lift "Rear Lateral" $ Accessory 3 20]), | ||
311 | Session "Power Clean" (Lift "Power Clean" Wendler :<|| Seq.fromList [Lift "Push Press" Wendler]) | ||
281 | ] | 312 | ] |
282 | 313 | ||
283 | main :: IO () | 314 | main :: IO () |
@@ -287,4 +318,4 @@ main = do | |||
287 | -- liftIO $ setMode (outputIface vty) Mouse True | 318 | -- liftIO $ setMode (outputIface vty) Mouse True |
288 | chan <- newBChan 10 | 319 | chan <- newBChan 10 |
289 | initial <- read <$> readFile "lifts.dat" :: IO [LiftRecord] | 320 | initial <- read <$> readFile "lifts.dat" :: IO [LiftRecord] |
290 | void $ customMain vty buildVty (Just chan) (theApp) (St initial Week1 routine 0) | 321 | void $ customMain vty buildVty (Just chan) (theApp) (St initial Week1 program 0) |