Jump to content

RPG attributes generator: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,403:
 
=={{header|Common Lisp}}==
===Mapping functions===
<syntaxhighlight lang="lisp">
(defpackage :rpg-generator
Line 1,423 ⟶ 1,424:
(return scores)))
</syntaxhighlight>
=== Loop macro ===
 
''Draft''
 
==== Note ====
 
See https://gigamonkeys.com/book/loop-for-black-belts.html
 
==== Program ====
 
<syntaxhighlight lang="lisp">;; 22.11.07 Draft
(defun score-jet-des ()
(loop :for resultat = (+ (random 6) 1)
:repeat 4
:sum resultat :into total
:minimize resultat :into minimum
:finally (return (- total minimum))))
 
(defun calcule-attributs-personnage ()
(loop named a
:do (loop :for score = (score-jet-des)
:repeat 6
:collect score :into scores
:sum score :into total
:count (>= score 15) :into frequence
:finally (when (and (>= total 75) (>= frequence 2))
(return-from a (values scores total))))))
</syntaxhighlight>
 
==== Execution ====
 
<pre>
(multiple-value-bind (scores total)
(calcule-attributs-personnage)
(list scores total))
</pre>
 
{{out}}
<pre>
((16 9 15 12 14 14) 80)
</pre>
 
''cyril nocton (cyril.nocton@gmail.com) w/ google translate''
=={{header|Cowgol}}==
<syntaxhighlight lang="cowgol">include "cowgol.coh";
422

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.