40 lines
809 B
JavaScript
40 lines
809 B
JavaScript
|
/**
|
||
|
* Based on Cb's get character code
|
||
|
*/
|
||
|
module.exports = function(config) {
|
||
|
var throwStat = function() {
|
||
|
// Heittää 4 kertaa d6:n, tiputtaa heikoimman tuloksen ja laskee
|
||
|
// loput yhteen
|
||
|
|
||
|
var throws = [];
|
||
|
var sum = 0;
|
||
|
for( var i = 0; i < 4; i++ ) {
|
||
|
var t = Math.floor(Math.random()*6)+1;
|
||
|
throws.push(t);
|
||
|
}
|
||
|
|
||
|
throws.sort();
|
||
|
throws.reverse();
|
||
|
|
||
|
var sum = 0;
|
||
|
for(var i = 0; i < 3; i++) {
|
||
|
sum += throws[i];
|
||
|
}
|
||
|
|
||
|
return sum;
|
||
|
};
|
||
|
|
||
|
var getDnDCharacter = function() {
|
||
|
var statPoints = 'DnD-statsit:';
|
||
|
var total = 0;
|
||
|
for( var i = 0; i < 6; i++) {
|
||
|
var newStat = throwStat();
|
||
|
statPoints += ' '; // erotetaan sanat toisistaan
|
||
|
statPoints += newStat;
|
||
|
total += Number(newStat);
|
||
|
}
|
||
|
statPoints += ' ('+total+')';
|
||
|
return statPoints;
|
||
|
};
|
||
|
return getDnDCharacter;
|
||
|
};
|