diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 800f1eb..c05a4d6 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -21,4 +21,7 @@ strength 1 dexterity 4 constitution 4 - \ No newline at end of file + +define-player "Christopher Robin" + description "Just debugging..." + ;place "Christopher Robin's house" \ No newline at end of file diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 800f1eb..c05a4d6 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -21,4 +21,7 @@ strength 1 dexterity 4 constitution 4 - \ No newline at end of file + +define-player "Christopher Robin" + description "Just debugging..." + ;place "Christopher Robin's house" \ No newline at end of file diff --git a/doc/TODO b/doc/TODO index c8e37b6..f11195d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,7 +1,7 @@ ATLANTIS TODO * fill in missing place descriptions -* hide 5 more pots of honey +* hide 4 more pots of honey * require XP minimum to finish game? * think of more quests * integrate the quests to lead the player through the game diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 800f1eb..c05a4d6 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -21,4 +21,7 @@ strength 1 dexterity 4 constitution 4 - \ No newline at end of file + +define-player "Christopher Robin" + description "Just debugging..." + ;place "Christopher Robin's house" \ No newline at end of file diff --git a/doc/TODO b/doc/TODO index c8e37b6..f11195d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,7 +1,7 @@ ATLANTIS TODO * fill in missing place descriptions -* hide 5 more pots of honey +* hide 4 more pots of honey * require XP minimum to finish game? * think of more quests * integrate the quests to lead the player through the game diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 658f312..e18346a 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -25,20 +25,6 @@ ("Winnie the Pooh" "Pooh/pooh.atl") ("Development" "dev/test.atl"))) -(defun development () - "A method to easily test whatever feature I am currently developing" - (setf *debugging* T) - (load-file "../ATL/test/lisp-test.atl") - (let ((player (make-player :name "Bilbo" - :place "Fields of Punishment" - :strength 6 :constitution 12 - :dexterity 19 :intelligence 14 - :money 100 - :item '("Anaklusmos" "Lightning bolt") - :weapon "Lightning bolt"))) - (add-player player) - (play-game (player-name player)))) - (defun print-version () (format t "~&Atlantis ~A.~A.~A" (first ATLANTIS-VERSION) @@ -53,7 +39,7 @@ (print-text-file "banner.txt") (format t "~&~%Welcome! What do you want to do?") (setf options '("Start a new game" "Load a game" - "Create worlds" "Develop" "About" "Exit")) + "Create worlds" "About" "Exit")) (case (choose-number-option options) (0 (format t "~&Which world do you want to play?") ;; let the player choose one of the game worlds @@ -67,10 +53,11 @@ (setf world-file (concatenate 'string "../ATL/" world-file)) (load-file world-file) ;; let the player choose a character - (format t "~&Which character do you want to play?") - (let* ((char-nr (choose-number-option - (list-world-objects 'player))) - (char-name (nth char-nr (list-world-objects 'player)))) + (let* ((chars (list-world-objects 'player)) + (char-name (first chars))) + (when (< 1 (length chars)) + (format t "~&Which character do you want to play?") + (setf char-name (choose-option chars))) (set-main-player char-name) (play-game)))) (1 (format t "~&What game file do you want to load?") @@ -80,11 +67,10 @@ (load-game game) (play-game))) (2 (world-creator)) - (3 (development)) ;; XXX Remove this - (4 (print-version) + (3 (print-version) (read-line) (start-menu)) - (5 (format t "~&Goodbye!") + (4 (format t "~&Goodbye!") (quit)))) (defun cmd-parameter (name &optional truth-value) diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 800f1eb..c05a4d6 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -21,4 +21,7 @@ strength 1 dexterity 4 constitution 4 - \ No newline at end of file + +define-player "Christopher Robin" + description "Just debugging..." + ;place "Christopher Robin's house" \ No newline at end of file diff --git a/doc/TODO b/doc/TODO index c8e37b6..f11195d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,7 +1,7 @@ ATLANTIS TODO * fill in missing place descriptions -* hide 5 more pots of honey +* hide 4 more pots of honey * require XP minimum to finish game? * think of more quests * integrate the quests to lead the player through the game diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 658f312..e18346a 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -25,20 +25,6 @@ ("Winnie the Pooh" "Pooh/pooh.atl") ("Development" "dev/test.atl"))) -(defun development () - "A method to easily test whatever feature I am currently developing" - (setf *debugging* T) - (load-file "../ATL/test/lisp-test.atl") - (let ((player (make-player :name "Bilbo" - :place "Fields of Punishment" - :strength 6 :constitution 12 - :dexterity 19 :intelligence 14 - :money 100 - :item '("Anaklusmos" "Lightning bolt") - :weapon "Lightning bolt"))) - (add-player player) - (play-game (player-name player)))) - (defun print-version () (format t "~&Atlantis ~A.~A.~A" (first ATLANTIS-VERSION) @@ -53,7 +39,7 @@ (print-text-file "banner.txt") (format t "~&~%Welcome! What do you want to do?") (setf options '("Start a new game" "Load a game" - "Create worlds" "Develop" "About" "Exit")) + "Create worlds" "About" "Exit")) (case (choose-number-option options) (0 (format t "~&Which world do you want to play?") ;; let the player choose one of the game worlds @@ -67,10 +53,11 @@ (setf world-file (concatenate 'string "../ATL/" world-file)) (load-file world-file) ;; let the player choose a character - (format t "~&Which character do you want to play?") - (let* ((char-nr (choose-number-option - (list-world-objects 'player))) - (char-name (nth char-nr (list-world-objects 'player)))) + (let* ((chars (list-world-objects 'player)) + (char-name (first chars))) + (when (< 1 (length chars)) + (format t "~&Which character do you want to play?") + (setf char-name (choose-option chars))) (set-main-player char-name) (play-game)))) (1 (format t "~&What game file do you want to load?") @@ -80,11 +67,10 @@ (load-game game) (play-game))) (2 (world-creator)) - (3 (development)) ;; XXX Remove this - (4 (print-version) + (3 (print-version) (read-line) (start-menu)) - (5 (format t "~&Goodbye!") + (4 (format t "~&Goodbye!") (quit)))) (defun cmd-parameter (name &optional truth-value) diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 5030149..9e01fab 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -18,13 +18,20 @@ (defun play-game () "The main game loop" (let ((player (get-game-object 'player (world-main-player *world*)))) + ;; If the player's starting position is not specified, choose at random + (when (zerop (length (player-place player))) + (format t "~&Choosing a random starting location.") + (setf (player-place player) + (random-elt (list-world-objects 'place)))) ;; The actual game loop (clear-screen) (let ((place (get-game-object 'place (player-place player)))) (describe-place place) (input-string command) - ;; TODO Ask for confirmation before quitting - (while (not (or (equalp command "quit") (equalp command "exit"))) + ;; TODO Tidy up the exit process + (while (not (and (or (equalp command "quit") + (equalp command "exit")) + (y-or-n-p "~&Really quit?"))) (game-command command player) (input-string command)) (format t "~&Goodbye!")))) @@ -44,6 +51,33 @@ (when (place-command p) (format t "~&Commands: ~A" (string-from-list (place-command p))))) +(defun describe-player (p) + "Print a description of this player" + (let ((tab (string #\tab))) + (when (stringp p) (setf p (get-game-object 'player p))) + (format t "~&~A~%~%~A" + (string-upcase (player-name p)) (player-description p)) + (format t "~&~%Current place: ~A" (player-place p)) + (format t "~&=====~&Attributes:") + (format t "~&Intelligence: ~A~AStrength: ~A" + (player-intelligence p) tab (player-strength p)) + (format t "~&Constitution: ~A~ADexterity: ~A" + (player-constitution p) tab (player-dexterity p)) + (format t "~&=====~&Abilities:~&~A" + (let ((abilities (player-ability p))) + (dolist (i (player-item p) (string-from-list abilities)) + (let ((ia (item-ability (get-game-object 'item i)))) + (when ia (setf abilities (append abilities ia))))))) + (format t "~&=====") + (format t "~&Weapon: ~A" (player-weapon p)) + ;; XXX This will need adjusting for large item numbers + (format t "~&Items: ~A" (string-from-list (player-item p))) + (format t "~&=====") + (format t "~&Max health: ~A~ACurrent health: ~A" + (player-max-health p) tab (player-health p)) + (format t "~&Experience: ~A~AMoney: ~A" + (player-experience p) tab (player-money p)))) + (defun game-command (cmd player) "Execute a typed-in game command" (let* ((command (read-from-string cmd)) @@ -74,10 +108,10 @@ ;; A list of all in-game commands. Each new command must be registered here. (defvar *commands* - '(help player goto take + '(help look goto take drop talk trade - equip attack spell - look search save clear)) + equip attack searc + save clear)) ;;; The following commands don't take any arguments except for a player @@ -89,16 +123,19 @@ quit/exit - Exit the game clear - Clear the screen look [here] - Describe the current location -search - Search for hidden items -player - Describe your player -goto - Go to a neighbouring location +look me - Describe your character look - Show a description of this entity +search - Search for hidden items +goto - Go to a neighbouring location talk [to] - Talk to an NPC take - Pick up an item lying around drop - Drop the item equip - Equip this item as your weapon attack - Fight a monster -save - Save the game to file +save [] - Save the game to file + +Arguments in square brackets are optional, +arguments in angular brackets denote place fillers. Some places and items may provide additional commands.") (format t "~A" help-text)) @@ -108,40 +145,6 @@ (clear-screen) (place player)) -;; XXX Will the following two functions give problems? (Their name is -;; identical with the struct name) Probably not, but best to be aware. -(defun place (player) - "Describe the player's current location (wrapper function)" - (describe-place (player-place player))) - -(defun player (p) - "Print a description of this player" - ;; TODO update - (let ((tab (string #\tab))) - (when (stringp p) (setf p (get-game-object 'player p))) - (format t "~&~A~%~%~A" - (string-upcase (player-name p)) (player-description p)) - (format t "~&~%Current place: ~A" (player-place p)) - (format t "~&=====~&Attributes:") - (format t "~&Intelligence: ~A~AStrength: ~A" - (player-intelligence p) tab (player-strength p)) - (format t "~&Constitution: ~A~ADexterity: ~A" - (player-constitution p) tab (player-dexterity p)) - (format t "~&=====~&Abilities:~&~A" - (let ((abilities (player-ability p))) - (dolist (i (player-item p) (string-from-list abilities)) - (let ((ia (item-ability (get-game-object 'item i)))) - (when ia (setf abilities (append abilities ia))))))) - (format t "~&=====") - (format t "~&Weapon: ~A" (player-weapon p)) - ;; XXX This will need adjusting for large item numbers - (format t "~&Items: ~A" (string-from-list (player-item p))) - (format t "~&=====") - (format t "~&Max health: ~A~ACurrent health: ~A" - (player-max-health p) tab (player-health p)) - (format t "~&Experience: ~A~AMoney: ~A" - (player-experience p) tab (player-money p)))) - ;;; These next functions have to take two arguments (the argument ;;; to the function and a player instance). @@ -200,12 +203,12 @@ (defun look (player &optional object-name) "Print a description of this object" - (unless object-name - (place player) - (return-from look)) + (unless object-name (setf object-name "here")) ;; A bit of syntactic sugar... - (cond ((equalp object-name "me") (player player) (return-from look)) - ((equalp object-name "here") (place player) (return-from look))) + (cond ((equalp object-name "me") + (describe-player player) (return-from look)) + ((equalp object-name "here") + (describe-place (player-place player)) (return-from look))) (let ((description (get-object-description object-name (player-place player)))) ;; Don't forget items the player is carrying diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index 800f1eb..c05a4d6 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -21,4 +21,7 @@ strength 1 dexterity 4 constitution 4 - \ No newline at end of file + +define-player "Christopher Robin" + description "Just debugging..." + ;place "Christopher Robin's house" \ No newline at end of file diff --git a/doc/TODO b/doc/TODO index c8e37b6..f11195d 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,7 +1,7 @@ ATLANTIS TODO * fill in missing place descriptions -* hide 5 more pots of honey +* hide 4 more pots of honey * require XP minimum to finish game? * think of more quests * integrate the quests to lead the player through the game diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 658f312..e18346a 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -25,20 +25,6 @@ ("Winnie the Pooh" "Pooh/pooh.atl") ("Development" "dev/test.atl"))) -(defun development () - "A method to easily test whatever feature I am currently developing" - (setf *debugging* T) - (load-file "../ATL/test/lisp-test.atl") - (let ((player (make-player :name "Bilbo" - :place "Fields of Punishment" - :strength 6 :constitution 12 - :dexterity 19 :intelligence 14 - :money 100 - :item '("Anaklusmos" "Lightning bolt") - :weapon "Lightning bolt"))) - (add-player player) - (play-game (player-name player)))) - (defun print-version () (format t "~&Atlantis ~A.~A.~A" (first ATLANTIS-VERSION) @@ -53,7 +39,7 @@ (print-text-file "banner.txt") (format t "~&~%Welcome! What do you want to do?") (setf options '("Start a new game" "Load a game" - "Create worlds" "Develop" "About" "Exit")) + "Create worlds" "About" "Exit")) (case (choose-number-option options) (0 (format t "~&Which world do you want to play?") ;; let the player choose one of the game worlds @@ -67,10 +53,11 @@ (setf world-file (concatenate 'string "../ATL/" world-file)) (load-file world-file) ;; let the player choose a character - (format t "~&Which character do you want to play?") - (let* ((char-nr (choose-number-option - (list-world-objects 'player))) - (char-name (nth char-nr (list-world-objects 'player)))) + (let* ((chars (list-world-objects 'player)) + (char-name (first chars))) + (when (< 1 (length chars)) + (format t "~&Which character do you want to play?") + (setf char-name (choose-option chars))) (set-main-player char-name) (play-game)))) (1 (format t "~&What game file do you want to load?") @@ -80,11 +67,10 @@ (load-game game) (play-game))) (2 (world-creator)) - (3 (development)) ;; XXX Remove this - (4 (print-version) + (3 (print-version) (read-line) (start-menu)) - (5 (format t "~&Goodbye!") + (4 (format t "~&Goodbye!") (quit)))) (defun cmd-parameter (name &optional truth-value) diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 5030149..9e01fab 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -18,13 +18,20 @@ (defun play-game () "The main game loop" (let ((player (get-game-object 'player (world-main-player *world*)))) + ;; If the player's starting position is not specified, choose at random + (when (zerop (length (player-place player))) + (format t "~&Choosing a random starting location.") + (setf (player-place player) + (random-elt (list-world-objects 'place)))) ;; The actual game loop (clear-screen) (let ((place (get-game-object 'place (player-place player)))) (describe-place place) (input-string command) - ;; TODO Ask for confirmation before quitting - (while (not (or (equalp command "quit") (equalp command "exit"))) + ;; TODO Tidy up the exit process + (while (not (and (or (equalp command "quit") + (equalp command "exit")) + (y-or-n-p "~&Really quit?"))) (game-command command player) (input-string command)) (format t "~&Goodbye!")))) @@ -44,6 +51,33 @@ (when (place-command p) (format t "~&Commands: ~A" (string-from-list (place-command p))))) +(defun describe-player (p) + "Print a description of this player" + (let ((tab (string #\tab))) + (when (stringp p) (setf p (get-game-object 'player p))) + (format t "~&~A~%~%~A" + (string-upcase (player-name p)) (player-description p)) + (format t "~&~%Current place: ~A" (player-place p)) + (format t "~&=====~&Attributes:") + (format t "~&Intelligence: ~A~AStrength: ~A" + (player-intelligence p) tab (player-strength p)) + (format t "~&Constitution: ~A~ADexterity: ~A" + (player-constitution p) tab (player-dexterity p)) + (format t "~&=====~&Abilities:~&~A" + (let ((abilities (player-ability p))) + (dolist (i (player-item p) (string-from-list abilities)) + (let ((ia (item-ability (get-game-object 'item i)))) + (when ia (setf abilities (append abilities ia))))))) + (format t "~&=====") + (format t "~&Weapon: ~A" (player-weapon p)) + ;; XXX This will need adjusting for large item numbers + (format t "~&Items: ~A" (string-from-list (player-item p))) + (format t "~&=====") + (format t "~&Max health: ~A~ACurrent health: ~A" + (player-max-health p) tab (player-health p)) + (format t "~&Experience: ~A~AMoney: ~A" + (player-experience p) tab (player-money p)))) + (defun game-command (cmd player) "Execute a typed-in game command" (let* ((command (read-from-string cmd)) @@ -74,10 +108,10 @@ ;; A list of all in-game commands. Each new command must be registered here. (defvar *commands* - '(help player goto take + '(help look goto take drop talk trade - equip attack spell - look search save clear)) + equip attack searc + save clear)) ;;; The following commands don't take any arguments except for a player @@ -89,16 +123,19 @@ quit/exit - Exit the game clear - Clear the screen look [here] - Describe the current location -search - Search for hidden items -player - Describe your player -goto - Go to a neighbouring location +look me - Describe your character look - Show a description of this entity +search - Search for hidden items +goto - Go to a neighbouring location talk [to] - Talk to an NPC take - Pick up an item lying around drop - Drop the item equip - Equip this item as your weapon attack - Fight a monster -save - Save the game to file +save [] - Save the game to file + +Arguments in square brackets are optional, +arguments in angular brackets denote place fillers. Some places and items may provide additional commands.") (format t "~A" help-text)) @@ -108,40 +145,6 @@ (clear-screen) (place player)) -;; XXX Will the following two functions give problems? (Their name is -;; identical with the struct name) Probably not, but best to be aware. -(defun place (player) - "Describe the player's current location (wrapper function)" - (describe-place (player-place player))) - -(defun player (p) - "Print a description of this player" - ;; TODO update - (let ((tab (string #\tab))) - (when (stringp p) (setf p (get-game-object 'player p))) - (format t "~&~A~%~%~A" - (string-upcase (player-name p)) (player-description p)) - (format t "~&~%Current place: ~A" (player-place p)) - (format t "~&=====~&Attributes:") - (format t "~&Intelligence: ~A~AStrength: ~A" - (player-intelligence p) tab (player-strength p)) - (format t "~&Constitution: ~A~ADexterity: ~A" - (player-constitution p) tab (player-dexterity p)) - (format t "~&=====~&Abilities:~&~A" - (let ((abilities (player-ability p))) - (dolist (i (player-item p) (string-from-list abilities)) - (let ((ia (item-ability (get-game-object 'item i)))) - (when ia (setf abilities (append abilities ia))))))) - (format t "~&=====") - (format t "~&Weapon: ~A" (player-weapon p)) - ;; XXX This will need adjusting for large item numbers - (format t "~&Items: ~A" (string-from-list (player-item p))) - (format t "~&=====") - (format t "~&Max health: ~A~ACurrent health: ~A" - (player-max-health p) tab (player-health p)) - (format t "~&Experience: ~A~AMoney: ~A" - (player-experience p) tab (player-money p)))) - ;;; These next functions have to take two arguments (the argument ;;; to the function and a player instance). @@ -200,12 +203,12 @@ (defun look (player &optional object-name) "Print a description of this object" - (unless object-name - (place player) - (return-from look)) + (unless object-name (setf object-name "here")) ;; A bit of syntactic sugar... - (cond ((equalp object-name "me") (player player) (return-from look)) - ((equalp object-name "here") (place player) (return-from look))) + (cond ((equalp object-name "me") + (describe-player player) (return-from look)) + ((equalp object-name "here") + (describe-place (player-place player)) (return-from look))) (let ((description (get-object-description object-name (player-place player)))) ;; Don't forget items the player is carrying diff --git a/lisp/util.lisp b/lisp/util.lisp index 0de81ba..cbf30cf 100644 --- a/lisp/util.lisp +++ b/lisp/util.lisp @@ -52,7 +52,7 @@ `(progn (format t "~&>>> ") (set-list (read) ,@vars) - (magic (first (list ,@vars))) + (magic (first (list ,@vars))) ;;TODO Remove this again (first (list ,@vars)))) (defmacro input-string (&optional (var (gensym))) @@ -60,7 +60,7 @@ `(progn (format t "~&>>> ") (setf ,var (read-line)) - (magic (read-from-string ,var)) + (magic (read-from-string ,var)) ;;TODO Remove this again ,var)) (defmacro while (condition &body body)