Newer
Older
naledi / animals.lisp
;;;;
;;;; Naledi ya Africa ("Star of Africa") is an ncurses-based survival game
;;;; set in Africa.
;;;;
;;;; This file defines animal and species structs and the various species
;;;; found in-game.
;;;; 
;;;; (c) 2018 Daniel Vedder, MIT license
;;;;

(defmethod random-move ((a animal))
	(do* ((dir (random-elt *directions*) (random-elt *directions*))
			 (next-patch (patch-in-dir (.x a) (.y a) dir)
				 (patch-in-dir (.x a) (.y a) dir))
			 (ttl 10 (1- ttl)))
		((zerop ttl) NIL)
		(when (and next-patch (null (patch-occupant next-patch)))
			(setf (patch-occupant (coord (.x a) (.y a))) NIL)
			(setf (.x a) (first (patch-pos next-patch))
				(.y a) (second (patch-pos next-patch)))
			(setf (patch-occupant next-patch) a)
			(return-from random-move a))))

;;XXX bird species?
;;XXX water species?
;;XXX small mammals -> hills

(new-item species 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
	: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
	: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
	: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
	:strength 15 :max-health 20
	:aggression 10 :group-size 1
	:habitat '(grassland)
	:char #\C :color :yellow
	:drops NIL) ;TODO

(new-item species 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
	:strength 15 :max-health 20
	:aggression 5 :group-size 10
	:habitat '(swamp grassland)
	:char #\B :color :magenta
	:drops NIL) ;TODO

(new-item species oryx
	:strength 8 :max-health 12
	:aggression 0 :group-size 2
	:habitat '(desert grassland)
	:char #\a :color :blue
	:drops NIL) ;TODO