Commit e91cc4e1 authored by Mark Oteiza's avatar Mark Oteiza

Make dunnet insertion functions n-ary

* lisp/play/dunnet.el (dun-mprinc, dun-mprincl, dun-minsert):
(dun-minsertl, dun-batch-mprinc, dun-batch-mprincl): Change to accept
any number of arguments.
(dun-parse, dun-describe-room, dun-quit, dun-inven, dun-shake):
(dun-take, dun-go, dun-move, dun-press, dun-score):
(dun-compile-save-out, dun-do-logfile): Collect arguments from
multiple insertion calls into less calls with more args.
parent 18c47695
......@@ -1156,7 +1156,7 @@ treasures for points?" "4" "four")
(setq line (downcase (buffer-substring beg (point))))
(princ line)
(if (eq (dun-vparse dun-ignore dun-verblist line) -1)
(dun-mprinc "I don't understand that.\n")))
(dun-mprincl "I don't understand that.")))
(goto-char (point-max))
(dun-mprinc "\n")))
(dun-messages))
......@@ -1200,8 +1200,7 @@ treasures for points?" "4" "four")
(> room 0))
(not (string= dun-mode "long")))
nil
(dun-mprinc (car (nth (abs room) dun-rooms)))
(dun-mprinc "\n"))
(dun-mprincl (car (nth (abs room) dun-rooms))))
(when (and (not (string= dun-mode "long"))
(not (member (abs room) dun-visited)))
(setq dun-visited (append (list (abs room)) dun-visited)))
......@@ -1216,8 +1215,7 @@ treasures for points?" "4" "four")
(when (and (= xobjs obj-jar) dun-jar)
(dun-mprincl "The jar contains:")
(dolist (x dun-jar)
(dun-mprinc " ")
(dun-mprincl (car (nth x dun-objects))))))
(dun-mprincl " " (car (nth x dun-objects))))))
(if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
(dun-mprincl "You are on the bus."))))
......@@ -1308,8 +1306,7 @@ disk bursts into flames, and disintegrates.")
;;; as we must also print what is in it.
(defun dun-inven (_args)
(dun-mprinc "You currently have:")
(dun-mprinc "\n")
(dun-mprincl "You currently have:")
(dolist (curobj dun-inventory)
(if curobj
(progn
......@@ -1318,8 +1315,7 @@ disk bursts into flames, and disintegrates.")
(progn
(dun-mprincl "The jar contains:")
(dolist (x dun-jar)
(dun-mprinc " ")
(dun-mprincl (cadr (nth x dun-objects))))))))))
(dun-mprincl " " (cadr (nth x dun-objects))))))))))
(defun dun-shake (obj)
(let ((objnum (dun-objnum-from-args-std obj)))
......@@ -1327,10 +1323,8 @@ disk bursts into flames, and disintegrates.")
(cond
((member objnum dun-inventory)
;; If shaking anything will do anything, put here.
(dun-mprinc "Shaking ")
(dun-mprinc (downcase (cadr (nth objnum dun-objects))))
(dun-mprinc " seems to have no effect.")
(dun-mprinc "\n"))
(dun-mprinc "Shaking " (downcase (cadr (nth objnum dun-objects))))
(dun-mprincl " seems to have no effect."))
((and (not (member objnum (nth dun-current-room dun-room-silents)))
(not (member objnum (nth dun-current-room dun-room-objects))))
(dun-mprincl "I don't see that here."))
......@@ -1441,8 +1435,7 @@ For an explosive time, go to Fourth St. and Vermont.")
(if (and (>= x 0) (not (= x obj-special)))
(progn
(setq gotsome t)
(dun-mprinc (cadr (nth x dun-objects)))
(dun-mprinc ": ")
(dun-mprinc (cadr (nth x dun-objects)) ": ")
(dun-take-object x))))
(if (not gotsome)
(dun-mprincl "Nothing to take."))))
......@@ -1688,7 +1681,7 @@ just try dropping it."))
(if (or (not (car args))
(eq (dun-doverb dun-ignore dun-verblist (car args)
(cdr (cdr args))) -1))
(dun-mprinc "I don't understand where you want me to go.\n")))
(dun-mprincl "I don't understand where you want me to go.")))
;;; Uses the dungeon-map to figure out where we are going. If the
;;; requested direction yields 255, we know something special is
......@@ -1708,7 +1701,7 @@ body.")
(let (newroom)
(setq newroom (nth dir (nth dun-current-room dungeon-map)))
(if (eq newroom -1)
(dun-mprinc "You can't go that way.\n")
(dun-mprincl "You can't go that way.")
(if (eq newroom 255)
(dun-special-move dir)
(setq dun-room -1)
......@@ -1931,9 +1924,7 @@ disk bursts into flames, and disintegrates.")
(member objnum (nth dun-current-room dun-room-silents))))
(dun-mprincl "I don't see that here."))
((not (member objnum (list obj-button obj-switch)))
(dun-mprinc "You can't ")
(dun-mprinc (car line-list))
(dun-mprincl " that."))
(dun-mprincl "You can't " (car line-list) " that."))
((= objnum obj-button)
(dun-mprincl
"As you press the button, you notice a passageway open up, but
......@@ -1965,11 +1956,9 @@ to swim.")
(if (not dun-endgame)
(let (total)
(setq total (dun-reg-score))
(dun-mprinc "You have scored ")
(dun-mprinc total)
(dun-mprincl " out of a possible 90 points.") total)
(dun-mprinc "You have scored ")
(dun-mprinc (dun-endgame-score))
(dun-mprincl "You have scored " total " out of a possible 90 points.")
total)
(dun-mprinc "You have scored " (dun-endgame-score))
(dun-mprincl " endgame points out of a possible 110.")
(if (= (dun-endgame-score) 110)
(dun-mprincl
......@@ -2263,17 +2252,19 @@ for a moment, then straighten yourself up.
;;; Insert something into the window buffer
(defun dun-minsert (string)
(if (stringp string)
(insert string)
(insert (prin1-to-string string))))
(defun dun-minsert (&rest args)
(dolist (arg args)
(if (stringp arg)
(insert arg)
(insert (prin1-to-string arg)))))
;;; Print something out, in window mode
(defun dun-mprinc (string)
(if (stringp string)
(insert string)
(insert (prin1-to-string string))))
(defun dun-mprinc (&rest args)
(dolist (arg args)
(if (stringp arg)
(insert arg)
(insert (prin1-to-string arg)))))
;;; In window mode, keep screen from jumping by keeping last line at
;;; the bottom of the screen.
......@@ -2286,14 +2277,14 @@ for a moment, then straighten yourself up.
;;; Insert something into the buffer, followed by newline.
(defun dun-minsertl (string)
(dun-minsert string)
(defun dun-minsertl (&rest args)
(apply #'dun-minsert args)
(dun-minsert "\n"))
;;; Print something, followed by a newline.
(defun dun-mprincl (string)
(dun-mprinc string)
(defun dun-mprincl (&rest args)
(apply #'dun-mprinc args)
(dun-mprinc "\n"))
;;; Function which will get an object number given the list of
......@@ -3052,9 +3043,7 @@ File not found")))
(defun dun-save-val (varname)
(let ((value (symbol-value (intern varname))))
(dun-minsert "(setq ")
(dun-minsert varname)
(dun-minsert " ")
(dun-minsert "(setq " varname " ")
(if (or (listp value)
(symbolp value))
(dun-minsert "'"))
......@@ -3086,30 +3075,19 @@ File not found")))
(dun-mprincl (error-message-string err))))
(when (null ferror)
(goto-char (point-max))
(dun-minsert (current-time-string))
(dun-minsert " ")
(dun-minsert (user-login-name))
(dun-minsert " ")
(dun-minsert (current-time-string) " " (user-login-name) " ")
(if (eq type 'save)
(dun-minsert "saved ")
(if (= (dun-endgame-score) 110)
(dun-minsert "won ")
(if (not how)
(dun-minsert "quit ")
(dun-minsert "killed by ")
(dun-minsert how)
(dun-minsert " "))))
(dun-minsert "at ")
(dun-minsert (cadr (nth (abs dun-room) dun-rooms)))
(dun-minsert ". score: ")
(dun-minsert "killed by " how " "))))
(dun-minsert "at " (cadr (nth (abs dun-room) dun-rooms)) ". score: ")
(if (> (dun-endgame-score) 0)
(dun-minsert (+ 90 (dun-endgame-score)))
(dun-minsert (dun-reg-score)))
(dun-minsert " saves: ")
(dun-minsert dun-numsaves)
(dun-minsert " commands: ")
(dun-minsert dun-numcmds)
(dun-minsert "\n")
(dun-minsertl " saves: " dun-numsaves " commands: " dun-numcmds)
(write-region 1 (point-max) dun-log-file nil 1)))))
......@@ -3118,19 +3096,19 @@ File not found")))
;;;; be run in batch mode.
(defun dun-batch-mprinc (arg)
(if (stringp arg)
(send-string-to-terminal arg)
(send-string-to-terminal (prin1-to-string arg))))
(defun dun-batch-mprinc (&rest args)
(dolist (arg args)
(if (stringp arg)
(send-string-to-terminal arg)
(send-string-to-terminal (prin1-to-string arg)))))
(defun dun-batch-mprincl (arg)
(if (stringp arg)
(progn
(send-string-to-terminal arg)
(send-string-to-terminal "\n"))
(send-string-to-terminal (prin1-to-string arg))
(send-string-to-terminal "\n")))
(defun dun-batch-mprincl (&rest args)
(dolist (arg args)
(if (stringp arg)
(send-string-to-terminal arg)
(send-string-to-terminal (prin1-to-string arg))))
(send-string-to-terminal "\n"))
(defun dun-batch-parse (ignore verblist line)
(setq line-list (dun-listify-string (concat line " ")))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment