X-Git-Url: https://git.distorted.org.uk/~mdw/dnd/blobdiff_plain/ac6c07c4feeaea33c25b4696bbcb6b27e594624c..da704ab3e5163297d581bf4d06fd3a31dbdc42fe:/dice.lisp diff --git a/dice.lisp b/dice.lisp index 3f17c62..ee031fa 100644 --- a/dice.lisp +++ b/dice.lisp @@ -183,6 +183,15 @@ collect n collect `(lambda () ,@clause))))) +(defmacro pick-matching ((form &key) &body clauses) + (let ((formtemp (gensym "FORM"))) + `(let ((,formtemp ,form)) + (pick ,@(loop for (prob assertion . code) in clauses + collect `((if (assertion-match-p ,formtemp ',assertion) + ,prob + 0) + ,@code)))))) + (defconstant cleric-spells #((cure-light-wounds detect-evil detect-magic light protection-from-evil purify-food-and-water remove-fear resist-cold) @@ -307,15 +316,6 @@ (decf len) (setf (aref copy j) (aref copy len)))))) -(defmacro pick-matching ((form &key) &body clauses) - (let ((formtemp (gensym "FORM"))) - `(let ((,formtemp ,form)) - (pick ,@(loop for (prob assertion . code) in clauses - collect `((if (assertion-match-p ,formtemp ',assertion) - ,prob - 0) - ,@code)))))) - (defun magic-item (form) (labels ((cursedp (&optional (prob 10)) (cond ((assertion-match-p form '(:cursed :unspecified)) @@ -835,26 +835,27 @@ ((a) (let* ((bonus (weapon-bonus 'a)) (cursedp (zerop (random 10))) (talent (and (percentp (* 5 (- 7 bonus))) - (choose 4 'biting - 5 'blinking - 5 'charming - 7 'climbing - 10 'curing - 3 'disarming - 4 'dispelling - 7 'flying - 7 'lightning - 5 'penetrating - 4 'refilling - 6 'screaming - 5 'seeking - 4 'sinking - 2 'slaying - 7 'speaking - 4 'stunning - 2 'teleporting - 5 'transporting - 4 'wounding))) + (pick (4 'biting) + (5 'blinking) + (5 'charming) + (7 'climbing) + (10 'curing) + (3 'disarming) + (4 'dispelling) + (7 'flying) + (7 'lightning) + (5 'penetrating) + (4 'refilling) + (6 'screaming) + (5 'seeking) + (4 'sinking) + (2 `(slaying + :opponent ,(opponent))) + (7 'speaking) + (4 'stunning) + (2 'teleporting) + (5 'transporting) + (4 'wounding)))) (number (ecase bonus ((1) (d 10 2)) ((2) (d 8 2))