diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-05-30 22:45:29 -0700 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-05-30 22:45:29 -0700 |
commit | d4e9417c32414b39e76d20a1b810d274de1f20e9 (patch) | |
tree | 8bbacd4b1bba6a0d49abfa4150e7514af380cbe2 /speedrun.lisp | |
parent | ffa83bc8b0794f5e20c6ee909e963436f5f06371 (diff) | |
download | lispruns-d4e9417c32414b39e76d20a1b810d274de1f20e9.tar.gz lispruns-d4e9417c32414b39e76d20a1b810d274de1f20e9.zip |
Add simple cli for interfacing with program (not fully functional); show splits
Diffstat (limited to 'speedrun.lisp')
-rw-r--r-- | speedrun.lisp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/speedrun.lisp b/speedrun.lisp index b78f75d..df473c9 100644 --- a/speedrun.lisp +++ b/speedrun.lisp @@ -52,16 +52,21 @@ (speedrun-start-timestamp speedrun) (get-internal-real-time) (run-split-start-time (current-split speedrun)) (local-time:now))) +;; Saves the speedrun into the database +(defun save-speedrun (speedrun) + (mapcar #'mito:save-dao (cons (speedrun-run-dao speedrun) (speedrun-splits speedrun)))) + ;; Set the state of the speedrun to be stopped if there are no more splits. ;; Or, set the current split to the next one in the list. (defun next-split (speedrun) (let ((now (local-time:now))) - (setf (run-split-end-time (current-split speedrun)) now) - (inc (speedrun-current-split-index speedrun)) - (if (equal (speedrun-current-split-index speedrun) (length (speedrun-splits speedrun))) - (setf (speedrun-state speedrun) 'STOPPED) - (setf (run-split-start-time (current-split speedrun)) now)))) + (unless (equal (speedrun-state speedrun) 'STOPPED) + (setf (run-split-end-time (current-split speedrun)) now) + (if (equal (speedrun-current-split-index speedrun) (1- (length (speedrun-splits speedrun)))) + (progn + (setf (speedrun-state speedrun) 'STOPPED) + (save-speedrun speedrun)) + (progn + (inc (speedrun-current-split-index speedrun)) + (setf (run-split-start-time (current-split speedrun)) now)))))) -;; Saves the speedrun into the database -(defun save-speedrun (speedrun) - (mapcar #'mito:save-dao (cons (speedrun-run-dao speedrun) (speedrun-splits speedrun)))) |