diff options
author | 2020-07-18 12:42:18 -0500 | |
---|---|---|
committer | 2020-07-18 12:42:18 -0500 | |
commit | 8b54a01a8b0073e323cfd24ba59328f3ea060a47 (patch) | |
tree | ae12e69b92eaa24f03b0c87fa09ed6864a5380ed | |
parent | bugfix (diff) |
add mutagen and antimutagen
these add and remove element types from the user
right now, the code assumes that the order of the types that appear
in the list isn't relavent
-rw-r--r-- | data/items/consumable.lisp | 34 | ||||
-rw-r--r-- | packages.lisp | 2 |
2 files changed, 36 insertions, 0 deletions
diff --git a/data/items/consumable.lisp b/data/items/consumable.lisp index fd44336..a5f48e0 100644 --- a/data/items/consumable.lisp +++ b/data/items/consumable.lisp @@ -12,6 +12,40 @@ (progn (format t "~a regained health~%" (name-of user)) (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))) +(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))) + (new (union old types :key 'type-of :test 'eq)) + (difference (set-difference new old :key 'type-of :test 'eq))) + (if difference + (progn (setf (element-type-of user) new) + (iter (for i in difference) + (f:fmt t (name-of user) " gained the " (:esc + (let* ((class (class-of i)) + (name (name-of class))) + (if name (:fmt (:a name)) + (:s (class-name class))))) + " type" #\Newline))) + (f:fmt t "It had no effect on " (name-of user) #\Newline)))) +(defclass antimutagen (consumable) + ((element-type :initarg :element-type :accessor element-type-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))) + (new (set-difference old types :key 'type-of :test 'eq)) + (difference (set-difference old new :key 'type-of :test 'eq))) + (if difference + (progn (setf (element-type-of user) new) + (iter (for i in difference) + (f:fmt t (name-of user) " lost the " (:esc + (let* ((class (class-of i)) + (name (name-of class))) + (if name (:fmt (:a name)) + (:s (class-name class))))) + " type" #\Newline))) + (f:fmt t "It had no effect on " (name-of user) #\Newline)))) (defclass monster-energy-drink (consumable) () (:default-initargs :name "Monster Energy Drink" diff --git a/packages.lisp b/packages.lisp index 64f668d..8a35192 100644 --- a/packages.lisp +++ b/packages.lisp @@ -399,6 +399,8 @@ #:stretchable-orca-suit-lite #:boxers #:panties + #:mutagen + #:antimutagen #:bra #:bikini-top #:tunic |