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

;;TODO This needs to be done with CLOS

(defstruct item
	(name "")
	(description "")
	(weight 0)
	(movable T)
	(occupant NIL)
	(equipment NIL)
	(resource NIL)
	(destroy-with '())
	(drops '())
	(craft-with '())
	(action #'(lambda () NIL)))

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

	(defun get-item-type (symbol-name)
		(cassoc symbol-name item-list))

	(defun get-item (symbol-name)
		(copy-item (get-item-type symbol-name))))

(defmacro new-item (name &body body)
	`(register-item ,name
		 (make-item ,@body)))


;;; RESOURCE ITEMS

(new-item 'wood
	:name "wood" :weight 1
	:description "A block of wood, just right for working with")

(new-item 'stone
	:name "stone" :weight 2
	:description "A fist-sized stone. What are you going to do with it?")

(new-item 'iron
	:name "iron" :weight 3
	:description "An iron ingot, ready for further crafting.")

;;; LANDSCAPE FEATURES

(new-item 'acacia
	:name "acacia"
	:description "A tall acacia tree, spreading its branches wide."
	:destroy-with '(stone-axe iron-axe)
	:drops '(wood) :weight 2000
	:movable NIL :occupant T)

(new-item 'miombo
	:name "miombo"
	:description "A small, crooked miombo tree."
	:destroy-with '(stone-axe iron-axe)
	:drops '(wood) :weight 500
	:movable NIL :occupant T)

(new-item 'boulder
	:name "boulder"
	:description "A huge lump of grey basalt, sticking out of the ground."
	:destroy-with '(stone-pickaxe iron-pickaxe)
	:drops '(stone) :weight 5000
	:movable NIL :occupant T)

;;; TOOL ITEMS

;;TODO Faustkeil?

(new-item 'stone-axe
	:name "stone axe"
	:description "An axe, crudely but effectively fashioned out of stone."
	:weight 2 :craft-with '(stone wood))

(new-item 'iron-axe
	:name "iron axe"
	:description "A finely honed iron axe, just right for chopping wood."
	:weight 3 :craft-with '(iron wood))

(new-item 'stone-pickaxe
	:name "stone pickaxe"
	:description "A pickaxe, somewhat helplessly made from stone."
	:weight 3 :craft-with '(stone wood))

(new-item 'iron-pickaxe
	:name "iron pickaxe"
	:description "A solid iron pickaxe. Prepare to split rock!"
	:weight 4 :craft-with '(iron wood))