;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Welcome Sequence ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Interface ;;; Asks the player the three initial questions and return a list of the ;;; nickname symbol and the name string. ;;; (define (read-player-nick+name) ...) ;;; Greets a player. (defgeneric (greet player)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Implementation ;;; Initialization input section. ;;; Ask one of the *WHAT* questions. (define (*what* something) (define (read) (let ((result (read-inp-line))) (if (equal? result "") (read) result))) (echon "*WHAT* is" something "? ") (read)) ;;; Get a string for a player name. (define (read-player-string) (let ((string (*what* "your name"))) (if (equal? string "") (read-player-string) string))) (define (read-netid) (let* ((netid (*what* "your Cornell NetID (or another nickname)")) (symbol (match-input netid (list symbol?))) (directory (cornell-finger netid)) (info (lambda (s) (cond ((assq s directory) => second) (else #f))))) (cond ((and (list? directory) (not (empty? directory)) (not (memq (first symbol) (map (lambda (x) (first (nick x))) *players*)))) (list (as netid) ;; Get the first name (first (regexp-match "^[^ ]+" (info 'name))) ;; Get the last name (first (regexp-match "[^ ]+$" (info 'name))) ;; Get preferred nickname (info 'nickname) ;; Get the address (or (info 'local-address) (info 'campus-address)) ;; Get a phone number (or (info 'local-phone) (info 'campus-phone)) ;; Get project (info 'project))) ((not symbol) (echo "You must enter a symbol for a nickname.") (read-netid)) ((> (string-length (as (first symbol))) 8) (echo "You must use less than 8 characters.") (read-netid)) ((memq (first symbol) (map (lambda (x) (first (nick x))) (append *players* *characters*))) (echo "This nick name is already used, try another.") (read-netid)) (else (first symbol))))) ;;; Ever since you moved to ~a, you felt that something ~ ;;; bad will happen here... Then, one day you tell ~ ;;; yourself: \"Well ~a, something bad is going to happen ~ ;;; today or my name isn't ~a\".~%" ;;; Return a list of nick name and name for a player. (define (read-player-nick+name) (echo) (echo) (echo "Welcome, you are expected. You will feel much obliged") (echo "to my employer, for the use of an alias...") (echo) (let ((info (read-netid))) ;; got the information from Cornell directory server (cond ((list? info) info) ;; need to get the player's name ((symbol? info) (list info (read-player-string)))))) ;;; Specialize the greeting for different types of players (defmethod (greet (p )) (tell p "") (tell p "") (tell p "") (tell p "") (tell p (echos-ns "Ever since starting CS212, you've said to " "yourself, \"" (name p) ", I can't wait to " "play that game.\"")) (tell p "") (tell p "") (tell p "") (tell p " CLUE") (tell p "") (tell p " It was a Dark and Stormy Night...") (tell p "") (tell p (echos "...and all through Upson Hall was the feeling of both" "anticipation and apprehension. The Evil Empire's Maximum" "Leader, Gates, has come to Cornell to demonstrate the" "latest Window Panes technology in Microsoft's most recent" "operating system. His Billness arrived in Upson lobby to" "both the cheers and derision of the crowd.")) (tell p "") (tell p (echos "The power goes out... The power comes back on... Bill Gates" "is missing. The suspicion is that he was murdered. Who did" "it, where was it done, and with what? Everyone has had" "Windows crash and lost important data. Everyone's a" "suspect.")) (tell p "") (tell p "") (get-player-input p "Press return to continue... ") (tell p "") (tell p "") (tell p " Type 'help' for instructions on the game.") (tell p "") (tell p ""))