X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=verbs.lisp;h=406e6e622cd97a8f54944323745ea3541fa5ff42;hb=4b3d4fbf3031334896e98a3da1dbc8820abb0c17;hp=bf227ffd87a6ab52549b55b6d4bb295330f944da;hpb=a55a923ba8e14bae6a6590c2b28b379f773f8760;p=lifp.git diff --git a/verbs.lisp b/verbs.lisp index bf227ff..406e6e6 100644 --- a/verbs.lisp +++ b/verbs.lisp @@ -15,7 +15,8 @@ (:export :attack :take :teleport :examine :go-to :take :put-in :put-on :drop :receive - :wear :strip :enter :climb) + :wear :strip :enter :climb :drink :eat + :rub :turn :switch-on :switch-off) (:shadow :listen) (:shadowing-import-from :if-lib :room)) @@ -142,6 +143,29 @@ '(:noun -> listen) '("to" :noun -> listen)) +(verb "drink" "sip" "swallow" '(:noun -> drink)) + +(verb "eat" "consume" '(:held -> eat)) + +(verb "rub" "clean" "dust" "polish" "scrub" "shine" + "sweep" "wipe" '(:noun -> rub)) + +(verb "switch" + '(:noun -> switch-on) + '(:noun "on" -> switch-on) + '(:noun "off" -> switch-off) + '("on" :noun -> switch-on) + '("off" :noun -> switch-off)) + +(verb "turn" + '(:noun -> turn) + '(:noun "on" -> switch-on) + '(:noun "off" -> switch-off) + '("on" :noun -> switch-on) + '("off" :noun -> switch-off)) + + + (defaction attack (obj) "Violence is not the answer.") (defaction teleport (obj) @@ -181,7 +205,7 @@ (defaction take (obj) "You can't take that.") -(defmethod take((obj item)) +(defmethod take ((obj item)) (if (has obj :item) (if (in obj *player*) (progn (sprint "You already have ~A" (the-name obj)) t) @@ -268,4 +292,54 @@ "You can't climb that.") (defaction listen (what) - "You hear nothing unexpected.") \ No newline at end of file + "You hear nothing unexpected.") + +(defaction drink (what) + "You can't drink that.") + +(defaction eat (what) + "You can't eat that.") + +(defmethod eat ((obj food)) + (if (has obj :edible) + (progn + (rmv obj) + (when (run-action-after obj) + (format nil "You eat ~a." (the-name obj)))) + (call-next-method))) + +(defaction rub (what) + "This action achieves nothing.") + +(defaction turn (what) + "That's fixed in place") + +(defmethod turn ((item item)) + (if (has item :item) + "This action achieves nothing." + (call-next-method))) + +(defaction switch-on (what) + "You can't switch this on") + +(defaction switch-off (what) + "You can't switch this off") + +(defmethod switch-on ((obj switchable)) + (if (has obj :switchable) + (progn + (if (has obj :on) + (format nil "~a is already on." (the-name obj)) + (progn (give obj :on) + (when (run-action-after obj) "Done.")))) + (call-next-method))) + +(defmethod switch-off ((obj switchable)) + (if (has obj :switchable) + (progn + (if (hasnt obj :on) + (format nil "~a is already off." (the-name obj)) + (progn (give obj :~on) + (when (run-action-after obj) "Done.")))) + (call-next-method))) +