X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=iflib.lisp;h=4ba5b5dfde16d40b7918bf717fd7fcf78a7e8ae0;hb=2d1a6f87c4d559af53eb5e5f0fe571caf14f8b29;hp=1193606f36ca4880c3708172864045d12e88c026;hpb=f8f56cc15a3d62a34e2b73b04503885d787a46aa;p=lifp.git diff --git a/iflib.lisp b/iflib.lisp index 1193606..4ba5b5d 100644 --- a/iflib.lisp +++ b/iflib.lisp @@ -22,12 +22,12 @@ (defpackage :if-lib (:use :common-lisp :if-basic-lib :if-console) (:export :container :room :item :clothing :capacity - :food :switchable + :food :switchable :door :predoor :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 + :u-to :d-to :cant-go :destination :*intscope* :*outscope* :*location* :*trace-light* :*vowels* :*score* :*gamestate* :*turns* :*dark* - :add-to-scope :add-to-outscope :found-in :seen-from + :add-to-scope :add-to-outscope :found-in :seen-from :with-keys :compass :dir-n :dir-ne :dir-e :dir-se :dir-s :dir-sw :dir-w :dir-nw :dir-u :dir-d :dir-in :dir-out :darkness :lit :transparent :passable @@ -79,10 +79,10 @@ "Turns passed since beginning of the game") (defparameter *player* nil - "Current player object (will be initialised later") - -(declare-predicate add-to-scope add-to-outscope found-in seen-from) + "Current player object (will be initialised later)") +(declare-predicate add-to-scope add-to-outscope found-in seen-from + with-keys) ;;Library file names (defvar *library-file-if* "if.fas") @@ -91,14 +91,16 @@ ;;SECTION 2: Library-defined classes and objects -(ifclass container () (capacity integer) (has :container)) +(ifclass predoor ()) ;;Can potentially be locked... + +(ifclass container (predoor) (capacity integer) (has :container)) (ifclass supporter () (capacity integer) (has :supporter)) (ifclass room () (description string) (n-to object) (ne-to object) (e-to object) (se-to object) (s-to object) (sw-to object) (w-to object) (nw-to object) (u-to object) (d-to object) (in-to object) (out-to object) - (cant-go string) + ;(cant-go string) <- doesn't provide by default (has :light :enterable)) (ifclass item () (description string) (article string) @@ -118,6 +120,11 @@ (look (look self))) (has :~light)) +(ifclass door (predoor scenery) (destination object) + (has :door :closed :openable)) + + + ;;Compass directions (object compass ()) (object dir-n () "north" (name "north" "n") compass (property 'n-to)) @@ -155,7 +162,7 @@ (defun transparent (obj) "Whether the object is transparent" - (or (has obj :container :open) + (or (and (has obj :container) (hasnt obj :closed)) (has obj :supporter) (has obj :transparent) (eql obj *player*))) @@ -200,7 +207,7 @@ (seep1 actor obj))) (defun passable (obj) - (or (has obj :container :open) + (or (and (has obj :container) (hasnt obj :closed)) (has obj :supporter) (eql obj *player*))) @@ -321,7 +328,7 @@ (defun print-inside (obj stream) "Return the string containing the status of contents of the object" (when (has obj :container) - (if (or (has obj :open) (has obj :transparent)) + (if (or (hasnt obj :closed) (has obj :transparent)) (if (children obj) (progn (princ " (containing " stream) (princ (list-contents obj) stream) @@ -349,7 +356,7 @@ (defun default-glance (obj) "Default initial description of object" - (format t "[Default glance for ~a]~%" obj) + ;;(format t "[Default glance for ~a]~%" obj) (sprint "~a~%" (with-output-to-string (out) (princ "There is " out) (princ (print-name obj) out) @@ -681,7 +688,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"