RPG attributes generator: Difference between revisions

RPG attributes generator en Yabasic
(→‎{{header|Forth}}: Add implementation)
(RPG attributes generator en Yabasic)
Line 3,754:
Their total is: 79
</pre>
 
=={{header|Yabasic}}==
{{trans|FreeBASIC}}
<lang freebasic>sub d6()
//simulates a marked regular hexahedron coming to rest on a plane
return 1 + int(ran(6))
end sub
 
sub roll_stat()
//rolls four dice, returns the sum of the three highest
a = d6() : b = d6(): c = d6(): d = d6()
return a + b + c + d - min(min(a, b), min(c, d))
end sub
 
dim statnames$(6)
statnames$(1) = "STR"
statnames$(2) = "CON"
statnames$(3) = "DEX"
statnames$(4) = "INT"
statnames$(5) = "WIS"
statnames$(6) = "CHA"
 
dim stat(6)
acceptable = false
 
repeat
sum = 0
n15 = 0
for i = 1 to 6
stat(i) = roll_stat()
sum = sum + stat(i)
if stat(i) >= 15 then n15 = n15 + 1 : fi
next i
if sum >= 75 and n15 >= 2 then acceptable = true : fi
until acceptable
 
for i = 1 to 6
print statnames$(i), ": ", stat(i) using "##"
next i
print "-------\nTOT: ", sum
end</lang>
{{out}}
<pre>Igual que la entrada de FreeBASIC.</pre>
 
=={{header|zkl}}==
2,122

edits