Mercurial > emacs
comparison lisp/play/dunnet.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 0d8b17d428b5 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; dunnet.el --- text adventure for Emacs | 1 ;;; dunnet.el --- text adventure for Emacs |
2 | 2 |
3 ;; Copyright (C) 1992, 1993, 2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1992, 1993, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Ron Schnell <ronnie@driver-aces.com> | 6 ;; Author: Ron Schnell <ronnie@driver-aces.com> |
6 ;; Created: 25 Jul 1992 | 7 ;; Created: 25 Jul 1992 |
7 ;; Version: 2.01 | 8 ;; Version: 2.01 |
8 ;; Keywords: games | 9 ;; Keywords: games |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 ;; GNU General Public License for more details. | 21 ;; GNU General Public License for more details. |
21 | 22 |
22 ;; You should have received a copy of the GNU General Public License | 23 ;; You should have received a copy of the GNU General Public License |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02111-1307, USA. | 26 ;; Boston, MA 02110-1301, USA. |
26 | 27 |
27 ;;; Commentary: | 28 ;;; Commentary: |
28 | 29 |
29 ;; This game can be run in batch mode. To do this, use: | 30 ;; This game can be run in batch mode. To do this, use: |
30 ;; emacs -batch -l dunnet | 31 ;; emacs -batch -l dunnet |
51 (eval-when-compile | 52 (eval-when-compile |
52 (require 'cl)) | 53 (require 'cl)) |
53 | 54 |
54 ;;;; Mode definitions for interactive mode | 55 ;;;; Mode definitions for interactive mode |
55 | 56 |
56 (defun dun-mode () | 57 (define-derived-mode dun-mode text-mode "Dungeon" |
57 "Major mode for running dunnet." | 58 "Major mode for running dunnet." |
58 (interactive) | |
59 (text-mode) | |
60 (make-local-variable 'scroll-step) | 59 (make-local-variable 'scroll-step) |
61 (setq scroll-step 2) | 60 (setq scroll-step 2)) |
62 (use-local-map dungeon-mode-map) | |
63 (setq major-mode 'dun-mode) | |
64 (setq mode-name "Dungeon")) | |
65 | 61 |
66 (defun dun-parse (arg) | 62 (defun dun-parse (arg) |
67 "Function called when return is pressed in interactive mode to parse line." | 63 "Function called when return is pressed in interactive mode to parse line." |
68 (interactive "*p") | 64 (interactive "*p") |
69 (beginning-of-line) | 65 (beginning-of-line) |
1364 | 1360 |
1365 (setq dun-visited '(27)) | 1361 (setq dun-visited '(27)) |
1366 (setq dun-current-room 1) | 1362 (setq dun-current-room 1) |
1367 (setq dun-exitf nil) | 1363 (setq dun-exitf nil) |
1368 (setq dun-badcd nil) | 1364 (setq dun-badcd nil) |
1369 (defvar dungeon-mode-map nil) | 1365 (define-obsolete-variable-alias 'dungeon-mode-map 'dun-mode-map "22.1") |
1370 (setq dungeon-mode-map (make-sparse-keymap)) | 1366 (define-key dun-mode-map "\r" 'dun-parse) |
1371 (define-key dungeon-mode-map "\r" 'dun-parse) | |
1372 (defvar dungeon-batch-map (make-keymap)) | 1367 (defvar dungeon-batch-map (make-keymap)) |
1373 (if (string= (substring emacs-version 0 2) "18") | 1368 (if (string= (substring emacs-version 0 2) "18") |
1374 (let (n) | 1369 (let (n) |
1375 (setq n 32) | 1370 (setq n 32) |
1376 (while (< 0 (setq n (- n 1))) | 1371 (while (< 0 (setq n (- n 1))) |
2592 (defun dun-unix-interface () | 2587 (defun dun-unix-interface () |
2593 (dun-login) | 2588 (dun-login) |
2594 (if dun-logged-in | 2589 (if dun-logged-in |
2595 (progn | 2590 (progn |
2596 (setq dungeon-mode 'unix) | 2591 (setq dungeon-mode 'unix) |
2597 (define-key dungeon-mode-map "\r" 'dun-unix-parse) | 2592 (define-key dun-mode-map "\r" 'dun-unix-parse) |
2598 (dun-mprinc "$ ")))) | 2593 (dun-mprinc "$ ")))) |
2599 | 2594 |
2600 (defun dun-login () | 2595 (defun dun-login () |
2601 (let (tries username password) | 2596 (let (tries username password) |
2602 (setq tries 4) | 2597 (setq tries 4) |
2858 "Possible commands are:\nsend quit type ascii binary help")) | 2853 "Possible commands are:\nsend quit type ascii binary help")) |
2859 | 2854 |
2860 (defun dun-uexit (args) | 2855 (defun dun-uexit (args) |
2861 (setq dungeon-mode 'dungeon) | 2856 (setq dungeon-mode 'dungeon) |
2862 (dun-mprincl "\nYou step back from the console.") | 2857 (dun-mprincl "\nYou step back from the console.") |
2863 (define-key dungeon-mode-map "\r" 'dun-parse) | 2858 (define-key dun-mode-map "\r" 'dun-parse) |
2864 (if (not dun-batch-mode) | 2859 (if (not dun-batch-mode) |
2865 (dun-messages))) | 2860 (dun-messages))) |
2866 | 2861 |
2867 (defun dun-pwd (args) | 2862 (defun dun-pwd (args) |
2868 (dun-mprincl dun-cdpath)) | 2863 (dun-mprincl dun-cdpath)) |
3057 (dun-dos-prompt))))) | 3052 (dun-dos-prompt))))) |
3058 | 3053 |
3059 (defun dun-dos-interface () | 3054 (defun dun-dos-interface () |
3060 (dun-dos-boot-msg) | 3055 (dun-dos-boot-msg) |
3061 (setq dungeon-mode 'dos) | 3056 (setq dungeon-mode 'dos) |
3062 (define-key dungeon-mode-map "\r" 'dun-dos-parse) | 3057 (define-key dun-mode-map "\r" 'dun-dos-parse) |
3063 (dun-dos-prompt)) | 3058 (dun-dos-prompt)) |
3064 | 3059 |
3065 (defun dun-dos-type (args) | 3060 (defun dun-dos-type (args) |
3066 (sleep-for 2) | 3061 (sleep-for 2) |
3067 (if (setq args (car args)) | 3062 (if (setq args (car args)) |
3115 (dun-mprincl "Cannot spawn subshell")) | 3110 (dun-mprincl "Cannot spawn subshell")) |
3116 | 3111 |
3117 (defun dun-dos-exit (args) | 3112 (defun dun-dos-exit (args) |
3118 (setq dungeon-mode 'dungeon) | 3113 (setq dungeon-mode 'dungeon) |
3119 (dun-mprincl "\nYou power down the machine and step back.") | 3114 (dun-mprincl "\nYou power down the machine and step back.") |
3120 (define-key dungeon-mode-map "\r" 'dun-parse) | 3115 (define-key dun-mode-map "\r" 'dun-parse) |
3121 (if (not dun-batch-mode) | 3116 (if (not dun-batch-mode) |
3122 (dun-messages))) | 3117 (dun-messages))) |
3123 | 3118 |
3124 (defun dun-dos-no-disk () | 3119 (defun dun-dos-no-disk () |
3125 (sleep-for 3) | 3120 (sleep-for 3) |
3367 (setq dun-batch-mode t) | 3362 (setq dun-batch-mode t) |
3368 (dun-batch-loop)) | 3363 (dun-batch-loop)) |
3369 | 3364 |
3370 (provide 'dunnet) | 3365 (provide 'dunnet) |
3371 | 3366 |
3367 ;;; arch-tag: 4cc8e47c-d9e1-4ef4-936b-578e7f529558 | |
3372 ;;; dunnet.el ends here | 3368 ;;; dunnet.el ends here |