diff options
author | 2020-07-21 09:32:22 -0500 | |
---|---|---|
committer | 2020-07-21 09:32:22 -0500 | |
commit | d70b36d58bf7d02dc3f481052977b131c2280db9 (patch) | |
tree | 40298abe54038a984bcd4ca6b4dd2fc7aeb24c45 | |
parent | subtypes are supposed to count here (diff) |
moves can now have mutliple element types
-rw-r--r-- | core/classes.lisp | 23 | ||||
-rw-r--r-- | core/libexec.lisp | 20 | ||||
-rw-r--r-- | data/enemies/eggbots.lisp | 2 | ||||
-rw-r--r-- | data/enemies/navy.lisp | 2 | ||||
-rw-r--r-- | data/enemies/pirates.lisp | 2 | ||||
-rw-r--r-- | data/enemies/pokemon.lisp | 2 | ||||
-rw-r--r-- | data/enemies/rpgmaker.lisp | 6 | ||||
-rw-r--r-- | data/items/consumable.lisp | 16 | ||||
-rw-r--r-- | data/moves/regular.lisp | 2 | ||||
-rw-r--r-- | data/prolog/enemies.lisp | 2 | ||||
-rw-r--r-- | packages.lisp | 2 |
11 files changed, 37 insertions, 42 deletions
diff --git a/core/classes.lisp b/core/classes.lisp index 9df677f..7132f75 100644 --- a/core/classes.lisp +++ b/core/classes.lisp @@ -51,7 +51,14 @@ nil) (:method (source (target (eql nil))) nil)) -(defclass base-character (yadfa-class) +(defclass element-type-mixin () + ((element-types + :accessor element-types-of + :initform nil + :initarg :element-types + :type list + :documentation #.(f:fmt nil "a list of " (ref element-type :class) "s or symbols that makes @code{CL:MAKE-INSTANCE} return one when passed to it")))) +(defclass base-character (yadfa-class element-type-mixin) ((name :initarg :name :initform :missingno. @@ -64,12 +71,6 @@ :accessor description-of :type (or keyword string) :documentation "Description of the character") - (element-type - :accessor element-type-of - :initform nil - :initarg :element-type - :type list - :documentation #.(f:fmt nil "a list of " (ref element-type :class) "s or symbols that makes @code{CL:MAKE-INSTANCE} return one when passed to it")) (health :initarg :health :accessor health-of @@ -314,7 +315,7 @@ :accessor persistentp :documentation "Whether items or moves that cure statuses cure this")) (:documentation "Base class for all the status conditions ")) -(defclass move (yadfa-class attack-mixin) +(defclass move (yadfa-class attack-mixin element-type-mixin) ((name :initarg :name :initform :- @@ -327,12 +328,6 @@ :type (or keyword string) :accessor description-of :documentation "Description of move") - (element-type - :accessor element-type-of - :initform nil - :initarg :element-type - :type (or (and symbol (not keyword)) element-type) - :documentation #.(f:fmt nil "a " (ref element-type :class) " or symbol that makes @code{CL:MAKE-INSTANCE} return one when passed to it")) (energy-cost :initarg :energy-cost :initform 0 diff --git a/core/libexec.lisp b/core/libexec.lisp index a9fd5ab..e3e1752 100644 --- a/core/libexec.lisp +++ b/core/libexec.lisp @@ -3379,18 +3379,19 @@ attack is @code{(calculate-stat @var{user} :attack)} defense is @code{(calculate-stat @var{user} :defense)} 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))) + (let ((attack-element-types (element-types-of attack)) + (target-element-types (element-types-of target)) + (user-element-types (element-types-of user))) (s:mvlet ((super-effective not-very-effective no-effect (funcall (lambda () (iter (with (the fixnum super-effective) = 0) (with (the fixnum not-very-effective) = 0) (with (the fixnum 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))) + (for attack-element-type in attack-element-types) + (iter (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) @@ -3399,8 +3400,7 @@ randomrange is @code{(random-from-range 85 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 :test 'subtypep) + (if (intersection attack-element-types user-element-types :key 'coerce-element-type :test 'subtypep) 1.5 1))))))) (defun present-stats (user) diff --git a/data/enemies/eggbots.lisp b/data/enemies/eggbots.lisp index e760a5f..19d4ba1 100644 --- a/data/enemies/eggbots.lisp +++ b/data/enemies/eggbots.lisp @@ -8,4 +8,4 @@ :male t :attributes (list :not-ticklish t) :bitcoins-per-level 40 - :element-type (list (make-instance 'yadfa-element-types:steel)))) + :element-types (list (make-instance 'yadfa-element-types:steel)))) diff --git a/data/enemies/navy.lisp b/data/enemies/navy.lisp index b0986eb..6e987f1 100644 --- a/data/enemies/navy.lisp +++ b/data/enemies/navy.lisp @@ -10,7 +10,7 @@ :mudsport-chance 3 :bladder/contents (random 500) :bowels/contents (random 700) - :element-type (list (make-instance 'yadfa-element-types:water)) + :element-types (list (make-instance 'yadfa-element-types:water)) :inventory (iter (for i from 0 to (random 5)) (collect (make-instance 'yadfa-items:navy-pullups))) :bitcoins-per-level 60)) (defmethod process-battle-accident ((character navy-officer) attack (item item) reload (selected-target base-character)) diff --git a/data/enemies/pirates.lisp b/data/enemies/pirates.lisp index 2e31025..38889c5 100644 --- a/data/enemies/pirates.lisp +++ b/data/enemies/pirates.lisp @@ -8,7 +8,7 @@ :male (a:random-elt '(t nil)) :bladder/contents (random 500) :bowels/contents (random 700) - :element-type (list (make-instance 'yadfa-element-types:water)) + :element-types (list (make-instance 'yadfa-element-types:water)) :watersport-limit 300 :mudsport-limit 400 :inventory (iter (for i from 0 to (random 20)) (collect (make-instance 'yadfa-items:diaper))))) diff --git a/data/enemies/pokemon.lisp b/data/enemies/pokemon.lisp index 197f078..696b644 100644 --- a/data/enemies/pokemon.lisp +++ b/data/enemies/pokemon.lisp @@ -7,7 +7,7 @@ :species "Magikarp" :male (a:random-elt '(t nil)) :bitcoins-per-level 10 - :element-type (list (make-instance 'yadfa-element-types:water)))) + :element-types (list (make-instance 'yadfa-element-types:water)))) (defmethod attack ((target team-member) (user magikarp) (attack null)) (declare (ignore target attack)) (format t "~a uses Splash, obviously it had no effect. What did you think was going to happen?" (name-of user))) diff --git a/data/enemies/rpgmaker.lisp b/data/enemies/rpgmaker.lisp index 1934075..23965db 100644 --- a/data/enemies/rpgmaker.lisp +++ b/data/enemies/rpgmaker.lisp @@ -36,7 +36,7 @@ :bitcoins-per-level 100 :inventory (iter (for i from 0 to (random 10)) (collect (make-instance 'yadfa-items:high-capacity-diaper))) - :element-type (list (make-instance 'yadfa-element-types:poison)) + :element-types (list (make-instance 'yadfa-element-types:poison)) :moves (list (make-instance 'yadfa-moves:spray) (make-instance 'yadfa-moves:face-sit)))) (defmethod initialize-instance :after ((c diapered-skunk) &rest args &key &allow-other-keys) @@ -109,7 +109,7 @@ :watersport-chance 3 :mudsport-chance 3 :bitcoins-per-level 100 - :element-type (list (make-instance 'yadfa-element-types:poison)) + :element-types (list (make-instance 'yadfa-element-types:poison)) :moves (list (make-instance 'yadfa-moves:spray) (make-instance 'yadfa-moves:face-sit)))) (defmethod initialize-instance :after ((c diapered-skunk*) &rest args &key &allow-other-keys) @@ -191,7 +191,7 @@ (collect (make-instance 'yadfa-items:high-capacity-diaper))) (iter (for i from 0 to (random 20)) (collect (make-instance 'yadfa-items:kurikia-thick-diaper)))) - :element-type (list (make-instance 'yadfa-element-types:dragon) (make-instance 'yadfa-element-types:fire) + :element-types (list (make-instance 'yadfa-element-types:dragon) (make-instance 'yadfa-element-types:fire) (make-instance 'yadfa-element-types:flying)) :moves (list (make-instance 'yadfa-moves:tickle) (make-instance 'yadfa-moves:roar) diff --git a/data/items/consumable.lisp b/data/items/consumable.lisp index 5026f86..932d454 100644 --- a/data/items/consumable.lisp +++ b/data/items/consumable.lisp @@ -13,10 +13,10 @@ (incf (health-of user) 20)) (format t "You make the unconscious ~a suckle on the ~a like a sleeping infant~%" (name-of user) (name-of item)))) (defclass mutagen (consumable) - ((element-type :initarg :element-type :accessor element-type-of))) + ((element-types :initarg :element-types :accessor element-types-of))) (defmethod use-script ((item mutagen) (user base-character)) - (let* ((types (mapcar 'coerce-element-type (element-type-of item))) - (old (mapcar 'coerce-element-type (element-type-of user))) + (let* ((types (mapcar 'coerce-element-type (element-types-of item))) + (old (mapcar 'coerce-element-type (element-types-of user))) (new (union old types :key 'type-of :test 'eq)) (difference (set-difference new old :key 'type-of :test 'eq))) (if difference @@ -27,15 +27,15 @@ (if name (:fmt (:a name)) (:fmt (:s (class-name class)))))) " type" #\Newline))) - (setf (element-type-of user) new) + (setf (element-types-of user) new) (iter (for i in difference) (format-type i))) (f:fmt t "It had no effect on " (name-of user) #\Newline)))) (defclass antimutagen (consumable) - ((element-type :initarg :element-type :accessor element-type-of))) + ((element-types :initarg :element-types :accessor element-types-of))) (defmethod use-script ((item antimutagen) (user base-character)) - (let* ((types (mapcar 'coerce-element-type (element-type-of item))) - (old (mapcar 'coerce-element-type (element-type-of user))) + (let* ((types (mapcar 'coerce-element-type (element-types-of item))) + (old (mapcar 'coerce-element-type (element-types-of user))) (new (set-difference old types :key 'type-of :test 'eq)) (difference (set-difference old new :key 'type-of :test 'eq))) (if difference @@ -46,7 +46,7 @@ (if name (:fmt (:a name)) (:fmt (:s (class-name class)))))) " type" #\Newline))) - (setf (element-type-of user) new) + (setf (element-types-of user) new) (iter (for i in difference) (format-type i))) (f:fmt t "It had no effect on " (name-of user) #\Newline)))) diff --git a/data/moves/regular.lisp b/data/moves/regular.lisp index 7a54522..485cd7c 100644 --- a/data/moves/regular.lisp +++ b/data/moves/regular.lisp @@ -139,7 +139,7 @@ :energy-cost 5 :power 60 :description "Breathes fire at the enemy" - :element-type (make-instance 'yadfa-element-types:fire))) + :element-types (list (make-instance 'yadfa-element-types:fire)))) (defmethod attack ((target base-character) (user base-character) (self fire-breath)) (let ((a (calculate-damage target user self))) (format t "~a used ~a~%" (name-of user) (name-of self)) diff --git a/data/prolog/enemies.lisp b/data/prolog/enemies.lisp index 1910684..a9c7fdf 100644 --- a/data/prolog/enemies.lisp +++ b/data/prolog/enemies.lisp @@ -28,5 +28,5 @@ :defense float-features:long-float-positive-infinity :energy most-positive-fixnum :speed 120) - :element-type (list (make-instance 'yadfa-element-types:ghost)) + :element-types (list (make-instance 'yadfa-element-types:ghost)) :moves (list (make-instance 'yadfa-moves:ghost-tickle) (make-instance 'yadfa-moves:ghost-mush) (make-instance 'yadfa-moves:ghost-squish)))) diff --git a/packages.lisp b/packages.lisp index ec42613..5afe1f7 100644 --- a/packages.lisp +++ b/packages.lisp @@ -198,7 +198,7 @@ #:skin-of #:config-of #:stairs-of - #:element-type-of + #:element-types-of #:last-process-potty-time-of #:process-battle-accident-of #:process-potty-dance-of |