RPG attributes generator: Difference between revisions

→‎{{header|Forth}}: Add implementation
(→‎{{header|Atari BASIC}}: Add implementation.)
(→‎{{header|Forth}}: Add implementation)
Line 1,857:
STR DEX CON INT WIS CHA TOTAL
= 16 = 9 = 16 = 9 = 11 = 14 = 75</pre>
 
=={{header|Forth}}==
{{works with|GNU Forth}}
{{libheader|random.fs}}
<lang forth>require random.fs
: d6 ( -- roll ) 6 random 1 + ;
 
variable smallest
: genstat ( -- stat )
d6 dup smallest !
3 0 do
d6 dup smallest @ < if dup smallest ! then +
loop
smallest @ -
;
 
variable strong
variable total
: genstats ( -- cha wis int con dex str )
0 strong !
0 total !
6 0 do
genstat
dup 15 >= if strong @ 1 + strong ! then
dup total @ + total !
loop
total @ 75 < strong @ 2 < or if
drop drop drop drop drop drop
recurse
then
;
 
: roll ( -- )
genstats
." str:" . ." dex:" . ." con:" .
." int:" . ." wis:" . ." cha:" .
." (total:" total @ . 8 emit ." )"
;
 
utime drop seed !</lang>
 
{{Out}}
<pre>roll str:13 dex:15 con:14 int:8 wis:17 cha:10 (total:77) ok</pre>
 
 
=={{header|Go}}==
1,481

edits