diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 4b00977..7bd153f 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -7,7 +7,7 @@ ;;; date: 09/05/2015 ;;; -(defconstant ATLANTIS-VERSION '(0 1 5)) +(defconstant ATLANTIS-VERSION '(0 2 1)) (load "util.lisp") (load "game-objects.lisp") @@ -50,17 +50,23 @@ (setf options '("Start a new game" "Load a game" "Create worlds" "Develop" "About" "Exit")) (case (choose-number-option options) + ;;FIXME Present the player with a choice of saved games (0 (format t "~&What world file do you want to load?") (input-string world-file) + (setf world-file (concatenate 'string "../saves/" world-file)) + ;;FIXME Allowing only one player per world eliminates the need + ;; to ask for a player name (format t "~&What is your name?") (input-string name) (load-file world-file) (play-game name)) + ;;FIXME Present the player with a choice of game worlds (1 (format t "~&What game file do you want to load?") (input-string game) + (load-game game) + ;;FIXME Present the player with a choice of predefined characters (format t "~&What is your name?") (input-string name) - (load-game game) (play-game name)) (2 (world-creator)) (3 (development)) @@ -89,7 +95,6 @@ (format t "~A" help-text)) (defun parse-commandline-args () - ;; TODO clean this up? (should give error message with unknown params) (cond ((or (cmd-parameter "--version" T) (cmd-parameter "-v" T)) (print-version) (quit)) ((or (cmd-parameter "--help" T) (cmd-parameter "-h" T)) diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 4b00977..7bd153f 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -7,7 +7,7 @@ ;;; date: 09/05/2015 ;;; -(defconstant ATLANTIS-VERSION '(0 1 5)) +(defconstant ATLANTIS-VERSION '(0 2 1)) (load "util.lisp") (load "game-objects.lisp") @@ -50,17 +50,23 @@ (setf options '("Start a new game" "Load a game" "Create worlds" "Develop" "About" "Exit")) (case (choose-number-option options) + ;;FIXME Present the player with a choice of saved games (0 (format t "~&What world file do you want to load?") (input-string world-file) + (setf world-file (concatenate 'string "../saves/" world-file)) + ;;FIXME Allowing only one player per world eliminates the need + ;; to ask for a player name (format t "~&What is your name?") (input-string name) (load-file world-file) (play-game name)) + ;;FIXME Present the player with a choice of game worlds (1 (format t "~&What game file do you want to load?") (input-string game) + (load-game game) + ;;FIXME Present the player with a choice of predefined characters (format t "~&What is your name?") (input-string name) - (load-game game) (play-game name)) (2 (world-creator)) (3 (development)) @@ -89,7 +95,6 @@ (format t "~A" help-text)) (defun parse-commandline-args () - ;; TODO clean this up? (should give error message with unknown params) (cond ((or (cmd-parameter "--version" T) (cmd-parameter "-v" T)) (print-version) (quit)) ((or (cmd-parameter "--help" T) (cmd-parameter "-h" T)) diff --git a/lisp/banner.txt b/lisp/banner.txt index 68d8ee8..3c4a9f5 100644 --- a/lisp/banner.txt +++ b/lisp/banner.txt @@ -1,10 +1,10 @@ -==================================================== -|| \ / || -|| - O -MM _ MM ATLANTIS || -|| / \ ||_/.\_|| || -|| |*| |*| Lost worlds await || -|| ~~~~~| | A | |~~~~ || -|| ~~~~###########~~~ || -|| ~~~#############~~ (c) 2015 Daniel Vedder || -|| ~~~~~~~~~~~~~~~~~~ || -==================================================== +======================================================== +|| \ / || +|| - O - MM _ MM ATLANTIS || +|| / \ ||_/.\_|| || +|| |*| |*| Lost worlds await || +|| ~~~~~~| | A | |~~~~ || +|| ~~~~~###########~~~ || +|| ~~~~#############~~ (c) 2015-2017 Daniel Vedder || +|| ~~~~~~~~~~~~~~~~~~~ || +======================================================== diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 4b00977..7bd153f 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -7,7 +7,7 @@ ;;; date: 09/05/2015 ;;; -(defconstant ATLANTIS-VERSION '(0 1 5)) +(defconstant ATLANTIS-VERSION '(0 2 1)) (load "util.lisp") (load "game-objects.lisp") @@ -50,17 +50,23 @@ (setf options '("Start a new game" "Load a game" "Create worlds" "Develop" "About" "Exit")) (case (choose-number-option options) + ;;FIXME Present the player with a choice of saved games (0 (format t "~&What world file do you want to load?") (input-string world-file) + (setf world-file (concatenate 'string "../saves/" world-file)) + ;;FIXME Allowing only one player per world eliminates the need + ;; to ask for a player name (format t "~&What is your name?") (input-string name) (load-file world-file) (play-game name)) + ;;FIXME Present the player with a choice of game worlds (1 (format t "~&What game file do you want to load?") (input-string game) + (load-game game) + ;;FIXME Present the player with a choice of predefined characters (format t "~&What is your name?") (input-string name) - (load-game game) (play-game name)) (2 (world-creator)) (3 (development)) @@ -89,7 +95,6 @@ (format t "~A" help-text)) (defun parse-commandline-args () - ;; TODO clean this up? (should give error message with unknown params) (cond ((or (cmd-parameter "--version" T) (cmd-parameter "-v" T)) (print-version) (quit)) ((or (cmd-parameter "--help" T) (cmd-parameter "-h" T)) diff --git a/lisp/banner.txt b/lisp/banner.txt index 68d8ee8..3c4a9f5 100644 --- a/lisp/banner.txt +++ b/lisp/banner.txt @@ -1,10 +1,10 @@ -==================================================== -|| \ / || -|| - O -MM _ MM ATLANTIS || -|| / \ ||_/.\_|| || -|| |*| |*| Lost worlds await || -|| ~~~~~| | A | |~~~~ || -|| ~~~~###########~~~ || -|| ~~~#############~~ (c) 2015 Daniel Vedder || -|| ~~~~~~~~~~~~~~~~~~ || -==================================================== +======================================================== +|| \ / || +|| - O - MM _ MM ATLANTIS || +|| / \ ||_/.\_|| || +|| |*| |*| Lost worlds await || +|| ~~~~~~| | A | |~~~~ || +|| ~~~~~###########~~~ || +|| ~~~~#############~~ (c) 2015-2017 Daniel Vedder || +|| ~~~~~~~~~~~~~~~~~~~ || +======================================================== diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index d6eb54b..3204ccb 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -67,6 +67,7 @@ ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) + (trimmed-line (trim-whitespace line) (trim-whitespace line)) (current-object NIL)) ((= line-nr (length source)) NIL) ;; concatenate string arguments spanning several lines @@ -74,10 +75,10 @@ (incf line-nr) (setf line (concatenate 'string line (to-string #\Newline) (trim-whitespace (nth line-nr source))))) - (cond ((zerop (length line)) + (cond ((or (zerop (length trimmed-line)) (zerop (length line))) (when current-object (add-game-object current-object)) (setf current-object NIL)) - ((eql (aref line 0) #\;)) ;Comments are ignored + ((eql (aref trimmed-line 0) #\;)) ;Comments are ignored ;; interpret a define command ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) @@ -101,7 +102,7 @@ (2 (set-object-attribute current-object (first options) (second options))) ;; FIXME gives problems with lines like this: - ;; " ;commented" + ;; " ;commented" - should be fixed (t (error "~&ERROR: too many arguments: '~A'" line))))) (T ;; can't happen diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 4b00977..7bd153f 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -7,7 +7,7 @@ ;;; date: 09/05/2015 ;;; -(defconstant ATLANTIS-VERSION '(0 1 5)) +(defconstant ATLANTIS-VERSION '(0 2 1)) (load "util.lisp") (load "game-objects.lisp") @@ -50,17 +50,23 @@ (setf options '("Start a new game" "Load a game" "Create worlds" "Develop" "About" "Exit")) (case (choose-number-option options) + ;;FIXME Present the player with a choice of saved games (0 (format t "~&What world file do you want to load?") (input-string world-file) + (setf world-file (concatenate 'string "../saves/" world-file)) + ;;FIXME Allowing only one player per world eliminates the need + ;; to ask for a player name (format t "~&What is your name?") (input-string name) (load-file world-file) (play-game name)) + ;;FIXME Present the player with a choice of game worlds (1 (format t "~&What game file do you want to load?") (input-string game) + (load-game game) + ;;FIXME Present the player with a choice of predefined characters (format t "~&What is your name?") (input-string name) - (load-game game) (play-game name)) (2 (world-creator)) (3 (development)) @@ -89,7 +95,6 @@ (format t "~A" help-text)) (defun parse-commandline-args () - ;; TODO clean this up? (should give error message with unknown params) (cond ((or (cmd-parameter "--version" T) (cmd-parameter "-v" T)) (print-version) (quit)) ((or (cmd-parameter "--help" T) (cmd-parameter "-h" T)) diff --git a/lisp/banner.txt b/lisp/banner.txt index 68d8ee8..3c4a9f5 100644 --- a/lisp/banner.txt +++ b/lisp/banner.txt @@ -1,10 +1,10 @@ -==================================================== -|| \ / || -|| - O -MM _ MM ATLANTIS || -|| / \ ||_/.\_|| || -|| |*| |*| Lost worlds await || -|| ~~~~~| | A | |~~~~ || -|| ~~~~###########~~~ || -|| ~~~#############~~ (c) 2015 Daniel Vedder || -|| ~~~~~~~~~~~~~~~~~~ || -==================================================== +======================================================== +|| \ / || +|| - O - MM _ MM ATLANTIS || +|| / \ ||_/.\_|| || +|| |*| |*| Lost worlds await || +|| ~~~~~~| | A | |~~~~ || +|| ~~~~~###########~~~ || +|| ~~~~#############~~ (c) 2015-2017 Daniel Vedder || +|| ~~~~~~~~~~~~~~~~~~~ || +======================================================== diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index d6eb54b..3204ccb 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -67,6 +67,7 @@ ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) + (trimmed-line (trim-whitespace line) (trim-whitespace line)) (current-object NIL)) ((= line-nr (length source)) NIL) ;; concatenate string arguments spanning several lines @@ -74,10 +75,10 @@ (incf line-nr) (setf line (concatenate 'string line (to-string #\Newline) (trim-whitespace (nth line-nr source))))) - (cond ((zerop (length line)) + (cond ((or (zerop (length trimmed-line)) (zerop (length line))) (when current-object (add-game-object current-object)) (setf current-object NIL)) - ((eql (aref line 0) #\;)) ;Comments are ignored + ((eql (aref trimmed-line 0) #\;)) ;Comments are ignored ;; interpret a define command ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) @@ -101,7 +102,7 @@ (2 (set-object-attribute current-object (first options) (second options))) ;; FIXME gives problems with lines like this: - ;; " ;commented" + ;; " ;commented" - should be fixed (t (error "~&ERROR: too many arguments: '~A'" line))))) (T ;; can't happen diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 17af7de..bbb1fd8 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -19,6 +19,7 @@ (let ((player (get-game-object 'player player-name))) (clear-screen) ;; Initialize the player if necessary + ;; FIXME Shouldn't be necessary after the adjustment (unless player (setf player (create-player player-name)) (add-player player)) @@ -35,6 +36,7 @@ (defun create-player (player-name) "The user creates a new player" + ;; FIXME Remove this entirely. Game authors should define all playable characters. ;; TODO Rewrite this if possible ;; XXX This function feels somewhat ugly - any possibility of a cleanup? (let* ((start-player (get-game-object 'player "Start")) @@ -136,11 +138,11 @@ help - Show this list of game commands quit/exit - Exit the game clear - Clear the screen -place - Describe the current location +look [here] - Describe the current location player - Describe your player goto - Go to a neighbouring location -about - Show a description of this entity -talk to - Talk to an NPC +look - Show a description of this entity +talk [to] - Talk to an NPC pickup - Pick up an item lying around drop - Drop the item equip - Equip this item as your weapon @@ -198,6 +200,7 @@ ((not (or last-save game-file)) (format t "~&Where do you want to save the game?") (input-string game-file) + (setf game-file (concatenate 'string "../saves/" game-file)) (setf last-save game-file))) (when (y-or-n-p "Save game to ~A?" game-file) (save-world game-file) @@ -229,11 +232,11 @@ (add-player-experience player 1) (describe-place location)) -(defun about (player &optional object-name) +(defun look (player &optional object-name) "Print a description of this object" (unless object-name - (format t "~&Please specify the object you wish to inspect!") - (return-from about)) + (describe-place (player-place player)) + (return-from look)) ;; A bit of syntactic sugar... (cond ((equalp object-name "me") (player player) (return-from about)) ((equalp object-name "here") (place player) (return-from about))) diff --git a/ATL/Pooh/objects.atl b/ATL/Pooh/objects.atl index e69de29..3692a93 100644 --- a/ATL/Pooh/objects.atl +++ b/ATL/Pooh/objects.atl @@ -0,0 +1,7 @@ +; The 100 Acre Wood was invented by A.A. Milne for his Winnie-the-Pooh stories. +; This Atlantis world is based on the novels. +; +; This file holds item and NPC descriptions. +; +; author: Daniel Vedder +; date: 07/06/2017 diff --git a/ATL/Pooh/pooh.atl b/ATL/Pooh/pooh.atl index c77826d..302df84 100644 --- a/ATL/Pooh/pooh.atl +++ b/ATL/Pooh/pooh.atl @@ -16,4 +16,3 @@ place "Pooh's home" max-health 50 health 50 - diff --git a/ATL/Pooh/woods.atl b/ATL/Pooh/woods.atl index 3c16b69..291539a 100644 --- a/ATL/Pooh/woods.atl +++ b/ATL/Pooh/woods.atl @@ -12,6 +12,7 @@ delicious honey..." neighbour "Pooh's porch" neighbour "Pooh's branch" + neighbour "Western woods" item "Hunny" define-place "Pooh's porch" @@ -26,4 +27,14 @@ blustery day, Pooh had to escape to up here. Since then, he keeps an emergency ration of honey handy." neighbour "Pooh's home" - item "Hunny" \ No newline at end of file + item "Hunny" + +define-place "Western woods" + description "This is the western part of the 100 Acre Wood. As you would + expect in a wood, it is full of trees. Here, however, there are + not quite that many - mainly young birches." + neighbour "Pooh's porch" + neighbour "Central woods" + neighbour "Northern woods" + neighbour "Southern woods" + neighbour "Piglet's porch" \ No newline at end of file diff --git a/atlantis b/atlantis new file mode 100644 index 0000000..59176cb --- /dev/null +++ b/atlantis @@ -0,0 +1,5 @@ +#!/bin/bash +# Launch Atlantis. + +cd lisp +clisp atlantis.lisp diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index 4b00977..7bd153f 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -7,7 +7,7 @@ ;;; date: 09/05/2015 ;;; -(defconstant ATLANTIS-VERSION '(0 1 5)) +(defconstant ATLANTIS-VERSION '(0 2 1)) (load "util.lisp") (load "game-objects.lisp") @@ -50,17 +50,23 @@ (setf options '("Start a new game" "Load a game" "Create worlds" "Develop" "About" "Exit")) (case (choose-number-option options) + ;;FIXME Present the player with a choice of saved games (0 (format t "~&What world file do you want to load?") (input-string world-file) + (setf world-file (concatenate 'string "../saves/" world-file)) + ;;FIXME Allowing only one player per world eliminates the need + ;; to ask for a player name (format t "~&What is your name?") (input-string name) (load-file world-file) (play-game name)) + ;;FIXME Present the player with a choice of game worlds (1 (format t "~&What game file do you want to load?") (input-string game) + (load-game game) + ;;FIXME Present the player with a choice of predefined characters (format t "~&What is your name?") (input-string name) - (load-game game) (play-game name)) (2 (world-creator)) (3 (development)) @@ -89,7 +95,6 @@ (format t "~A" help-text)) (defun parse-commandline-args () - ;; TODO clean this up? (should give error message with unknown params) (cond ((or (cmd-parameter "--version" T) (cmd-parameter "-v" T)) (print-version) (quit)) ((or (cmd-parameter "--help" T) (cmd-parameter "-h" T)) diff --git a/lisp/banner.txt b/lisp/banner.txt index 68d8ee8..3c4a9f5 100644 --- a/lisp/banner.txt +++ b/lisp/banner.txt @@ -1,10 +1,10 @@ -==================================================== -|| \ / || -|| - O -MM _ MM ATLANTIS || -|| / \ ||_/.\_|| || -|| |*| |*| Lost worlds await || -|| ~~~~~| | A | |~~~~ || -|| ~~~~###########~~~ || -|| ~~~#############~~ (c) 2015 Daniel Vedder || -|| ~~~~~~~~~~~~~~~~~~ || -==================================================== +======================================================== +|| \ / || +|| - O - MM _ MM ATLANTIS || +|| / \ ||_/.\_|| || +|| |*| |*| Lost worlds await || +|| ~~~~~~| | A | |~~~~ || +|| ~~~~~###########~~~ || +|| ~~~~#############~~ (c) 2015-2017 Daniel Vedder || +|| ~~~~~~~~~~~~~~~~~~~ || +======================================================== diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index d6eb54b..3204ccb 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -67,6 +67,7 @@ ;; otherwise, parse the ATL file (do* ((line-nr 0 (1+ line-nr)) (source (load-text-file file-name)) (line (nth line-nr source) (nth line-nr source)) + (trimmed-line (trim-whitespace line) (trim-whitespace line)) (current-object NIL)) ((= line-nr (length source)) NIL) ;; concatenate string arguments spanning several lines @@ -74,10 +75,10 @@ (incf line-nr) (setf line (concatenate 'string line (to-string #\Newline) (trim-whitespace (nth line-nr source))))) - (cond ((zerop (length line)) + (cond ((or (zerop (length trimmed-line)) (zerop (length line))) (when current-object (add-game-object current-object)) (setf current-object NIL)) - ((eql (aref line 0) #\;)) ;Comments are ignored + ((eql (aref trimmed-line 0) #\;)) ;Comments are ignored ;; interpret a define command ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) @@ -101,7 +102,7 @@ (2 (set-object-attribute current-object (first options) (second options))) ;; FIXME gives problems with lines like this: - ;; " ;commented" + ;; " ;commented" - should be fixed (t (error "~&ERROR: too many arguments: '~A'" line))))) (T ;; can't happen diff --git a/lisp/ui.lisp b/lisp/ui.lisp index 17af7de..bbb1fd8 100644 --- a/lisp/ui.lisp +++ b/lisp/ui.lisp @@ -19,6 +19,7 @@ (let ((player (get-game-object 'player player-name))) (clear-screen) ;; Initialize the player if necessary + ;; FIXME Shouldn't be necessary after the adjustment (unless player (setf player (create-player player-name)) (add-player player)) @@ -35,6 +36,7 @@ (defun create-player (player-name) "The user creates a new player" + ;; FIXME Remove this entirely. Game authors should define all playable characters. ;; TODO Rewrite this if possible ;; XXX This function feels somewhat ugly - any possibility of a cleanup? (let* ((start-player (get-game-object 'player "Start")) @@ -136,11 +138,11 @@ help - Show this list of game commands quit/exit - Exit the game clear - Clear the screen -place - Describe the current location +look [here] - Describe the current location player - Describe your player goto - Go to a neighbouring location -about - Show a description of this entity -talk to - Talk to an NPC +look - Show a description of this entity +talk [to] - Talk to an NPC pickup - Pick up an item lying around drop - Drop the item equip - Equip this item as your weapon @@ -198,6 +200,7 @@ ((not (or last-save game-file)) (format t "~&Where do you want to save the game?") (input-string game-file) + (setf game-file (concatenate 'string "../saves/" game-file)) (setf last-save game-file))) (when (y-or-n-p "Save game to ~A?" game-file) (save-world game-file) @@ -229,11 +232,11 @@ (add-player-experience player 1) (describe-place location)) -(defun about (player &optional object-name) +(defun look (player &optional object-name) "Print a description of this object" (unless object-name - (format t "~&Please specify the object you wish to inspect!") - (return-from about)) + (describe-place (player-place player)) + (return-from look)) ;; A bit of syntactic sugar... (cond ((equalp object-name "me") (player player) (return-from about)) ((equalp object-name "here") (place player) (return-from about))) diff --git a/saves/lugwey.world b/saves/lugwey.world new file mode 100644 index 0000000..8081fc7 --- /dev/null +++ b/saves/lugwey.world @@ -0,0 +1,38 @@ +(0 1 4) +#S(WORLD :NAME "Lugwey" + :PLAYERS + (#S(PLAYER :NAME "Start" :RACE "" :CLASS "" :STRENGTH 0 :DEXTERITY 0 :CONSTITUTION 0 :INTELLIGENCE 0 :MONEY 50 :ITEM NIL :WEAPON "" :ARMOUR-CLASS 0 :PLACE "Gate" + :EXPERIENCE 0 :LEVEL 0 :MAX-HEALTH 50 :HEALTH 50 :GAME-ADMIN NIL) + #S(PLAYER :NAME "Leonardo" :RACE "Human" :CLASS "Scholar" :STRENGTH 0 :DEXTERITY 0 :CONSTITUTION 0 :INTELLIGENCE 0 :MONEY 60 :ITEM ("Dagger") :WEAPON "Dagger" + :ARMOUR-CLASS 0 :PLACE "Gate" :EXPERIENCE 0 :LEVEL 0 :MAX-HEALTH 50 :HEALTH 50 :GAME-ADMIN NIL)) + :CHARACTER-CLASSS (#S(CHARACTER-CLASS :NAME "Scholar" :DESCRIPTION "Dubio ergo corgito, corgito ergo sum" :SPECIAL-ITEM ("Paper" "Quill") :SPECIAL-ABILITY NIL)) + :RACES + (#S(RACE :NAME "Human" :DESCRIPTION "Errare humanum est" :STRENGTH-BONUS 0 :DEXTERITY-BONUS 0 :CONSTITUTION-BONUS 0 :INTELLIGENCE-BONUS 1 :SPECIAL-ABILITY NIL)) + :PLACES + (#S(PLACE :NAME "Gate" + :DESCRIPTION + "An old, partly moss-covered stone wall rises up in front of +you. Set in it, a wooden gate, reinforced with rusty iron strips. +One wing is open, permitting a view into the space beyond. +Behind you, the dusty track leads off into the forest. + +A monk is sitting in the gate house, obviously bored." + :NEIGHBOUR ("Forest track" "Monastery grounds") :PLAYER NIL :ITEM NIL :MONSTER NIL :NPC ("Gatekeeper")) + #S(PLACE :NAME "Monastery grounds" + :DESCRIPTION + "Paths criss-cross well-kept lawns. Here and there, roses bloom +in a flower bed. On one side stand the monastery buildings with +their calm, ancient dignity. On the other, the gardens, stables +and agricultural outhouses speak of a simple working life." + :NEIGHBOUR ("Gate" "Chapel" "Dormitory" "Gardens" "Stable") :PLAYER NIL :ITEM NIL :MONSTER NIL :NPC NIL) + #S(PLACE :NAME "Forest track" + :DESCRIPTION + "A rutted track, scarred by the wheels of many carts, leads +through the forest from the monastery to the village." + :NEIGHBOUR ("Gate") :PLAYER NIL :ITEM ("Signet ring") :MONSTER NIL :NPC NIL)) + :MONSTERS NIL :NPCS NIL + :ITEMS + (#S(ITEM :NAME "Parchment" :DESCRIPTION "Dried animal skins used as paper." :COST 5 :WEAPON "no" :FUNCTION NIL) + #S(ITEM :NAME "Quill" :DESCRIPTION "A goose-feather, sharpened at one end to make a pen." :COST 5 :WEAPON "no" :FUNCTION NIL) + #S(ITEM :NAME "Dagger" :DESCRIPTION "A long, sharp knife, useful for self defence." :COST 20 :WEAPON "Yes" :FUNCTION NIL)) + :WEAPONS (#S(WEAPON :NAME "Dagger" :DESCRIPTION "A long, sharp knife, useful for self defence." :TYPE "Knife" :DAMAGE 3)) :STARTING-PLACE "" :STARTING-MONEY 0)