diff options
author | Joris | 2021-05-13 14:50:51 +0200 |
---|---|---|
committer | Joris | 2021-05-13 14:58:26 +0200 |
commit | 221b6451fb4f8559a10e7fefebd13ce125ef29d0 (patch) | |
tree | 3ab337b7b2d40e8235f887046a580b0850540f11 /src/Model | |
parent | 5c636f11cdfed82634ee572645d765b704941b68 (diff) |
Rewrite in TypeScript
BuckleScript is no longer maintained. Choose a widely used techno that
will still be maintained in the following years.
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/config.ml | 12 | ||||
-rw-r--r-- | src/Model/step.ml | 40 |
2 files changed, 0 insertions, 52 deletions
diff --git a/src/Model/config.ml b/src/Model/config.ml deleted file mode 100644 index 99e42d1..0000000 --- a/src/Model/config.ml +++ /dev/null @@ -1,12 +0,0 @@ -type config = { - prepare : int; - tabatas : int; - cycles : int; - work : int; - rest : int; -} - -let init = { prepare = 10; tabatas = 4; cycles = 8; work = 20; rest = 10 } - -let getDuration { prepare; tabatas; cycles; work; rest } = - tabatas * (prepare + (cycles * (work + rest))) diff --git a/src/Model/step.ml b/src/Model/step.ml deleted file mode 100644 index 02a110e..0000000 --- a/src/Model/step.ml +++ /dev/null @@ -1,40 +0,0 @@ -type step = Prepare | Work | Rest | End - -let prettyPrint step = - match step with - | Prepare -> "Prepare" - | Work -> "Work" - | Rest -> "Rest" - | End -> "End" - -type state = { step : step; remaining : int; tabata : int; cycle : int } - -let getAt (config : Config.config) elapsed = - let cycleDuration = config.work + config.rest in - let tabataDuration = config.prepare + (config.cycles * cycleDuration) in - if elapsed >= tabataDuration * config.tabatas then - { - step = End; - remaining = 0; - tabata = config.tabatas; - cycle = config.cycles; - } - else - let currentTabataElapsed = elapsed mod tabataDuration in - let step, remaining = - if currentTabataElapsed < config.prepare then - (Prepare, config.prepare - currentTabataElapsed) - else - let currentCycleElapsed = - (currentTabataElapsed - config.prepare) mod cycleDuration - in - if currentCycleElapsed < config.work then - (Work, config.work - currentCycleElapsed) - else (Rest, config.work + config.rest - currentCycleElapsed) - in - let tabata = (elapsed / tabataDuration) + 1 in - let cycle = - if currentTabataElapsed < config.prepare then 1 - else ((currentTabataElapsed - config.prepare) / cycleDuration) + 1 - in - { step; remaining; tabata; cycle } |