From: grue Date: Thu, 9 Feb 2006 10:34:53 +0000 (+0000) Subject: official update X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=4b3d4fbf3031334896e98a3da1dbc8820abb0c17;p=lifp.git official update darcs-hash:0ca1bf8978c98047303c9c9c7ee16e72eb8e4930 --- diff --git a/if.lisp b/if.lisp index dd8d31a..08d5038 100644 --- a/if.lisp +++ b/if.lisp @@ -47,7 +47,7 @@ :verb :extend-verb :extend-verb-first :extend-verb-only :extend-verb-only-first :deftoken :string== :matchp :!last! - :in :objectloop :provides + :in :notin :objectloop :provides :wordlist :tokenlist :nosuchword :nosuchword-word :parse-command :unknown-verb :run-action :run-action-after diff --git a/iflib.lisp b/iflib.lisp index 0098e5c..8ed9480 100644 --- a/iflib.lisp +++ b/iflib.lisp @@ -22,6 +22,7 @@ (defpackage :if-lib (:use :common-lisp :if-basic-lib :if-console) (:export :container :room :item :clothing :capacity + :food :switchable :n-to :ne-to :e-to :se-to :s-to :sw-to :w-to :nw-to :in-to :out-to :u-to :d-to :cant-go :*intscope* :*outscope* :*location* :*trace-light* :*vowels* 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))) +