aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Pouar <pouar@pouar.net>2020-09-10 11:19:59 -0500
committerGravatar Pouar <pouar@pouar.net>2020-09-10 11:19:59 -0500
commit2eec2e6469ef69e108ebb8c4e2bf14593ee42ee0 (patch)
tree75fb479a9450c8afc3de9c045373f47b513090ac
parentmake this slightly faster (diff)
add multiplier and cooldown to fill-bladder and fill-bowels
-rw-r--r--core/classes.lisp24
-rw-r--r--core/libexec/functions.lisp8
-rw-r--r--core/libexec/generic-functions.lisp32
-rw-r--r--core/libexec/methods.lisp8
4 files changed, 58 insertions, 14 deletions
diff --git a/core/classes.lisp b/core/classes.lisp
index d8dba72..4671f71 100644
--- a/core/classes.lisp
+++ b/core/classes.lisp
@@ -317,6 +317,18 @@
:type real
:accessor bladder/fill-rate-of
:documentation "Amount in ml that the character's bladder fills each turn.")
+ (bladder/fill-rate/multiplier
+ :initarg :bladder/fill-rate/multiplier
+ :initform 1
+ :type real
+ :accessor bladder/fill-rate/multiplier-of
+ :documentation "Multiplier for @var{BLADDER/FILL-RATE}. Decreases by @var{BLADDER/FILL-RATE/COOLDOWN} every turn")
+ (bladder/fill-rate/cooldown
+ :initarg :bladder/fill-rate/cooldown
+ :initform 1/20
+ :type real
+ :accessor bladder/fill-rate/cooldown-of
+ :documentation "How much @var{BLADDER/FILL-RATE/MULTIPLIER} decreases every turn")
(bladder/need-to-potty-limit
:initarg :bladder/need-to-potty-limit
:initform 300
@@ -354,6 +366,18 @@
:type (real 0)
:accessor bowels/fill-rate-of
:documentation "Amount in grams that the character's bowels fills each turn")
+ (bowels/fill-rate/multiplier
+ :initarg :bowels/fill-rate/multiplier
+ :initform 1
+ :type real
+ :accessor bowels/fill-rate/multiplier-of
+ :documentation "Multiplier for @var{BOWELS/FILL-RATE}. Decreases by @var{BOWELS/FILL-RATE/COOLDOWN} every turn")
+ (bowels/fill-rate/cooldown
+ :initarg :bowels/fill-rate/cooldown
+ :initform 1/20
+ :type real
+ :accessor bowels/fill-rate/cooldown-of
+ :documentation "How much @var{BOWELS/FILL-RATE/MULTIPLIER} decreases every turn")
(bowels/need-to-potty-limit
:initarg :bowels/need-to-potty-limit
:initform 400
diff --git a/core/libexec/functions.lisp b/core/libexec/functions.lisp
index 9cc16cf..79e2627 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))))
- (fill-bladder user :multiplier time-difference)
- (fill-bowels user :multiplier time-difference))
+ (fill-bladder user :times time-difference)
+ (fill-bowels user :times 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))))
- (fill-bladder user :multiplier time-difference)
- (fill-bowels user :multiplier time-difference))
+ (fill-bladder user :times time-difference)
+ (fill-bowels user :times 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 4997f6d..b2ebbd9 100644
--- a/core/libexec/generic-functions.lisp
+++ b/core/libexec/generic-functions.lisp
@@ -245,21 +245,41 @@
nil))
(defgeneric bladder/fill-rate (user)
(:method ((user bladder-character))
- (bladder/fill-rate-of user))
+ (* (bladder/fill-rate-of user) (bladder/fill-rate/multiplier-of user)))
(:method ((user base-character))
0))
(defgeneric bowels/fill-rate (user)
(:method ((user bowels-character))
- (bowels/fill-rate-of user))
+ (* (bowels/fill-rate-of user) (bowels/fill-rate/multiplier-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 bladder-character) &key (times 1) &allow-other-keys)
+ (iter (for i from 1 to times)
+ (with multiplier = (bladder/fill-rate/multiplier-of user))
+ (with fill-rate = (bladder/fill-rate-of user))
+ (with cooldown = (bladder/fill-rate/cooldown-of user))
+ (with bladder = (bladder/contents-of user))
+ (incf bladder (* fill-rate multiplier))
+ (cond ((> (- multiplier cooldown) 1) (decf multiplier cooldown))
+ ((< (+ multiplier cooldown) 1) (incf multiplier cooldown))
+ (t (setf multiplier 1)))
+ (finally (setf (bladder/contents-of user) bladder
+ (bladder/fill-rate/multiplier-of user) multiplier))))
(: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 bowels-character) &key (times 1) &allow-other-keys)
+ (iter (for i from 1 to times)
+ (with multiplier = (bowels/fill-rate/multiplier-of user))
+ (with fill-rate = (bowels/fill-rate-of user))
+ (with cooldown = (bowels/fill-rate/cooldown-of user))
+ (with bowels = (bowels/contents-of user))
+ (incf bowels (* fill-rate multiplier))
+ (cond ((> (- multiplier cooldown) 1) (decf multiplier cooldown))
+ ((< (+ multiplier cooldown) 1) (incf multiplier cooldown))
+ (t (setf multiplier 1)))
+ (finally (setf (bowels/contents-of user) bowels
+ (bowels/fill-rate/multiplier-of user) multiplier))))
(:method ((user base-character) &key &allow-other-keys)
0))
diff --git a/core/libexec/methods.lisp b/core/libexec/methods.lisp
index 3baa528..53b0cd2 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))))
- (fill-bladder character :multiplier time-passed)
- (fill-bowels character :multiplier time-passed))
+ (fill-bladder character :times time-passed)
+ (fill-bowels character :times 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))))
- (fill-bladder character :multiplier time-passed)
- (fill-bowels character :multiplier time-passed))
+ (fill-bladder character :times time-passed)
+ (fill-bowels character :times time-passed))
(setf (last-process-potty-time-of character) (time-of *game*))
(cond ((process-battle-accident character attack item reload selected-target)
nil)