X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=verbs.lisp;h=d10da4d5242aa7c9b79e13aaa7452454e8a9b111;hb=e4d49c347b683ad27be42750e0d9117384fb6c23;hp=0adf53ce8cbdbf161bf1afa261b94a0fbaf08e13;hpb=f8f56cc15a3d62a34e2b73b04503885d787a46aa;p=lifp.git diff --git a/verbs.lisp b/verbs.lisp index 0adf53c..d10da4d 100644 --- a/verbs.lisp +++ b/verbs.lisp @@ -17,8 +17,8 @@ :take :put-in :put-on :drop :receive :wear :strip :enter :climb :drink :eat :rub :turn :switch-on :switch-off - :fill :empty :extract :let-go) - (:shadow :listen :fill) + :fill :empty :extract :let-go :open :close) + (:shadow :listen :fill :open :close) (:shadowing-import-from :if-lib :room)) (in-package :verb-lib) @@ -174,7 +174,21 @@ (verb "empty" '(:noun -> empty)) +(verb "open" + '(:noun -> open) + '(:noun "with" :held -> unlock-open)) +(verb "close" '(:noun -> close)) +(verb "shut" + '(:noun -> close) + '("off" :noun -> switch-off) + '(:noun "off" -> switch-off)) + +(verb "lock" + '(:noun "with" :held -> lock)) +(verb "unlock" + '(:noun "with" :held -> unlock)) + (defaction attack (obj) "Violence is not the answer.") @@ -338,7 +352,7 @@ "This action achieves nothing.") (defaction turn (what) - "That's fixed in place") + "That's fixed in place.") (defmethod turn ((item item)) (if (has item :item) @@ -417,3 +431,26 @@ (defmethod let-go ((host container) (item item)) (move item (parent host)) (run-action-after host)) + +(defaction open (obj) + "You cannot open this") + +(defmethod open ((obj container)) + (unless (has obj :container) (return-from open (call-next-method))) + (if (has obj :closed) + (if (hasnt obj :locked) + (progn + (give obj :~closed) + (when (run-action-after obj) + (format nil "You open ~a." (the-name obj)))) + "It's locked.") + (format nil "~a is already open." (the-name obj)))) + +(defmethod close ((obj container)) + (unless (has obj :container) (return-from closed (call-next-method))) + (if (hasnt obj :closed) + (progn + (give obj :closed) + (when (run-action-after obj) + (format nil "You close ~a." (the-name obj)))) + (format nil "~a is already closed." (the-name obj))))