Jump to content

RPG attributes generator: Difference between revisions

Add Red
(RPG attributes generator en Run BASIC)
(Add Red)
Line 3,293:
(Str => 15 Int => 16 Wis => 13 Dex => 11 Con => 15 Cha => 6)
Sum: 76, with 3 attributes >= 15
</pre>
 
=={{header|Red}}==
<lang rebol>Red ["RPG attributes generator"]
 
raw-attribute: does [
sum next sort collect [
loop 4 [keep random/only 6]
]
]
 
raw-attributes: does [
collect [
loop 6 [keep raw-attribute]
]
]
 
valid-attributes?: func [b][
n: 0
foreach attr b [
if attr > 14 [n: n + 1]
]
all [
n > 1
greater? sum b 74
]
]
 
attributes: does [
until [
valid-attributes? a: raw-attributes
]
a
]
 
show-attributes: function [a][
i: 1
foreach stat-name [
"Strength"
"Dexterity"
"Constitution"
"Intelligence"
"Wisdom"
"Charisma"
][
print [rejoin [stat-name ":"] a/:i]
i: i + 1
]
print "-----------------"
print ["Sum:" sum a]
print [n "attributes > 14"]
]
 
show-attributes attributes</lang>
{{out}}
<pre>
Strength: 14
Dexterity: 11
Constitution: 16
Intelligence: 9
Wisdom: 16
Charisma: 16
-----------------
Sum: 82
3 attributes > 14
</pre>
 
1,827

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.