aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Pouar <pouar@pouar.net>2020-09-07 11:21:25 -0500
committerGravatar Pouar <pouar@pouar.net>2020-09-07 11:21:25 -0500
commit8bbd13b8119027bdcf42f8983e0d2f42ed9c2b36 (patch)
tree8831e8da971c5e75ab0b1ca2967d8a3aa39ee4a1
parentindention (diff)
decided to abstract these
-rw-r--r--core/libexec/functions.lisp8
-rw-r--r--core/libexec/generic-functions.lisp20
-rw-r--r--core/libexec/methods.lisp8
-rw-r--r--data/epilog/pyramid.lisp6
-rw-r--r--packages.lisp4
5 files changed, 34 insertions, 12 deletions
diff --git a/core/libexec/functions.lisp b/core/libexec/functions.lisp
index f945bea..9cc16cf 100644
--- a/core/libexec/functions.lisp
+++ b/core/libexec/functions.lisp
@@ -1279,8 +1279,8 @@
(defunassert process-potty (&optional (user (player-of *game*)))
(user (or player ally))
(let ((time-difference (- (time-of *game*) (last-process-potty-time-of user))))
- (incf (bladder/contents-of user) (* (bladder/fill-rate-of user) time-difference))
- (incf (bowels/contents-of user) (* (bowels/fill-rate-of user) time-difference)))
+ (fill-bladder user :multiplier time-difference)
+ (fill-bowels user :multiplier time-difference))
(setf (last-process-potty-time-of user) (time-of *game*))
(let ((had-accident (if (typep user 'potty-trained-team-member)
(cons (when (>= (bladder/contents-of user) (bladder/maximum-limit-of user))
@@ -1549,8 +1549,8 @@
(defun go-to-sleep% (user)
(incf (time-of *game*) 60)
(let ((time-difference (- (time-of *game*) (last-process-potty-time-of user))))
- (incf (bladder/contents-of user) (* (bladder/fill-rate-of user) time-difference))
- (incf (bowels/contents-of user) (* (bowels/fill-rate-of user) time-difference)))
+ (fill-bladder user :multiplier time-difference)
+ (fill-bowels user :multiplier time-difference))
(setf (health-of user) (calculate-stat user :health)
(last-process-potty-time-of user) (time-of *game*)
(energy-of user) (calculate-stat user :energy))
diff --git a/core/libexec/generic-functions.lisp b/core/libexec/generic-functions.lisp
index e8eb81c..4997f6d 100644
--- a/core/libexec/generic-functions.lisp
+++ b/core/libexec/generic-functions.lisp
@@ -243,3 +243,23 @@
nil)
(:method (source (target (eql nil)))
nil))
+(defgeneric bladder/fill-rate (user)
+ (:method ((user bladder-character))
+ (bladder/fill-rate-of user))
+ (:method ((user base-character))
+ 0))
+(defgeneric bowels/fill-rate (user)
+ (:method ((user bowels-character))
+ (bowels/fill-rate-of user))
+ (:method ((user base-character))
+ 0))
+(defgeneric fill-bladder (user &key &allow-other-keys)
+ (:method ((user bladder-character) &key (delta 0) (multiplier 1) &allow-other-keys)
+ (incf (bladder/contents-of user) (+ (* (bladder/fill-rate user) multiplier) delta)))
+ (:method ((user base-character) &key &allow-other-keys)
+ 0))
+(defgeneric fill-bowels (user &key &allow-other-keys)
+ (:method ((user bowels-character) &key (delta 0) (multiplier 1) &allow-other-keys)
+ (incf (bowels/contents-of user) (+ (* (bowels/fill-rate user) multiplier) delta)))
+ (:method ((user base-character) &key &allow-other-keys)
+ 0))
diff --git a/core/libexec/methods.lisp b/core/libexec/methods.lisp
index 43a2bb4..3baa528 100644
--- a/core/libexec/methods.lisp
+++ b/core/libexec/methods.lisp
@@ -1691,8 +1691,8 @@ randomrange is @code{(random-from-range 85 100)}"
(when (> (energy-of character) (calculate-stat character :energy))
(setf (energy-of character) (calculate-stat character :energy)))
(let ((time-passed (- (time-of *game*) (last-process-potty-time-of character))))
- (incf (bladder/contents-of character) (* (bladder/fill-rate-of character) time-passed))
- (incf (bowels/contents-of character) (* (bowels/fill-rate-of character) time-passed)))
+ (fill-bladder character :multiplier time-passed)
+ (fill-bowels character :multiplier time-passed))
(setf (last-process-potty-time-of character) (time-of *game*))
(cond ((process-battle-accident character attack item reload selected-target)
nil)
@@ -1749,8 +1749,8 @@ randomrange is @code{(random-from-range 85 100)}"
(when (> (energy-of character) (calculate-stat character :energy))
(setf (energy-of character) (calculate-stat character :energy)))
(let ((time-passed (- (time-of *game*) (last-process-potty-time-of character))))
- (incf (bladder/contents-of character) (* (bladder/fill-rate-of character) time-passed))
- (incf (bowels/contents-of character) (* (bowels/fill-rate-of character) time-passed)))
+ (fill-bladder character :multiplier time-passed)
+ (fill-bowels character :multiplier time-passed))
(setf (last-process-potty-time-of character) (time-of *game*))
(cond ((process-battle-accident character attack item reload selected-target)
nil)
diff --git a/data/epilog/pyramid.lisp b/data/epilog/pyramid.lisp
index 2635114..2163210 100644
--- a/data/epilog/pyramid.lisp
+++ b/data/epilog/pyramid.lisp
@@ -93,10 +93,8 @@
(declaim (ftype (function () (values cons &optional)) process-potty))
(defun process-potty ()
(let ((user (player-of *game*)))
- (incf (bladder/contents-of user)
- (bladder/fill-rate-of user))
- (incf (bowels/contents-of user)
- (bowels/fill-rate-of user))
+ (fill-bladder user)
+ (fill-bowels user)
(cons (when (>= (bladder/contents-of user) (bladder/maximum-limit-of user))
(apply 'wet :wetter user (when (boundp '*wear*) `(:clothes ,*wear*))))
(when (>= (bowels/contents-of user) (bowels/maximum-limit-of user))
diff --git a/packages.lisp b/packages.lisp
index 46171aa..488e3b3 100644
--- a/packages.lisp
+++ b/packages.lisp
@@ -128,6 +128,10 @@
#:toggle-onesie
#:type-match
#:coerce-element-type
+ #:fill-bladder
+ #:fill-bowels
+ #:bladder/fill-rate
+ #:bowels/fill-rate
;;constructors
#:make-action
;;classes