RPG attributes generator: Difference between revisions

RPG attributes generator en BASIC256
(RPG attributes generator en Yabasic)
(RPG attributes generator en BASIC256)
Line 968:
Ready
</pre>
 
=={{header|BASIC256}}==
{{trans|FreeBASIC}}
<lang freebasic>function min(a, b)
if a < b then return a else return b
end function
 
function d6()
#simulates a marked regular hexahedron coming to rest on a plane
return 1 + int(rand * 6)
end function
 
function 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 function
 
arraybase 1
dim statnames$ = {"STR", "CON", "DEX", "INT", "WIS", "CHA"}
dim stat(6)
acceptable = false
 
do
sum = 0 : n15 = 0
for i = 1 to 6
stat[i] = roll_stat()
sum += stat[i]
if stat[i] >= 15 then n15 += 1
next i
if sum >= 75 and n15 >= 2 then acceptable = true
until acceptable
 
for i = 1 to 6
print statnames$[i]; ": "; stat[i]
next i
print "-------"
print "TOT: "; sum
end</lang>
{{out}}
<pre>Igual que la entrada de FreeBASIC.</pre>
 
=={{header|C}}==
2,122

edits