;;;; ;;;; Naledi ya Africa ("Star of Africa") is an ncurses-based survival game ;;;; set in Africa. ;;;; ;;;; This file stores all game data. ;;;; ;;;; (c) 2018 Daniel Vedder, MIT license ;;;; ;; TODO save and load functions ;; XXX Will probably require `make-load-form-saving-slots' ;;; PATCHES (let ((world NIL)) (defun set-world (w) (setf world w)) (defun world-size () (length world)) (defun save-topography (file-name) ;XXX (re)move this? "Save the world topography as a text file" (debugging "~&Saving world to file ~A" file-name) ;debug (with-open-file (tf file-name :direction :output) (dolist (row world) (format stream "~&~A~%" (string-from-list (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" (unless (or (< x 0) (< y 0) (> x (length world)) (> y (length world))) (nth x (nth y world))))) ;;; BIOMES (let ((biome-list NIL)) (defun register-biome (symbol-name biome-object) (setf biome-list (cons (list symbol-name biome-object) biome-list))) (defun available-biomes () (keys biome-list)) (defun get-biome (symbol-name) (cassoc symbol-name biome-list))) (defmacro new-biome (name &body body) `(register-biome ',name (make-biome :name ,(symbol-to-string name) ,@body)))