 (defvar orc-battle-monsters nil)
 (defvar orc-battle-monster-builders nil)
 (defvar orc-battle-monster-num 12)
+
+;; helper
+(defun randval (n)
+  (1+ (random (max 1 n))))
 
 (defun orc-battle ()
   (interactive)


(defmethod monster-attack (m))

(defclass orc (monster) ((club-level (randval 8))))
(push 'make-orc orc-battle-monster-builders)

(defmethod monster-show ((m orc))
  (insert "A wicked orc with a level ")
  (insert (orc-club-level m))
  (insert " club"))

(defmethod monster-attack ((m orc))
  (let ((x (randval (orc-club-level m))))
       (insert "An orc swings his club at you and knocks off ")
       (insert x)
       (insert " of your health points. ")
       (decf orc-battle-player-health x)))

(defclass hydra (monster) ())
(push 'make-hydra orc-battle-monster-builders)

(defmethod monster-show ((m hydra))
  (insert "A malicious hydra with ")
  (insert (monster-health m))
  (insert " heads."))

(defmethod monster-hit ((m hydra) x)
  (decf (monster-health m) x)
  (if (monster-dead m)
      (insert "The corpse of the fully decapitated and decapacitated hydra
falls to the floor!")
      (progn (insert "You lop off ")
              (insert x)
              (insert " of the hydra's heads! "))))

(defmethod monster-attack ((m hydra))
  (let ((x (randval (ash (monster-health m) -1))))
    (insert "A hydra attacks you with ")
    (insert x)
    (insert " of its heads! It also grows back one more head! ")
    (incf (monster-health m))
    (decf orc-battle-player-health x)))

(defclass slime-mold (monster) ((sliminess (randval 5))))
(push 'make-slime-mold orc-battle-monster-builders)

(defmethod monster-show ((m slime-mold))
  (insert "A slime mold with a sliminess of ")
  (insert (slime-mold-sliminess m)))

(defmethod monster-attack ((m slime-mold))
  (let ((x (randval (slime-mold-sliminess m))))
       (insert "A slime mold wraps around your legs and decreases your agility
by ")
       (insert x)
       (insert "! ")
       (decf orc-battle-player-agility x)
       (when (zerop (random 2))
         (insert "It also squirts in your face, taking away a health point! ")
         (decf orc-battle-player-health))))

(defclass brigand (monster) ())
(push 'make-brigand orc-battle-monster-builders)

(defmethod monster-attack ((m brigand))
  (let ((x (max orc-battle-player-health orc-battle-player-agility orc-battle-player-strength)))

    (insert "Congratulations! You have vanquished all of your foes.")))

(defun game-loop ()
  (insert "----------")
  (unless (or (player-dead) (monsters-dead))
    (show-player)
    (dotimes (k (1+ (truncate (/ (max 0 orc-battle-player-agility) 15))))
