aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2017-02-20 21:00:32 -0500
committerMark Oteiza2017-02-20 21:00:32 -0500
commite91cc4e1e02645dbd0eb93141fda763a34f51dc8 (patch)
treecb503853181ff75405136e23bed97994b7f4dfa4
parent18c476956d552f2e6f833b74faa95c095c441541 (diff)
downloademacs-e91cc4e1e02645dbd0eb93141fda763a34f51dc8.tar.gz
emacs-e91cc4e1e02645dbd0eb93141fda763a34f51dc8.zip
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.
-rw-r--r--lisp/play/dunnet.el110
1 files changed, 44 insertions, 66 deletions
diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el
index d13c967dad5..801d14c833e 100644
--- a/lisp/play/dunnet.el
+++ b/lisp/play/dunnet.el
@@ -1156,7 +1156,7 @@ treasures for points?" "4" "four")
1156 (setq line (downcase (buffer-substring beg (point)))) 1156 (setq line (downcase (buffer-substring beg (point))))
1157 (princ line) 1157 (princ line)
1158 (if (eq (dun-vparse dun-ignore dun-verblist line) -1) 1158 (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
1159 (dun-mprinc "I don't understand that.\n"))) 1159 (dun-mprincl "I don't understand that.")))
1160 (goto-char (point-max)) 1160 (goto-char (point-max))
1161 (dun-mprinc "\n"))) 1161 (dun-mprinc "\n")))
1162 (dun-messages)) 1162 (dun-messages))
@@ -1200,8 +1200,7 @@ treasures for points?" "4" "four")
1200 (> room 0)) 1200 (> room 0))
1201 (not (string= dun-mode "long"))) 1201 (not (string= dun-mode "long")))
1202 nil 1202 nil
1203 (dun-mprinc (car (nth (abs room) dun-rooms))) 1203 (dun-mprincl (car (nth (abs room) dun-rooms))))
1204 (dun-mprinc "\n"))
1205 (when (and (not (string= dun-mode "long")) 1204 (when (and (not (string= dun-mode "long"))
1206 (not (member (abs room) dun-visited))) 1205 (not (member (abs room) dun-visited)))
1207 (setq dun-visited (append (list (abs room)) dun-visited))) 1206 (setq dun-visited (append (list (abs room)) dun-visited)))
@@ -1216,8 +1215,7 @@ treasures for points?" "4" "four")
1216 (when (and (= xobjs obj-jar) dun-jar) 1215 (when (and (= xobjs obj-jar) dun-jar)
1217 (dun-mprincl "The jar contains:") 1216 (dun-mprincl "The jar contains:")
1218 (dolist (x dun-jar) 1217 (dolist (x dun-jar)
1219 (dun-mprinc " ") 1218 (dun-mprincl " " (car (nth x dun-objects))))))
1220 (dun-mprincl (car (nth x dun-objects))))))
1221 (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus) 1219 (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
1222 (dun-mprincl "You are on the bus.")))) 1220 (dun-mprincl "You are on the bus."))))
1223 1221
@@ -1308,8 +1306,7 @@ disk bursts into flames, and disintegrates.")
1308;;; as we must also print what is in it. 1306;;; as we must also print what is in it.
1309 1307
1310(defun dun-inven (_args) 1308(defun dun-inven (_args)
1311 (dun-mprinc "You currently have:") 1309 (dun-mprincl "You currently have:")
1312 (dun-mprinc "\n")
1313 (dolist (curobj dun-inventory) 1310 (dolist (curobj dun-inventory)
1314 (if curobj 1311 (if curobj
1315 (progn 1312 (progn
@@ -1318,8 +1315,7 @@ disk bursts into flames, and disintegrates.")
1318 (progn 1315 (progn
1319 (dun-mprincl "The jar contains:") 1316 (dun-mprincl "The jar contains:")
1320 (dolist (x dun-jar) 1317 (dolist (x dun-jar)
1321 (dun-mprinc " ") 1318 (dun-mprincl " " (cadr (nth x dun-objects))))))))))
1322 (dun-mprincl (cadr (nth x dun-objects))))))))))
1323 1319
1324(defun dun-shake (obj) 1320(defun dun-shake (obj)
1325 (let ((objnum (dun-objnum-from-args-std obj))) 1321 (let ((objnum (dun-objnum-from-args-std obj)))
@@ -1327,10 +1323,8 @@ disk bursts into flames, and disintegrates.")
1327 (cond 1323 (cond
1328 ((member objnum dun-inventory) 1324 ((member objnum dun-inventory)
1329 ;; If shaking anything will do anything, put here. 1325 ;; If shaking anything will do anything, put here.
1330 (dun-mprinc "Shaking ") 1326 (dun-mprinc "Shaking " (downcase (cadr (nth objnum dun-objects))))
1331 (dun-mprinc (downcase (cadr (nth objnum dun-objects)))) 1327 (dun-mprincl " seems to have no effect."))
1332 (dun-mprinc " seems to have no effect.")
1333 (dun-mprinc "\n"))
1334 ((and (not (member objnum (nth dun-current-room dun-room-silents))) 1328 ((and (not (member objnum (nth dun-current-room dun-room-silents)))
1335 (not (member objnum (nth dun-current-room dun-room-objects)))) 1329 (not (member objnum (nth dun-current-room dun-room-objects))))
1336 (dun-mprincl "I don't see that here.")) 1330 (dun-mprincl "I don't see that here."))
@@ -1441,8 +1435,7 @@ For an explosive time, go to Fourth St. and Vermont.")
1441 (if (and (>= x 0) (not (= x obj-special))) 1435 (if (and (>= x 0) (not (= x obj-special)))
1442 (progn 1436 (progn
1443 (setq gotsome t) 1437 (setq gotsome t)
1444 (dun-mprinc (cadr (nth x dun-objects))) 1438 (dun-mprinc (cadr (nth x dun-objects)) ": ")
1445 (dun-mprinc ": ")
1446 (dun-take-object x)))) 1439 (dun-take-object x))))
1447 (if (not gotsome) 1440 (if (not gotsome)
1448 (dun-mprincl "Nothing to take.")))) 1441 (dun-mprincl "Nothing to take."))))
@@ -1688,7 +1681,7 @@ just try dropping it."))
1688 (if (or (not (car args)) 1681 (if (or (not (car args))
1689 (eq (dun-doverb dun-ignore dun-verblist (car args) 1682 (eq (dun-doverb dun-ignore dun-verblist (car args)
1690 (cdr (cdr args))) -1)) 1683 (cdr (cdr args))) -1))
1691 (dun-mprinc "I don't understand where you want me to go.\n"))) 1684 (dun-mprincl "I don't understand where you want me to go.")))
1692 1685
1693;;; Uses the dungeon-map to figure out where we are going. If the 1686;;; Uses the dungeon-map to figure out where we are going. If the
1694;;; requested direction yields 255, we know something special is 1687;;; requested direction yields 255, we know something special is
@@ -1708,7 +1701,7 @@ body.")
1708 (let (newroom) 1701 (let (newroom)
1709 (setq newroom (nth dir (nth dun-current-room dungeon-map))) 1702 (setq newroom (nth dir (nth dun-current-room dungeon-map)))
1710 (if (eq newroom -1) 1703 (if (eq newroom -1)
1711 (dun-mprinc "You can't go that way.\n") 1704 (dun-mprincl "You can't go that way.")
1712 (if (eq newroom 255) 1705 (if (eq newroom 255)
1713 (dun-special-move dir) 1706 (dun-special-move dir)
1714 (setq dun-room -1) 1707 (setq dun-room -1)
@@ -1931,9 +1924,7 @@ disk bursts into flames, and disintegrates.")
1931 (member objnum (nth dun-current-room dun-room-silents)))) 1924 (member objnum (nth dun-current-room dun-room-silents))))
1932 (dun-mprincl "I don't see that here.")) 1925 (dun-mprincl "I don't see that here."))
1933 ((not (member objnum (list obj-button obj-switch))) 1926 ((not (member objnum (list obj-button obj-switch)))
1934 (dun-mprinc "You can't ") 1927 (dun-mprincl "You can't " (car line-list) " that."))
1935 (dun-mprinc (car line-list))
1936 (dun-mprincl " that."))
1937 ((= objnum obj-button) 1928 ((= objnum obj-button)
1938 (dun-mprincl 1929 (dun-mprincl
1939"As you press the button, you notice a passageway open up, but 1930"As you press the button, you notice a passageway open up, but
@@ -1965,11 +1956,9 @@ to swim.")
1965 (if (not dun-endgame) 1956 (if (not dun-endgame)
1966 (let (total) 1957 (let (total)
1967 (setq total (dun-reg-score)) 1958 (setq total (dun-reg-score))
1968 (dun-mprinc "You have scored ") 1959 (dun-mprincl "You have scored " total " out of a possible 90 points.")
1969 (dun-mprinc total) 1960 total)
1970 (dun-mprincl " out of a possible 90 points.") total) 1961 (dun-mprinc "You have scored " (dun-endgame-score))
1971 (dun-mprinc "You have scored ")
1972 (dun-mprinc (dun-endgame-score))
1973 (dun-mprincl " endgame points out of a possible 110.") 1962 (dun-mprincl " endgame points out of a possible 110.")
1974 (if (= (dun-endgame-score) 110) 1963 (if (= (dun-endgame-score) 110)
1975 (dun-mprincl 1964 (dun-mprincl
@@ -2263,17 +2252,19 @@ for a moment, then straighten yourself up.
2263 2252
2264;;; Insert something into the window buffer 2253;;; Insert something into the window buffer
2265 2254
2266(defun dun-minsert (string) 2255(defun dun-minsert (&rest args)
2267 (if (stringp string) 2256 (dolist (arg args)
2268 (insert string) 2257 (if (stringp arg)
2269 (insert (prin1-to-string string)))) 2258 (insert arg)
2259 (insert (prin1-to-string arg)))))
2270 2260
2271;;; Print something out, in window mode 2261;;; Print something out, in window mode
2272 2262
2273(defun dun-mprinc (string) 2263(defun dun-mprinc (&rest args)
2274 (if (stringp string) 2264 (dolist (arg args)
2275 (insert string) 2265 (if (stringp arg)
2276 (insert (prin1-to-string string)))) 2266 (insert arg)
2267 (insert (prin1-to-string arg)))))
2277 2268
2278;;; In window mode, keep screen from jumping by keeping last line at 2269;;; In window mode, keep screen from jumping by keeping last line at
2279;;; the bottom of the screen. 2270;;; the bottom of the screen.
@@ -2286,14 +2277,14 @@ for a moment, then straighten yourself up.
2286 2277
2287;;; Insert something into the buffer, followed by newline. 2278;;; Insert something into the buffer, followed by newline.
2288 2279
2289(defun dun-minsertl (string) 2280(defun dun-minsertl (&rest args)
2290 (dun-minsert string) 2281 (apply #'dun-minsert args)
2291 (dun-minsert "\n")) 2282 (dun-minsert "\n"))
2292 2283
2293;;; Print something, followed by a newline. 2284;;; Print something, followed by a newline.
2294 2285
2295(defun dun-mprincl (string) 2286(defun dun-mprincl (&rest args)
2296 (dun-mprinc string) 2287 (apply #'dun-mprinc args)
2297 (dun-mprinc "\n")) 2288 (dun-mprinc "\n"))
2298 2289
2299;;; Function which will get an object number given the list of 2290;;; Function which will get an object number given the list of
@@ -3052,9 +3043,7 @@ File not found")))
3052 3043
3053(defun dun-save-val (varname) 3044(defun dun-save-val (varname)
3054 (let ((value (symbol-value (intern varname)))) 3045 (let ((value (symbol-value (intern varname))))
3055 (dun-minsert "(setq ") 3046 (dun-minsert "(setq " varname " ")
3056 (dun-minsert varname)
3057 (dun-minsert " ")
3058 (if (or (listp value) 3047 (if (or (listp value)
3059 (symbolp value)) 3048 (symbolp value))
3060 (dun-minsert "'")) 3049 (dun-minsert "'"))
@@ -3086,30 +3075,19 @@ File not found")))
3086 (dun-mprincl (error-message-string err)))) 3075 (dun-mprincl (error-message-string err))))
3087 (when (null ferror) 3076 (when (null ferror)
3088 (goto-char (point-max)) 3077 (goto-char (point-max))
3089 (dun-minsert (current-time-string)) 3078 (dun-minsert (current-time-string) " " (user-login-name) " ")
3090 (dun-minsert " ")
3091 (dun-minsert (user-login-name))
3092 (dun-minsert " ")
3093 (if (eq type 'save) 3079 (if (eq type 'save)
3094 (dun-minsert "saved ") 3080 (dun-minsert "saved ")
3095 (if (= (dun-endgame-score) 110) 3081 (if (= (dun-endgame-score) 110)
3096 (dun-minsert "won ") 3082 (dun-minsert "won ")
3097 (if (not how) 3083 (if (not how)
3098 (dun-minsert "quit ") 3084 (dun-minsert "quit ")
3099 (dun-minsert "killed by ") 3085 (dun-minsert "killed by " how " "))))
3100 (dun-minsert how) 3086 (dun-minsert "at " (cadr (nth (abs dun-room) dun-rooms)) ". score: ")
3101 (dun-minsert " "))))
3102 (dun-minsert "at ")
3103 (dun-minsert (cadr (nth (abs dun-room) dun-rooms)))
3104 (dun-minsert ". score: ")
3105 (if (> (dun-endgame-score) 0) 3087 (if (> (dun-endgame-score) 0)
3106 (dun-minsert (+ 90 (dun-endgame-score))) 3088 (dun-minsert (+ 90 (dun-endgame-score)))
3107 (dun-minsert (dun-reg-score))) 3089 (dun-minsert (dun-reg-score)))
3108 (dun-minsert " saves: ") 3090 (dun-minsertl " saves: " dun-numsaves " commands: " dun-numcmds)
3109 (dun-minsert dun-numsaves)
3110 (dun-minsert " commands: ")
3111 (dun-minsert dun-numcmds)
3112 (dun-minsert "\n")
3113 (write-region 1 (point-max) dun-log-file nil 1))))) 3091 (write-region 1 (point-max) dun-log-file nil 1)))))
3114 3092
3115 3093
@@ -3118,19 +3096,19 @@ File not found")))
3118;;;; be run in batch mode. 3096;;;; be run in batch mode.
3119 3097
3120 3098
3121(defun dun-batch-mprinc (arg) 3099(defun dun-batch-mprinc (&rest args)
3122 (if (stringp arg) 3100 (dolist (arg args)
3123 (send-string-to-terminal arg) 3101 (if (stringp arg)
3124 (send-string-to-terminal (prin1-to-string arg)))) 3102 (send-string-to-terminal arg)
3103 (send-string-to-terminal (prin1-to-string arg)))))
3125 3104
3126 3105
3127(defun dun-batch-mprincl (arg) 3106(defun dun-batch-mprincl (&rest args)
3128 (if (stringp arg) 3107 (dolist (arg args)
3129 (progn 3108 (if (stringp arg)
3130 (send-string-to-terminal arg) 3109 (send-string-to-terminal arg)
3131 (send-string-to-terminal "\n")) 3110 (send-string-to-terminal (prin1-to-string arg))))
3132 (send-string-to-terminal (prin1-to-string arg)) 3111 (send-string-to-terminal "\n"))
3133 (send-string-to-terminal "\n")))
3134 3112
3135(defun dun-batch-parse (ignore verblist line) 3113(defun dun-batch-parse (ignore verblist line)
3136 (setq line-list (dun-listify-string (concat line " "))) 3114 (setq line-list (dun-listify-string (concat line " ")))