diff options
author | 2020-07-15 10:16:04 -0500 | |
---|---|---|
committer | 2020-07-15 10:16:04 -0500 | |
commit | 32a5ba08251f6a16ff01593db5b7493b55e853ca (patch) | |
tree | bf35e00e491372c20bec4f64c4e1a1410ca663cc | |
parent | make use of the new API in case these moves ever gain a element type (diff) |
iterate through this only once
-rw-r--r-- | core/libexec.lisp | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/core/libexec.lisp b/core/libexec.lisp index 4d04f14..16c7d5a 100644 --- a/core/libexec.lisp +++ b/core/libexec.lisp @@ -3380,24 +3380,27 @@ randomrange is @code{(random-from-range 85 100)}" (let ((attack-element-type (element-type-of attack)) (target-element-types (element-type-of target)) (user-element-types (element-type-of user))) - (round (u:$ (u:$ (u:$ (u:$ (u:$ (u:$ (u:$ 2 * (level-of user)) / 5) + 2) * (power-of attack) * (u:$ (calculate-stat user :attack) / (calculate-stat target :defense))) - / 50) - + 2) - * (* (u:$ (random-from-range 85 100) / 100) - (if (member :no-effect target-element-types - :test (lambda (o e) - (eq o (type-match attack-element-type e)))) - 0 - (expt 2 (iter (with ret = 0) (for target-element-type in target-element-types) - (case (type-match attack-element-type target-element-type) - (:super-effective (incf ret)) - (:not-very-effective (decf ret)) - (:no-effect (error "This should not happen"))) - (finally (return ret))))) - (if (find attack-element-type user-element-types + (s:mvlet ((super-effective not-very-effective no-effect (funcall (lambda () + (iter (with super-effective = 0) + (with not-very-effective = 0) + (with no-effect = 0) + (for target-element-type in target-element-types) + (case (type-match attack-element-type target-element-type) + (:super-effective (incf super-effective)) + (:not-very-effective (incf not-very-effective)) + (:no-effect (incf no-effect))) + (finally (return (values super-effective not-very-effective no-effect)))))))) + (round (u:$ (u:$ (u:$ (u:$ (u:$ (u:$ (u:$ 2 * (level-of user)) / 5) + 2) * (power-of attack) * (u:$ (calculate-stat user :attack) / (calculate-stat target :defense))) + / 50) + + 2) + * (* (u:$ (random-from-range 85 100) / 100) + (if (> no-effect 0) + 0 + (expt 2 (- super-effective not-very-effective))) + (if (find attack-element-type user-element-types :key 'coerce-element-type) - 1.5 - 1)))))) + 1.5 + 1))))))) (defun present-stats (user) (updating-present-with-effective-frame (*query-io* :unique-id `(stats% ,user) :id-test #'equal) (clim:updating-output (*query-io*) |