Browse files

Small edits

Added bash shell scripts to the ignore file.
Rewrote all of the rooms.
Deleted a useless command.
Deleted a hack for the actual Telnet protocol. Just use Raw TCP from now on.
  • Loading branch information...
1 parent 53f3776 commit 897539457030a2bb49c0bb3a508b23301e2c4c3a @capnmidnight committed Sep 21, 2011
Showing with 43 additions and 30 deletions.
  1. +1 −0 .gitignore
  2. +6 −23 clients.rkt
  3. +36 −7 rooms.rkt
@@ -2,3 +2,4 @@ compiled/
@@ -32,14 +32,6 @@
(process-all-clients clients)
(remove-old-clients (accept-new-clients clients listener)))
-;; this will have to do different things depending on the type of terminal that connects
-(define (parse-name input)
- (DEBUG "parse-name" input)
- (and (not (eof-object? input))
- ;; this regexp is different from the next one because spaces in the first line of text are an issue with PuTTY that I haven't figured out how to solve yet.
- (let ([nlist (regexp-match #rx"[a-zA-Z0-9~!@#$%^&*()_=+{}|\\:;<,>.?/]+" input)])
- (and nlist (first nlist)))))
(define (send msg out)
(unless (port-closed? out)
(display msg out)
@@ -50,8 +42,7 @@
(DEBUG "recv" "reading...")
(define line (read-line in 'any))
(DEBUG "recv" line)
- (define match (regexp-match #rx"[a-zA-Z0-9 ~!@#$%^&*()_=+{}|\\:;<,>.?/]+" line))
- (and match (first match))))
+ line))
(define (print-prompt client)
(send (string-append (client-name client) " :> ") (client-out client)))
@@ -60,11 +51,11 @@
(define (connect-new-client listener)
(DEBUG "connect-new-client" "accepting new connection")
(define-values (in out) (tcp-accept listener))
- (send #"\e[1;31;41m" out)
+ (send #"\e[1;31m" out)
(send (regexp-replace* #rx"\n" (regexp-replace* #rx"\r\n" (call-with-input-file* "welcome.txt" port->string) "\n") "\r\n") out) ;; this little rigamorole is to correct for the bullshit newline situation between OS X and everybody else
(send #"\e[0m" out)
(let* ([input (read-line in 'any)]
- [name (parse-name input)] ;; try to parse the name, or fail if the user disconnected
+ [name (and (not (eof-object? input)) input)] ;; fail if the user disconnected
[new-client (and name (client in out name 0))]) ;; create the user with their name, or fail
(DEBUG "connect-new-client" "input" input)
(DEBUG "connect-new-client" "name recognized" name)
@@ -109,7 +100,7 @@
(DEBUG "process" "client" client)
(DEBUG "process" "line" line)
(let* ([parts (regexp-split #rx" " line)]
- [command (first parts)]
+ [command (string-downcase (first parts))]
[func (assoc command commands)]
[result (and func ((cdr func) client (rest parts) clients))])
(DEBUG "process" "parts" parts)
@@ -175,7 +166,7 @@
(define out (client-out client))
(cond [(= 1 (length parts))
(let* ([room-id (client-current-room-id client)]
- [dir (first parts)]
+ [dir (string-downcase (first parts))]
[new-room-id (get-room-exit-id room-id dir)])
(cond [(new-room-id . > . -1)
(set-client-current-room-id! client new-room-id)
@@ -195,10 +186,6 @@
(close-client client)
(format "~a has quit.\r\n" (client-name client)))
-(define (cmd-bad-word client parts clients)
- (send "Hey now, that was a bad word. Only I'm allowed to cuss here.\r\n" (client-out client))
- #f)
(define (cmd-say client parts clients)
(cond [(cons? parts)
(format "[~a]: \"~a\"\r\n" (client-name client) (string-join parts " "))]
@@ -219,12 +206,8 @@
(alias-move "down")
(alias-move "in")
(alias-move "out")
+ (alias-move "leave")
(cons "exit" cmd-quit)
(cons "quit" cmd-quit)
(cons "say" cmd-say)
- (cons "fuck" cmd-bad-word)
- (cons "shit" cmd-bad-word)
- (cons "damn" cmd-bad-word)
- (cons "dammit" cmd-bad-word)
- (cons "damnit" cmd-bad-word)
(cons "XXX_SHUTDOWN_XXX" cmd-shutdown-server)))
@@ -11,11 +11,37 @@
(struct room (name descrip exits))
;; this sucks, because there is way more data that we need still
-(define rooms (list (room "lobby" "You are in the lobby" '(("north" . 1) ("south" . 2)))
- (room "bathroom" "You have entered the bathroom" '(("south" . 0)))
- (room "elevator" "You are in the elevator, on the first floor" '(("north" . 0) ("up" . 3)))
- (room "floor 2" "You're on the second floor" '(("down" . 2) ("up" . 4)))
- (room "floor 3" "You're on the third floor" '(("down" . 2)))))
+(define rooms (list (room "Welcome"
+"Welcome to Philly MUD. There are a few things you can do here. Mostly, you can walk around. When you see a room description (like this one), there is a section at the bottom labelled EXITS. Just type the direction that it says a certain room is from you and you will go there. Be careful, directions aren't necessarily two-way; you could fall in a pit!
+There are other people here. You won't see any of them if you don't walk around, but if you type \"say\" (without the quotes) you can then type whatever you want and it will be announced to everyone else on the server. There's no way currently to tell a person something in private, so make sure you aren't sharing anything you wish to remain a secret.
+Other than that, I haven't implemented anything else yet. So, when you get bored, just type \"quit\" and you'll be disconnected. I would prefer it if you did that rather than hard-quitting out of your telnet client; it could potentially cause an error on the server that I haven't yet figured out how to fix.
+So, there you go. Once you exit here you won't get back. Later." '(("leave" . 1)))
+ (room "Hive76"
+"This is the main hall of Hive76. From here, you can see the great statues comemorating glorious battles fought against the great machines of the past. The disabled hulk of a Stratasys FDM 2000 stands in the corner, no longer echoing its banshee cry. In its shadow lies, an Epson 7600, mostly-but-not dead. A soft din of sounds from a long-dead era announce the presence of Midway Spy Hunter. Around the corner, the deceptively small MakerBot Cupcake CNC. All valiant foes. All vanquished at the hands of the Members of the Hive.
+Oh yeah, there's a bunch of ATmega8 litering the floor. Jack must have been here." '(("north" . 2) ("south" . 3)))
+ (room "Hall"
+"This is a hall. It's like many halls. It has doors that lead to other rooms. But most of those doors are locked. Don't you wish you could see what's inside?" '(("south" . 1) ("west" . 4)))
+ (room "The Great Banquet Hall"
+"Haha, right. There's no banquet hall here. Try going to Popeye's up the street." '(("north" . 1)))
+ (room "Elevator, 5th floor"
+"This elevator looks like the one in Diamonds Are Forever, where an assassin tries to kill James Bond, but James Bond manages to fight him off and stab him to death with a piece of broken glass. James then swaps his identity with the dead man. A woman finds them and searches the body to fall victim to James' ruse, believing he has just killed Mr. Bond, who is apparently the most famous secret spy in the entire world.
+This didn't happen here, it was just an awesome scene, so I thought I would share." '(("east" . 2) ("down" . 5)))
+ (room "Elevator, 4th floor"
+"There is no point in getting off here. The door to this floor is locked" '(("up" . 4) ("down" . 6)))
+ (room "Elevator, 3rd floor"
+"There is no point in getting off here. The door to this floor is also locked" '(("up" . 5) ("down" . 7)))
+ (room "Elevator, 2nd floor"
+"There is no... yeah, you get the point by now" '(("up" . 6) ("down" . 8)))
+ (room "Elevator, 1st floor"
+"You are on the ground floor, in the Elevator. You can't go further in to the building, as the door is locked, but you can go outside to the wonderful, magical world of Philadelphia!" '(("up" . 7) ("west" . 9)))
+ (room "Outside Hive76"
+"The sweet smell of paper, tumbleweeding through the street, wafts to your nose. Nope, wait, that's a hobo. Definitely hobo poop" '(("east" . 8)))))
;; returns an index into the rooms list on success, -1 on failure.
(define (get-room-exit-id id dir)
@@ -42,8 +68,11 @@
(when (id . < . (length rooms))
(define room (list-ref rooms id))
(when (room? room)
- (format "ROOM: ~a\r
-DESC: ~a\r
+ (format "
+ROOM: ~a\r

0 comments on commit 8975394

Please sign in to comment.