RPG attributes generator: Difference between revisions

Content added Content deleted
(Added R.)
(→‎{{header|R}}: Bug fix.)
Line 2,793: Line 2,793:
<lang R>genStats <- function()
<lang R>genStats <- function()
{
{
stats <- c(STR = 0, DEX = 0, CON = 0, INT = 0, WIS = 0, CHA = 0, TOT = 0)
stats <- c(STR = 0, DEX = 0, CON = 0, INT = 0, WIS = 0, CHA = 0)
for(i in seq_along(stats))
for(i in seq_along(stats))
{
{
Line 2,799: Line 2,799:
stats[i] <- sum(results[-which.min(results)])
stats[i] <- sum(results[-which.min(results)])
}
}
if(sum(stats >= 15) < 2 || (stats[length(stats)] <- sum(stats)) < 75) Recall() else stats
stats["TOT"] <- sum(stats)
if(sum(stats >= 15) < 2 || stats["TOT"] < 75) Recall() else stats
}
}
print(genStats())</lang>
print(genStats())</lang>
Line 2,805: Line 2,806:
{{out}}
{{out}}
<pre>STR DEX CON INT WIS CHA TOT
<pre>STR DEX CON INT WIS CHA TOT
9 13 16 11 14 15 88 </pre>
16 14 9 9 14 15 77 </pre>


=={{header|Raku}}==
=={{header|Raku}}==