Newer
Older
naledi / animals.lisp
;;;;
;;;; Terra Nostra is a Minecraft-like survival game for the commandline.
;;;;
;;;; This file defines animal and species structs and the various species
;;;; found in-game.
;;;; 
;;;; (c) 2018 Daniel Vedder, MIT license
;;;;

(defstruct animal
	(pos '(0 0))
	(health 0)
	(species NIL))

;;TODO predatory species

(defstruct species
	(name "")
	(strength 0)
	(max-health 0)
	(aggression 0) ;attack probability %
	(group-size 1) ;maximum group size
	(habitat '()) ;preferred biomes
	(corpse-items '()))

(let ((species-list NIL))
	(defun register-species (symbol-name species-object)
		(setf species-list
			(cons (list symbol-name species-object) species-list)))

	(defun get-species (symbol-name)
		(cassoc symbol-name species-list)))

(register-species 'deer
	(make-species :name "deer"
		:strength 3 :max-health 10 :aggression 0
		:group-size 10
		:habitat '(forest grassland)
		:corpse-items NIL)) ;TODO

(register-species 'boar
	(make-species :name "boar"
		:strength 7 :max-health 15 :aggression 5
		:group-size 5
		:habitat '(forest)
		:corpse-items NIL)) ;TODO

(register-species 'wolf
	(make-species :name "wolf"
		:strength 10 :max-health 20 :aggression 20
		:group-size 6
		:habitat '(grassland)
		:corpse-items 'NIL)) ;TODO

(register-species 'bear
	(make-species :name "bear"
		:strength 20 :max-health 30 :aggression 20
		:group-size 1
		:habitat '(forest)
		:corpse-items 'NIL)) ;TODO