RPG attributes generator: Difference between revisions

no edit summary
m (→‎{{header|jq}}: rm reference to fq)
No edit summary
Line 1,916:
{{Out}}
<pre>roll str:13 dex:15 con:14 int:8 wis:17 cha:10 (total:77) ok</pre>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
_elements = 6
 
local fn min( a as long, b as long ) as long
long result
if ( a < b )
result = a : exit fn
else
result = b : exit fn
end if
end fn = result
 
local fn d6 as long
long result
result = 1 + int( rnd(_elements) )
end fn = result
 
local fn roll_stat as long
long result
long a = fn d6, b = fn d6, c = fn d6, d = fn d6
result = a + b + c + d - fn min( fn min( a, b ), fn min( c, d ) )
end fn = result
 
local fn DoIt
CFArrayRef statnames = @[@"Strength",@"Constitution",@"Dexterity",@"Intelligence",@"Wisdom",@"Charisma"]
long stat(_elements), n15, sum, i
BOOL acceptable = NO
randomize
do
sum = 0
n15 = 0
for i = 1 to _elements
stat(i) = fn roll_stat
sum = sum + stat(i)
if stat(i) >= 15 then n15++
next
if sum >= 75 and n15 >= 2 then acceptable = YES
until ( acceptable = YES )
for i = 1 to _elements
printf @"%12s %3ld", fn StringUTF8String( statnames[i -1] ), stat(i)
next
printf @"------------"
printf @"%13s %3ld", "Total:", sum
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Strength 17
Constitution 11
Dexterity 18
Intelligence 12
Wisdom 19
Charisma 11
------------
Total: 88
</pre>
 
 
715

edits