src/entities/food.lisp @ 903ab2ce309c

More flavors
author Steve Losh <>
date Sun, 08 Jan 2017 13:52:52 +0000
parents 0124edbf5a6f
children d61f3224d0dc
(in-package :ap.entities)

(defparameter *foods*
  (concatenate 'vector
               (read-file-into-form "data/vegetables.lisp")
               (read-file-into-form "data/meat.lisp")))

(defparameter *tastes*
  #("a bit rotten"
    "a bit strange"
    "better than nothing"
    "better than you expected"
    "faintly of mice"
    "like an old sock"
    "like it's brand new"
    "like it's starting to go bad"
    "like something else"
    "like something your father used to make"
    "like something your mother used to make"
    "pretty nice"

(define-entity food (visible coords holdable)
  (energy :accessor food/energy :initarg :food/energy))

(defun random-food-energy ()
  (random-range 30.0 80.0))

(defun random-food-description ()
  (format nil "a ~A of ~A"
          (random-elt #("can" "tin" "package"))
          (random-elt *foods*)))

(defun random-food-taste ()
  (format nil "It tastes ~A."
          (random-elt *tastes*)))

(defun make-food (x y)
  (create-entity 'food
    :coords/x x
    :coords/y y
    :visible/glyph "%"
    :visible/color ap::+black-yellow+
    :holdable/description (random-food-description)
    :food/energy (random-food-energy)))