diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 990bcbc..e8e0faf 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -19,8 +19,10 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + monster "Fury" load-file lisp-test.atl ;Testing whether recursive loading is prevented load-file races-classes.atl +load-file game-objects.atl start-place "Nowhere" \ No newline at end of file diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 990bcbc..e8e0faf 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -19,8 +19,10 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + monster "Fury" load-file lisp-test.atl ;Testing whether recursive loading is prevented load-file races-classes.atl +load-file game-objects.atl start-place "Nowhere" \ No newline at end of file diff --git a/lisp/client.lisp b/lisp/client.lisp index 0710804..ae72ff7 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -98,7 +98,8 @@ (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) (format t "~&Players present: ~A" (string-from-list (place-player p))) (format t "~&Items: ~A" (string-from-list (place-item p))) - (format t "~&NPCs: ~A" (string-from-list (place-npc p)))) + (format t "~&NPCs: ~A" (string-from-list (place-npc p))) + (format t "~&Monsters: ~A" (string-from-list (place-monster p)))) (defun game-command (cmd player) "Execute a typed-in game command" @@ -108,7 +109,8 @@ (if (member command *commands*) (if space (funcall command player arg) (funcall command player)) - (format t "~&Sorry, this command does not exist!")))) + (progn (format t "~&Sorry, this command does not exist!") + (format t "~&Type 'help' for a list of commands."))))) ;;; diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 990bcbc..e8e0faf 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -19,8 +19,10 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + monster "Fury" load-file lisp-test.atl ;Testing whether recursive loading is prevented load-file races-classes.atl +load-file game-objects.atl start-place "Nowhere" \ No newline at end of file diff --git a/lisp/client.lisp b/lisp/client.lisp index 0710804..ae72ff7 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -98,7 +98,8 @@ (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) (format t "~&Players present: ~A" (string-from-list (place-player p))) (format t "~&Items: ~A" (string-from-list (place-item p))) - (format t "~&NPCs: ~A" (string-from-list (place-npc p)))) + (format t "~&NPCs: ~A" (string-from-list (place-npc p))) + (format t "~&Monsters: ~A" (string-from-list (place-monster p)))) (defun game-command (cmd player) "Execute a typed-in game command" @@ -108,7 +109,8 @@ (if (member command *commands*) (if space (funcall command player arg) (funcall command player)) - (format t "~&Sorry, this command does not exist!")))) + (progn (format t "~&Sorry, this command does not exist!") + (format t "~&Type 'help' for a list of commands."))))) ;;; diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 104884f..add4f71 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -24,24 +24,27 @@ (defstruct npc (name "") + (description "") (says "")) (defstruct monster (name "") (description "") (strength 0) + (aggression 0) + (weapon "") (armour-class 0)) (defstruct item (name "") (description "") + (weapon "") (function NIL)) (defstruct weapon (name "") (description "") (ranged NIL) - (condition 10) (damage 0)) diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 990bcbc..e8e0faf 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -19,8 +19,10 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + monster "Fury" load-file lisp-test.atl ;Testing whether recursive loading is prevented load-file races-classes.atl +load-file game-objects.atl start-place "Nowhere" \ No newline at end of file diff --git a/lisp/client.lisp b/lisp/client.lisp index 0710804..ae72ff7 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -98,7 +98,8 @@ (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) (format t "~&Players present: ~A" (string-from-list (place-player p))) (format t "~&Items: ~A" (string-from-list (place-item p))) - (format t "~&NPCs: ~A" (string-from-list (place-npc p)))) + (format t "~&NPCs: ~A" (string-from-list (place-npc p))) + (format t "~&Monsters: ~A" (string-from-list (place-monster p)))) (defun game-command (cmd player) "Execute a typed-in game command" @@ -108,7 +109,8 @@ (if (member command *commands*) (if space (funcall command player arg) (funcall command player)) - (format t "~&Sorry, this command does not exist!")))) + (progn (format t "~&Sorry, this command does not exist!") + (format t "~&Type 'help' for a list of commands."))))) ;;; diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 104884f..add4f71 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -24,24 +24,27 @@ (defstruct npc (name "") + (description "") (says "")) (defstruct monster (name "") (description "") (strength 0) + (aggression 0) + (weapon "") (armour-class 0)) (defstruct item (name "") (description "") + (weapon "") (function NIL)) (defstruct weapon (name "") (description "") (ranged NIL) - (condition 10) (damage 0)) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index 56a5dd8..b1b46d9 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -10,17 +10,25 @@ ;;; -(defun define-place (name) - (format t "~&Making place ~A" name) - (make-place :name name)) +(defun build-define-command (object-type) + "Build a new define command function for the specified object type" + #'(lambda (name) + (format t "~&Making ~A ~A" + (string-downcase (to-string object-type)) name) + (funcall (build-symbol "make-" object-type) :name name))) -(defun define-race (name) - (format t "~&Making race ~A" name) - (make-race :name name)) +(defmacro defcommand (command-name object-type) + `(defun ,command-name (name) + (funcall ,(build-define-command object-type) name))) -(defun define-class (name) - (format t "~&Making class ~A" name) - (make-character-class :name name)) +;;; Syntax for new define commands: +;;; (defcommand ) + +(defcommand define-place place) +(defcommand define-race race) +(defcommand define-class character-class) +(defcommand define-monster monster) +(defcommand define-weapon weapon) (defun start-place (place) (format t "~&Starting place is ~A" place) diff --git a/ATL/atl-mode.el b/ATL/atl-mode.el index 127b8fa..8d2dcfd 100644 --- a/ATL/atl-mode.el +++ b/ATL/atl-mode.el @@ -6,15 +6,16 @@ ;;; date: 22/05/2015 ;;; -(require 'generic-x) ;; we need this +(require 'generic-x) ;; we need this apparently - don't ask me why ;-) (define-generic-mode atl-mode '(";") ;; comments ;; define commands '("define-place" "define-item" "define-monster" "define-npc" - "define-race" "define-place" "name-world" "load-file" "start-place") - '() ;; other commands (adjust this? + "define-race" "define-place" "define-weapon" + "name-world" "load-file" "start-place") + '() ;; other commands (adjust this?) '("\\.atl$") ;; files for which to activate this mode - '(#'linum-mode) ;; other functions to call + '(linum-mode) ;; other functions to call "An Emacs mode for the ATL game description language" ;; doc string ) diff --git a/ATL/game-objects.atl b/ATL/game-objects.atl new file mode 100644 index 0000000..2bc47fa --- /dev/null +++ b/ATL/game-objects.atl @@ -0,0 +1,15 @@ +; This module defines items, NPCs, monsters and weapons for my +; Atlantis test world. +; @author Daniel Vedder +; @date 02/06/2015 + +define-monster "Fury" + description "Hades messengers, torturers, assassins. Beware!" + strength 10 + aggression 30 + armour-class 3 + weapon "fire-whip" + +define-weapon "fire-whip" + description "A 10-foot long whip, blazing with magical fire" + damage 2 \ No newline at end of file diff --git a/ATL/lisp-test.atl b/ATL/lisp-test.atl index 990bcbc..e8e0faf 100644 --- a/ATL/lisp-test.atl +++ b/ATL/lisp-test.atl @@ -19,8 +19,10 @@ description "Precisely where you do NOT want to end up..." neighbour "Nowhere" neighbour "Elysium" + monster "Fury" load-file lisp-test.atl ;Testing whether recursive loading is prevented load-file races-classes.atl +load-file game-objects.atl start-place "Nowhere" \ No newline at end of file diff --git a/lisp/client.lisp b/lisp/client.lisp index 0710804..ae72ff7 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -98,7 +98,8 @@ (format t "~&Neighbouring places: ~A" (string-from-list (place-neighbour p))) (format t "~&Players present: ~A" (string-from-list (place-player p))) (format t "~&Items: ~A" (string-from-list (place-item p))) - (format t "~&NPCs: ~A" (string-from-list (place-npc p)))) + (format t "~&NPCs: ~A" (string-from-list (place-npc p))) + (format t "~&Monsters: ~A" (string-from-list (place-monster p)))) (defun game-command (cmd player) "Execute a typed-in game command" @@ -108,7 +109,8 @@ (if (member command *commands*) (if space (funcall command player arg) (funcall command player)) - (format t "~&Sorry, this command does not exist!")))) + (progn (format t "~&Sorry, this command does not exist!") + (format t "~&Type 'help' for a list of commands."))))) ;;; diff --git a/lisp/game-objects.lisp b/lisp/game-objects.lisp index 104884f..add4f71 100644 --- a/lisp/game-objects.lisp +++ b/lisp/game-objects.lisp @@ -24,24 +24,27 @@ (defstruct npc (name "") + (description "") (says "")) (defstruct monster (name "") (description "") (strength 0) + (aggression 0) + (weapon "") (armour-class 0)) (defstruct item (name "") (description "") + (weapon "") (function NIL)) (defstruct weapon (name "") (description "") (ranged NIL) - (condition 10) (damage 0)) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index 56a5dd8..b1b46d9 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -10,17 +10,25 @@ ;;; -(defun define-place (name) - (format t "~&Making place ~A" name) - (make-place :name name)) +(defun build-define-command (object-type) + "Build a new define command function for the specified object type" + #'(lambda (name) + (format t "~&Making ~A ~A" + (string-downcase (to-string object-type)) name) + (funcall (build-symbol "make-" object-type) :name name))) -(defun define-race (name) - (format t "~&Making race ~A" name) - (make-race :name name)) +(defmacro defcommand (command-name object-type) + `(defun ,command-name (name) + (funcall ,(build-define-command object-type) name))) -(defun define-class (name) - (format t "~&Making class ~A" name) - (make-character-class :name name)) +;;; Syntax for new define commands: +;;; (defcommand ) + +(defcommand define-place place) +(defcommand define-race race) +(defcommand define-class character-class) +(defcommand define-monster monster) +(defcommand define-weapon weapon) (defun start-place (place) (format t "~&Starting place is ~A" place) diff --git a/lisp/world.lisp b/lisp/world.lisp index eec8780..78088c0 100644 --- a/lisp/world.lisp +++ b/lisp/world.lisp @@ -25,6 +25,7 @@ (monsters NIL) (npcs NIL) (items NIL) + (weapons NIL) (starting-place "") (game-manager "")) ;The player in charge of the game