open,close
Sun Jul 2 09:57:03 PDT 2006 grue@mail.ru
* open,close
diff -rN -u old-lifp/iflib.lisp new-lifp/iflib.lisp
--- old-lifp/iflib.lisp 2014-07-31 20:44:32.000000000 -0700
+++ new-lifp/iflib.lisp 2014-07-31 20:44:32.000000000 -0700
@@ -79,7 +79,7 @@
"Turns passed since beginning of the game")
(defparameter *player* nil
- "Current player object (will be initialised later")
+ "Current player object (will be initialised later)")
(declare-predicate add-to-scope add-to-outscope found-in seen-from)
@@ -681,7 +681,7 @@
`(defpackage ,name
(:use :common-lisp :if-basic-lib :if-lib :verb-lib ,@other-packages)
(:shadowing-import-from :if-lib :room)
- (:shadowing-import-from :verb-lib :listen :fill)))
+ (:shadowing-import-from :verb-lib :listen :fill :open :close)))
(defmacro free-symbol (id)
"Frees a symbol from current package using shadow"
diff -rN -u old-lifp/verbs.lisp new-lifp/verbs.lisp
--- old-lifp/verbs.lisp 2014-07-31 20:44:32.000000000 -0700
+++ new-lifp/verbs.lisp 2014-07-31 20:44:32.000000000 -0700
@@ -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))))