anchor.diff:      ("vote" (ww-vote-command module message (second args)))
       (t
        (reply-to message "Usage: .ww start|list|vote <nick>"))))
  -
  -(defun test-ww ()
  -  (setf *m* (make-instance 'werewolf-module))
  -  (start-werewolf-game *m* "#ww")
  -  (add-werewolf-player *m* "Alice")
  -  (add-werewolf-player *m* "Bob")
  -  (add-werewolf-player *m* "Mallory")
  -  (begin-werewolf-game *m*))
positive.code:         :key 'nick-of))
  
  (defun ww-inform (module player fmt &rest args)
    (declare (ignore module))
    (format t "~a: ~?~%" player fmt args)
    #+nil
    (cl-irc:privmsg (conn-of module) (nick-of player) (format nil "~?~%" fmt args)))
  
  
  (defun ww-msg-players (module fmt &rest args)
      (format t "~a: ~?~%" (channel-of module) fmt args) #+nil
    (cl-irc:privmsg (conn-of module) (channel-of module) (format nil "~?~%" fmt args)))
  
  (defun ww-msg-wolves (module fmt &rest args)
    (dolist (player (players-of module))
      (when (werewolf? player)
        (apply 'ww-inform module player fmt args))))
  
  (defun select-victim (module)
    (let* ((votes (mapcar 'vote-of (players-of module)))
           (counts (mapcar (lambda (vote)
                             (cons vote (count vote votes)))
                           (remove-duplicates votes))))
  
negative.code: (defun start-werewolf-nighttime (module)
    (assert (eql (state-of module) 'day))
    (setf (state-of module) 'night)
    (let ((victim (select-victim (players-of module))))
      (cond
        (victim
         (setf (alive? victim) nil)
         (ww-msg-players module "Evening comes...  The villagers come together and lynch ~a!" (nick-of victim))
         (check-werewolf-win module)
         (unless (eql (state-of module) 'unstarted)
           (ww-inform module victim
                      "You are now dead.  Feel free to watch, but please wait until the next game to participate.")))
        (t
         (ww-msg-players module "Evening comes...  The villagers decide to cower in their homes." ))))
    (unless (eql (state-of module) 'unstarted)
      (dolist (player (players-of module))
        (setf (vote-of player) nil))
      (ww-msg-players module "Nighttime has fallen...  The werewolves choose a victim in secret." )))
  
  (defun start-werewolf-daytime (module)
    (assert (eql (state-of module) 'night))
    (setf (state-of module) 'day)
    (let ((victim (select-victim (remove-if-not 'werewolf? (players-of module)))))
      (cond
        (victim
         (setf (alive? victim) nil)
         (ww-msg-players module "Morning comes...  and ~a is found dead at home, ripped to shreds!"
                         (nick-of victim))
         (check-werewolf-win module)
         (unless (eql (state-of module) 'unstarted)
           (ww-inform module victim
                      "You are now dead.  Feel free to watch, but please wait until the next game to participate.")))
        (t
         (ww-msg-players module "Morning comes...  Everyone seems to be safe... Whew!" ))))
    (unless (eql (state-of module) 'unstarted)
      (dolist (player (players-of module))
        (setf (vote-of player) nil))
      (ww-msg-players module "The villagers come together in a town meeting to point fingers.")))
  
  (defun list-werewolf-players (module player-nick)
    (let* ((player (find-ww-player module player-nick))
           (sorted-players (sort (players-of module) #'string< :key 'nick-of))
           (living (remove-if-not 'alive? sorted-players))
           (dead (remove-if 'alive? sorted-players)))
      (cond
        ((null player)
         (cl-irc:privmsg (conn-of module) player-nick "You are not playing the werewolf game."))
        ((werewolf? player)
         (ww-inform module player
                    "Werewolves: ~{~a~^, ~} / Food: ~{~a~^, ~} / Dead: ~:[Nobody yet~;~:*~{~a~^, ~}~]"
                    (mapcar 'nick-of (remove-if-not 'werewolf? living))
                    (mapcar 'nick-of (remove-if 'werewolf? living))
                    (mapcar 'nick-of dead)))
  
        (t
         (ww-inform module player
                    "The quick: ~{~a~^,n ~} / The dead: ~:[Nobody yet~;~:*~{~a~^, ~}~]"
                    (mapcar 'nick-of living)
                    (mapcar 'nick-of dead))))))
  
  (defun begin-werewolf-game (module)
    (assert (eql (state-of module) 'starting))
    (setf (state-of module) 'night)
    ;; Pick werewolves
    (loop repeat (max 1 (floor (sqrt (length (players-of module))) 2)) do
         (let ((werewolf (random-elt (remove-if 'werewolf? (players-of module)))))
           (setf (werewolf? werewolf) t)))
    ;; Let everyone know their role
    (dolist (player (players-of module))
      (if (werewolf? player)
          (ww-inform module player "You are a werewolf.  You vote at night with other werewolves to murder villagers.   Be sure to /MSG orca .ww vote <nick> to keep your identity private.")
          (ww-inform module player "You are a villager."))
      (list-werewolf-players module (nick-of player)))
    (ww-msg-players module "Nighttime has fallen...  The werewolves choose a victim in secret." ))
  