RPG attributes generator: Difference between revisions
Content added Content deleted
No edit summary |
Cyril Nocton (talk | contribs) No edit summary |
||
Line 1,403: | Line 1,403: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
===Mapping functions=== |
|||
<syntaxhighlight lang="lisp"> |
<syntaxhighlight lang="lisp"> |
||
(defpackage :rpg-generator |
(defpackage :rpg-generator |
||
Line 1,423: | Line 1,424: | ||
(return scores))) |
(return scores))) |
||
</syntaxhighlight> |
</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}}== |
=={{header|Cowgol}}== |
||
<syntaxhighlight lang="cowgol">include "cowgol.coh"; |
<syntaxhighlight lang="cowgol">include "cowgol.coh"; |