Newer
Older
naledi / biomes.lisp
;;;;
;;;; Terra Nostra is a Minecraft-like survival game for the commandline.
;;;;
;;;; Biomes are habitat types, that provide default functions for patches.
;;;; This file defines the biome struct and the inbuilt biomes.
;;;; 
;;;; (c) 2018 Daniel Vedder, MIT license
;;;;

;; Biome struct and register

(defstruct biome
	(name "")
	(ground "")
	(occupants '()) ;an alist of possible occupants and their probabilities
	(char #\.) ;default map display character
	(col ':white)) ;default map display colour

(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 ,@body)))


;; Biome definitions

(new-biome 'grassland
	:name "grassland"
	:ground "tall elephant grass"
	:char #\; :col ':yellow
	:occupants '((acacia 5) (boulder 1))) ;TODO

(new-biome 'forest
	:name "forest"
	:ground "leaf litter and small shrubs"
	:char #\. :col ':green
	:occupants '((miombo 20) (acacia 10))) ;TODO

(new-biome 'stream
	:name "stream"
	:ground "shallow flowing water"
	:char #\~ :col ':blue
	:occupants '()) ;TODO

(new-biome 'swamp
	:name "swamp"
	:ground "short sedge grass growing on boggy black soil"
	:char #\w :col ':green
	:occupants '()) ;TODO

(new-biome 'hill
	:name "hill"
	:ground "hard, stony soil"
	:char #\m :col ':white
	:occupants '((boulder 15))) ;TODO