diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/item-classes.lisp b/item-classes.lisp index 1286189..2643ca9 100644 --- a/item-classes.lisp +++ b/item-classes.lisp @@ -50,7 +50,7 @@ (max-weight :reader .max-weight :initarg :max-weight :initform -1) (capacity :reader .capacity :initarg :capacity :initform 0))) -(defclass species (feature) +(defclass animal (feature) ;; An animal species (;; species properties (strength :accessor .strength :initarg :strength :initform 1) @@ -59,7 +59,7 @@ (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) ;; individual properties - (id :reader .id :initarg :id :initform -1) + (id :reader .id :initarg :id :initform -1)) (:default-initargs :destroy-with '(weapon) :movable T)) diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/item-classes.lisp b/item-classes.lisp index 1286189..2643ca9 100644 --- a/item-classes.lisp +++ b/item-classes.lisp @@ -50,7 +50,7 @@ (max-weight :reader .max-weight :initarg :max-weight :initform -1) (capacity :reader .capacity :initarg :capacity :initform 0))) -(defclass species (feature) +(defclass animal (feature) ;; An animal species (;; species properties (strength :accessor .strength :initarg :strength :initform 1) @@ -59,7 +59,7 @@ (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) ;; individual properties - (id :reader .id :initarg :id :initform -1) + (id :reader .id :initarg :id :initform -1)) (:default-initargs :destroy-with '(weapon) :movable T)) diff --git a/item-methods.lisp b/item-methods.lisp index 9440b90..3c5e02e 100644 --- a/item-methods.lisp +++ b/item-methods.lisp @@ -22,6 +22,9 @@ (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) +;;TODO (defmethod attack ((f feature) (tl tool))) +;;TODO (defmethod attack ((a animal) (w weapon))) + (defmethod update ((a animal)) (random-move a)) diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/item-classes.lisp b/item-classes.lisp index 1286189..2643ca9 100644 --- a/item-classes.lisp +++ b/item-classes.lisp @@ -50,7 +50,7 @@ (max-weight :reader .max-weight :initarg :max-weight :initform -1) (capacity :reader .capacity :initarg :capacity :initform 0))) -(defclass species (feature) +(defclass animal (feature) ;; An animal species (;; species properties (strength :accessor .strength :initarg :strength :initform 1) @@ -59,7 +59,7 @@ (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) ;; individual properties - (id :reader .id :initarg :id :initform -1) + (id :reader .id :initarg :id :initform -1)) (:default-initargs :destroy-with '(weapon) :movable T)) diff --git a/item-methods.lisp b/item-methods.lisp index 9440b90..3c5e02e 100644 --- a/item-methods.lisp +++ b/item-methods.lisp @@ -22,6 +22,9 @@ (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) +;;TODO (defmethod attack ((f feature) (tl tool))) +;;TODO (defmethod attack ((a animal) (w weapon))) + (defmethod update ((a animal)) (random-move a)) diff --git a/naledi.lisp b/naledi.lisp index 1f06386..1dae3d9 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -9,12 +9,15 @@ (defparameter *debugging* T) +(defparameter *logfile* "naledi.log") +(ql:quickload :bordeaux-threads) (ql:quickload :croatoan) (use-package :croatoan) (load "util.lisp") -(load "classes.lisp") +(load "item-classes.lisp") +(load "item-methods.lisp") (load "data.lisp") (load "world.lisp") (load "items.lisp") @@ -24,6 +27,7 @@ (defun start-game () (setf *random-state* (make-random-state t)) (create-world 250) + (bt:make-thread #'update-loop :name "world-thread") (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t :cursor-visibility nil :input-reading :unbuffered) (splash-screen scr) diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/item-classes.lisp b/item-classes.lisp index 1286189..2643ca9 100644 --- a/item-classes.lisp +++ b/item-classes.lisp @@ -50,7 +50,7 @@ (max-weight :reader .max-weight :initarg :max-weight :initform -1) (capacity :reader .capacity :initarg :capacity :initform 0))) -(defclass species (feature) +(defclass animal (feature) ;; An animal species (;; species properties (strength :accessor .strength :initarg :strength :initform 1) @@ -59,7 +59,7 @@ (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) ;; individual properties - (id :reader .id :initarg :id :initform -1) + (id :reader .id :initarg :id :initform -1)) (:default-initargs :destroy-with '(weapon) :movable T)) diff --git a/item-methods.lisp b/item-methods.lisp index 9440b90..3c5e02e 100644 --- a/item-methods.lisp +++ b/item-methods.lisp @@ -22,6 +22,9 @@ (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) +;;TODO (defmethod attack ((f feature) (tl tool))) +;;TODO (defmethod attack ((a animal) (w weapon))) + (defmethod update ((a animal)) (random-move a)) diff --git a/naledi.lisp b/naledi.lisp index 1f06386..1dae3d9 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -9,12 +9,15 @@ (defparameter *debugging* T) +(defparameter *logfile* "naledi.log") +(ql:quickload :bordeaux-threads) (ql:quickload :croatoan) (use-package :croatoan) (load "util.lisp") -(load "classes.lisp") +(load "item-classes.lisp") +(load "item-methods.lisp") (load "data.lisp") (load "world.lisp") (load "items.lisp") @@ -24,6 +27,7 @@ (defun start-game () (setf *random-state* (make-random-state t)) (create-world 250) + (bt:make-thread #'update-loop :name "world-thread") (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t :cursor-visibility nil :input-reading :unbuffered) (splash-screen scr) diff --git a/util.lisp b/util.lisp index da2029c..02a7e3e 100644 --- a/util.lisp +++ b/util.lisp @@ -14,7 +14,9 @@ "If *debugging* is true, print str" `(when *debugging* (format t ,str ,@format-args))) -;;TODO write `logging' macro +(defmacro logging (str &rest format-args) + "Write an entry to *logfile*" + `(write-to-file (format NIL ,str ,@format-args) *logfile* T)) (defmacro set-list (value &rest var-list) "Set each symbol in var-list to value" diff --git a/TODO b/TODO index 4583e01..7b2cf8a 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,8 @@ GAME * introduce multithreading, update functions + +* set up an ASDF system, define packages * (I am legion...) diff --git a/animals.lisp b/animals.lisp index 3e0cabd..a253200 100644 --- a/animals.lisp +++ b/animals.lisp @@ -12,56 +12,56 @@ ;;XXX water species? ;;XXX small mammals -> hills -(new-item species impala +(new-item animal impala :strength 3 :max-health 10 :aggression 0 :group-size 15 :habitat '(forest grassland) :char #\a :color :yellow :drops NIL) ;TODO -(new-item species warthog +(new-item animal warthog :strength 5 :max-health 10 :aggression 2 :group-size 5 :habitat '(forest grassland swamp hill) :char #\p :color :magenta :drops NIL) ;TODO -(new-item species lion +(new-item animal lion :strength 18 :max-health 25 :aggression 20 :group-size 6 :habitat '(grassland swamp desert) :char #\C :color :red :drops NIL) ;TODO -(new-item species leopard +(new-item animal leopard :strength 20 :max-health 30 :aggression 20 :group-size 1 :habitat '(forest grassland hill) :char #\C :color :magenta :drops NIL) ;TODO -(new-item species cheetah +(new-item animal cheetah :strength 15 :max-health 20 :aggression 10 :group-size 1 :habitat '(grassland) :char #\C :color :yellow :drops NIL) ;TODO -(new-item species elephant +(new-item animal elephant :strength 40 :max-health 50 :aggression 5 :group-size 4 :habitat '(forest grassland) :char #\E :color :cyan :drops NIL) ;TODO -(new-item species buffalo +(new-item animal buffalo :strength 15 :max-health 20 :aggression 5 :group-size 10 :habitat '(swamp grassland) :char #\B :color :magenta :drops NIL) ;TODO -(new-item species oryx +(new-item animal oryx :strength 8 :max-health 12 :aggression 0 :group-size 2 :habitat '(desert grassland) diff --git a/data.lisp b/data.lisp index 55a60d7..c89241e 100644 --- a/data.lisp +++ b/data.lisp @@ -27,6 +27,10 @@ (mapcar #'(lambda (p) (biome-char (patch-biome p))) row) ""))))) + + (defun save-world () + ;;TODO + ) (defun coord (x y) "Return the patch at the given coordinates or NIL if out of bounds" diff --git a/item-classes.lisp b/item-classes.lisp index 1286189..2643ca9 100644 --- a/item-classes.lisp +++ b/item-classes.lisp @@ -50,7 +50,7 @@ (max-weight :reader .max-weight :initarg :max-weight :initform -1) (capacity :reader .capacity :initarg :capacity :initform 0))) -(defclass species (feature) +(defclass animal (feature) ;; An animal species (;; species properties (strength :accessor .strength :initarg :strength :initform 1) @@ -59,7 +59,7 @@ (group-size :reader .group-size :initarg :group-size :initform 1) (habitat :reader .habitat :initarg :habitat :initform '()) ;; individual properties - (id :reader .id :initarg :id :initform -1) + (id :reader .id :initarg :id :initform -1)) (:default-initargs :destroy-with '(weapon) :movable T)) diff --git a/item-methods.lisp b/item-methods.lisp index 9440b90..3c5e02e 100644 --- a/item-methods.lisp +++ b/item-methods.lisp @@ -22,6 +22,9 @@ (leading-vowl (.name d)) (leading-vowel (.name tl))) NIL))) +;;TODO (defmethod attack ((f feature) (tl tool))) +;;TODO (defmethod attack ((a animal) (w weapon))) + (defmethod update ((a animal)) (random-move a)) diff --git a/naledi.lisp b/naledi.lisp index 1f06386..1dae3d9 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -9,12 +9,15 @@ (defparameter *debugging* T) +(defparameter *logfile* "naledi.log") +(ql:quickload :bordeaux-threads) (ql:quickload :croatoan) (use-package :croatoan) (load "util.lisp") -(load "classes.lisp") +(load "item-classes.lisp") +(load "item-methods.lisp") (load "data.lisp") (load "world.lisp") (load "items.lisp") @@ -24,6 +27,7 @@ (defun start-game () (setf *random-state* (make-random-state t)) (create-world 250) + (bt:make-thread #'update-loop :name "world-thread") (with-screen (scr :input-echoing nil :input-blocking t :enable-colors t :cursor-visibility nil :input-reading :unbuffered) (splash-screen scr) diff --git a/util.lisp b/util.lisp index da2029c..02a7e3e 100644 --- a/util.lisp +++ b/util.lisp @@ -14,7 +14,9 @@ "If *debugging* is true, print str" `(when *debugging* (format t ,str ,@format-args))) -;;TODO write `logging' macro +(defmacro logging (str &rest format-args) + "Write an entry to *logfile*" + `(write-to-file (format NIL ,str ,@format-args) *logfile* T)) (defmacro set-list (value &rest var-list) "Set each symbol in var-list to value" diff --git a/world.lisp b/world.lisp index df9744f..d5f683e 100644 --- a/world.lisp +++ b/world.lisp @@ -160,6 +160,27 @@ (dotimes (s (round (/ (expt size 2) 2000))) (generate-stream (random size) (random size)))) +(let ((uptime 0)) + (defun update-loop () + "The main loop, updating the world in the background" + ;;Update all items in each patch + (dotimes (y (world-size)) + (dotimes (x (world-size)) + (dolist (i (patch-items (coord x y))) + (update i)))) + ;;Update all items each player has + ;;TODO + ;;Save the world and start over + (save-world) ;XXX not yet implemented + (incf uptime) + (logging "Ran update ~S." uptime) + (sleep 0.5) + (update-loop)) ;;requires Tail-Call Optimization + + (defun age-of-the-world () uptime) + + (defun reset-world-age () (setf uptime 0))) + (defun describe-patch (p) "Return a list of lines describing this patch." (list (string-upcase (biome-name (patch-biome p))) ""