Progression adds the step the way a stepper tap does — a weight off the increment grid keeps its offset (397 + 10 = 407, not 410; #175); the service worker closes the previous notification of the same kind before showing the next (#172)
This commit is contained in:
1 parent
06f1c007a7
commit
bff87930d8
4 files changed
+42
-6
No files matched your search
@@ -115,11 +115,19 @@ export function snapWeight(v, step) {
|
||||
// A tap moves by one step. Snapping to the grid keeps the number identical to what progression
|
||||
// would prescribe (61.3 → 62.5 with a 1.25 step, not 62.55) — but only when the current value
|
||||
// already sits on that grid; from 62.5 with a 5 kg step a tap gives 67.5, not 70.
|
||||
// Add `step` to a weight the way a stepper tap does: from a weight that sits on the increment's
|
||||
// grid the sum is snapped to it, from one off the grid the step is simply added. Progression
|
||||
// uses the same rule (issue #175): a sled logged as 397 lb — its own weight plus plates — with
|
||||
// a 10 lb step goes to 407, not to the grid's 410.
|
||||
export function addStep(w, step, inc) {
|
||||
const v = +w || 0
|
||||
const onGrid = inc > 0 && Math.abs(v - Math.round(v / inc) * inc) <= 0.1
|
||||
const next = v + step
|
||||
return Math.max(0, onGrid ? snapWeight(next, inc) : round1(next))
|
||||
}
|
||||
export function stepWeight(value, step, direction) {
|
||||
const v = Number(value) || 0
|
||||
const onGrid = step > 0 && Math.abs(v - Math.round(v / step) * step) <= 0.1
|
||||
const next = v + direction * step
|
||||
return Math.max(0, onGrid ? snapWeight(next, step) : round1(next))
|
||||
return addStep(v, direction * step, step)
|
||||
}
|
||||
// Back off by a factor, landing on something you can actually load. This remains the old policy
|
||||
// used by Greyskull and timed progression; linear/double loaded reps use the Epley selector below.
|
||||
@@ -395,7 +403,7 @@ export function nextPrescription(S, cfg, routine) {
|
||||
const range = normalizeRepRange(cfg.reps || last.goal || 10, cfg.repsMin, repStep(cfg))
|
||||
const top = range.reps
|
||||
const bottom = range.repsMin
|
||||
if (last.ok) return { policy, kind: 'up', weight: snapWeight(w + inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }
|
||||
if (last.ok) return { policy, kind: 'up', weight: addStep(w, inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }
|
||||
if (stalls >= deloadAt) {
|
||||
const selected = epleyDeload()
|
||||
if (selected) return selected
|
||||
@@ -413,7 +421,7 @@ export function nextPrescription(S, cfg, routine) {
|
||||
const dbl = policy === 'greyskull' && last.goal > 0 && last.amrap >= last.goal * 2
|
||||
const step = dbl ? inc * 2 : inc
|
||||
return {
|
||||
policy, kind: 'up', weight: snapWeight(w + step, inc),
|
||||
policy, kind: 'up', weight: addStep(w, step, inc),
|
||||
why: dbl
|
||||
? ['Last set hit {0} reps — twice the target, so take a double jump of {1} {2}.', last.amrap, step, unit]
|
||||
: ['Every rep last time — {0} {1} more.', step, unit]
|
||||
|
||||
@@ -831,3 +831,21 @@ describe('drop-sets and rest-pause sets in progression', () => {
|
||||
expect(out[1]).toEqual({ type: 'dropset', w: 0, r: 10, done: false })
|
||||
})
|
||||
})
|
||||
|
||||
describe('a weight off the increment grid keeps its offset when it goes up (issue #175)', () => {
|
||||
it('adds the step instead of snapping the sum to the grid', () => {
|
||||
// A sled logged as its own 167 lb plus plates: 397 with a 10 lb step goes to 407, not 410.
|
||||
const lin = { id: LIFT, sets: 3, reps: 5, weight: 397, prog: 'linear', inc: 10 }
|
||||
const p = nextPrescription(hist(LIFT, [[397, 5, 5, 5]], { sets: 3, reps: 5, weight: 397 }), lin)
|
||||
expect(p.kind).toBe('up')
|
||||
expect(p.weight).toBe(407)
|
||||
const dbl = { id: LIFT, sets: 3, reps: 12, repsMin: 8, weight: 397, prog: 'double', inc: 10 }
|
||||
const d = nextPrescription(hist(LIFT, [[397, 12, 12, 12]], { sets: 3, reps: 12, weight: 397 }), dbl)
|
||||
expect(d.kind).toBe('up')
|
||||
expect(d.weight).toBe(407)
|
||||
})
|
||||
it('still snaps from a weight that sits on the grid', () => {
|
||||
const p = nextPrescription(hist(LIFT, [[60, 5, 5, 5]]), { id: LIFT, sets: 3, reps: 5, weight: 60, prog: 'linear', inc: 2.5 })
|
||||
expect(p.weight).toBe(62.5)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user